Message ID | 20230128005150.never.909-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1126089wrn; Fri, 27 Jan 2023 16:59:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuRTWqBWalCRh8VzXyuR7xYUp+wvVbXdISLFZIUt+WPSr50JTbLpG4dctyMbGmmNuMxa8SB X-Received: by 2002:a17:907:6746:b0:84d:1c67:97d7 with SMTP id qm6-20020a170907674600b0084d1c6797d7mr51009754ejc.30.1674867594508; Fri, 27 Jan 2023 16:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674867594; cv=none; d=google.com; s=arc-20160816; b=F8XZiQis7aeVyd3oNCJtLctL7OX4uAS3slqetFwSjDJ1vWUuLNJCYF68b+YqBXidpb oPrhyl8k7U3M+UGV9GcE9bN+QivQajjGfLDbqUYO6hPBdrODaKDAiK5aePXKf9QhVlT0 +PGhUqqlKe37HI6rtXONx0z6EhfQJgFptz/gB2HjTinmFXrcyIc7n3k03yFA8AAnHy8m YZJZPJgkjXndh/C+17jguDizR2NPMH2lKhIA++Q/ChkX83Ko5LIp4KMNhbiWLegGMZGx U9pnRmeS8e2nEM2wEfkl5TyuvyulF4MgUlvYuFUY0mURQQG3/P3kHBmSZ0LmgCW5MOSE sBPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MiU9G7/Ds/01bMEGuQC9LxFoYAJoQIyJyB7uaGN1BVg=; b=S+9uPQiNVU84vFRwnoGPye1LErEoZBdhuTgGskjkRIMp6hp2qzEtEESysLngM3pSTb TxIIyQnBG3b/9GrGQruP5L25Ehu7I8P4R60qCEOxjeRkJYCBqIYnitwwESHkQH9pkAJ0 Jp8dD5vFnTN/Mq3j67QGH2wXEkiW65RiT1agsf8jzwL/FYWD4AzGIYGk5brzLVDARMvx MsEVXXyJAUDQtSuwHxeCx9yiGq/ZY4HBsY5LDpqqaVMERepeZg0bwBZ4yRBEg3RYbWgq hJMWl44iQAiTmoDuioNAXhSK4aLNTz1fUpJ/FPM4oX8C70ABqqakfpD3XW+NguxVhJ96 Q8MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OLznq80N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f9-20020a1709063f4900b008781794d6desi6242960ejj.715.2023.01.27.16.59.31; Fri, 27 Jan 2023 16:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OLznq80N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbjA1AwB (ORCPT <rfc822;jesperjuhl76@gmail.com> + 99 others); Fri, 27 Jan 2023 19:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbjA1Av6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 27 Jan 2023 19:51:58 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDFF7E6B0 for <linux-kernel@vger.kernel.org>; Fri, 27 Jan 2023 16:51:57 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id v3so4275041pgh.4 for <linux-kernel@vger.kernel.org>; Fri, 27 Jan 2023 16:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MiU9G7/Ds/01bMEGuQC9LxFoYAJoQIyJyB7uaGN1BVg=; b=OLznq80N8Oh4QKvXlMNb3ih7XmBuOr005NMxnz1LIqYtgjmVS4YuyblUnj4zWitmjZ lJCBYiXm4J7ZPtv8qMBJLQ2QyrCPUVlMoHuTzG6nrKbe2t4bMMlp9FCurOKdogoN8i4l hQWxAh2177dSgrm4CatTUBP0hAX9SrJm5fmoc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MiU9G7/Ds/01bMEGuQC9LxFoYAJoQIyJyB7uaGN1BVg=; b=hGoyGUpJIb7XMerWkNYb0U1yjDPS9AgQk2yAJkJeAslACxOzw+Rk9eofvAiQ6VbYH4 CtVDtUI77HwcOA7GPcR42I1OQ2GkTwZdbSsOJDuqfwFxnWlyVY4KMrBH2Qha1/ACD5CE +RB46AA40oJIMJLBsTZ7PFs6N0XqeRhJKADtTL0AKeVvsmrYjpyYp0aIfu+d0xUiC50x /mnMchPWVpnr7Jbub/GdGBrbpMmqIJR95yi7qR2DW2dVAcoBh5uSWK12pIU8b6hHGvVL 1DKK1K3bMLvzSPOa4dJo96Jh7XTpy4f+dZdvrGHuDZbYZ77AhSK0TR2+dYctJHu/f5xc eHTg== X-Gm-Message-State: AO0yUKWI/HCCS3unAkbYTGc8sbjrUh2AvnMJ5iLrUsPqwMTY8NrNIhrV IMAeZS2OW2Ft2TzvGv4eYbvPcw== X-Received: by 2002:a05:6a00:1916:b0:58d:aae3:bcc1 with SMTP id y22-20020a056a00191600b0058daae3bcc1mr590500pfi.5.1674867116995; Fri, 27 Jan 2023 16:51:56 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i2-20020a056a00004200b0059392f591b0sm202309pfk.53.2023.01.27.16.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 16:51:56 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Cc: Kees Cook <keescook@chromium.org>, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] Bluetooth: hci_conn: Refactor hci_bind_bis() since it always succeeds Date: Fri, 27 Jan 2023 16:51:54 -0800 Message-Id: <20230128005150.never.909-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2549; h=from:subject:message-id; bh=mVnvB6NOyfWKqwGU5dfT8S9lHvRpK/kONHhCQ2CZubo=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBj1HGqBJHOTl2sp2HPsmuw4TM++NQqA2fhgVBlGeK4 MQdzgL2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY9RxqgAKCRCJcvTf3G3AJjDqD/ 0V0RCFZ3es87Ut1Lhxbg2HbsAjs/19gb8HGiAWmEiBRCm82CiN1ITFJVmYFH0xvuismK6BY5FNj8lS CMX08uMHTIswyaN5ofAc9gyH8zLHzyyEnNe+hJrJlN4vqzi0QGNy5uAyt6QG/7kQvabiiQXS34cOsr VJI3asei8wsGFxCvYz/vBYL7zz6j1aQ1ZdnRrRt6yOk7XIfpp6M65oPkznc/2vtOsgb9BQ5eQsvvA5 hbDSzxnlzxviJ5nXIZSKQcn6F5raQ0Yy3rj6dLnGt2JkESmUwvuXBmU0alQK2uuW9f0MNYlDAboyvX VwuTTivoEkQbOM3AzdHp6JOQP7daw+nRfxiiqiffRME5JbQckkDi9wjaBZvBrcWRLDIoQPTgBOWGKD f1xNi2lOWu6AOrsv6ZGKTp72iZsieXDBwBc2TbeGZ4+9PhS4g8jQQ1QLHQCUKVBLk/GNpTcYWO8+Nw i0CrHq5WR2SmhGB/UYiZON2eOmeugzjRR8XWZFk+tgiGsjlwIFJn4MyIv4bT+GFcnm2w5J8NEfc85q fWVG3gz0ySWvP5ysxUpuv6GlMw8Tobx+52ascosL0U43MqZJ8/ZrSe/99wfCbdUcblc1BkWp3ggxRJ ezfgazR7DB1IvBC35Sm6nk2z2M7+PLYlE0jWeC8Amh3+ty78ipc69h9JwAYA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756225963014795890?= X-GMAIL-MSGID: =?utf-8?q?1756225963014795890?= |
Series |
Bluetooth: hci_conn: Refactor hci_bind_bis() since it always succeeds
|
|
Commit Message
Kees Cook
Jan. 28, 2023, 12:51 a.m. UTC
The compiler thinks "conn" might be NULL after a call to hci_bind_bis(),
which cannot happen. Avoid any confusion by just making it not return a
value since it cannot fail. Fixes the warnings seen with GCC 13:
In function 'arch_atomic_dec_and_test',
inlined from 'atomic_dec_and_test' at ../include/linux/atomic/atomic-instrumented.h:576:9,
inlined from 'hci_conn_drop' at ../include/net/bluetooth/hci_core.h:1391:6,
inlined from 'hci_connect_bis' at ../net/bluetooth/hci_conn.c:2124:3:
../arch/x86/include/asm/rmwcc.h:37:9: warning: array subscript 0 is outside array bounds of 'atomic_t[0]' [-Warray-bounds=]
37 | asm volatile (fullop CC_SET(cc) \
| ^~~
...
In function 'hci_connect_bis':
cc1: note: source object is likely at address zero
Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-bluetooth@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
net/bluetooth/hci_conn.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
Comments
On Fri, Jan 27, 2023 at 04:51:54PM -0800, Kees Cook wrote: > The compiler thinks "conn" might be NULL after a call to hci_bind_bis(), > which cannot happen. Avoid any confusion by just making it not return a > value since it cannot fail. Fixes the warnings seen with GCC 13: > > In function 'arch_atomic_dec_and_test', > inlined from 'atomic_dec_and_test' at ../include/linux/atomic/atomic-instrumented.h:576:9, > inlined from 'hci_conn_drop' at ../include/net/bluetooth/hci_core.h:1391:6, > inlined from 'hci_connect_bis' at ../net/bluetooth/hci_conn.c:2124:3: > ../arch/x86/include/asm/rmwcc.h:37:9: warning: array subscript 0 is outside array bounds of 'atomic_t[0]' [-Warray-bounds=] > 37 | asm volatile (fullop CC_SET(cc) \ > | ^~~ > ... > In function 'hci_connect_bis': > cc1: note: source object is likely at address zero > > Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections") ... > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > net/bluetooth/hci_conn.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) Is this really a 'fix' ? In any case, the change looks good to me. Reviewed-by: Simon Horman <simon.horman@corigine.com>
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Fri, 27 Jan 2023 16:51:54 -0800 you wrote: > The compiler thinks "conn" might be NULL after a call to hci_bind_bis(), > which cannot happen. Avoid any confusion by just making it not return a > value since it cannot fail. Fixes the warnings seen with GCC 13: > > In function 'arch_atomic_dec_and_test', > inlined from 'atomic_dec_and_test' at ../include/linux/atomic/atomic-instrumented.h:576:9, > inlined from 'hci_conn_drop' at ../include/net/bluetooth/hci_core.h:1391:6, > inlined from 'hci_connect_bis' at ../net/bluetooth/hci_conn.c:2124:3: > ../arch/x86/include/asm/rmwcc.h:37:9: warning: array subscript 0 is outside array bounds of 'atomic_t[0]' [-Warray-bounds=] > 37 | asm volatile (fullop CC_SET(cc) \ > | ^~~ > ... > In function 'hci_connect_bis': > cc1: note: source object is likely at address zero > > [...] Here is the summary with links: - Bluetooth: hci_conn: Refactor hci_bind_bis() since it always succeeds https://git.kernel.org/bluetooth/bluetooth-next/c/d57d873e6851 You are awesome, thank you!
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index acf563fbdfd9..61a34801e61e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1981,16 +1981,14 @@ static void hci_iso_qos_setup(struct hci_dev *hdev, struct hci_conn *conn, qos->latency = conn->le_conn_latency; } -static struct hci_conn *hci_bind_bis(struct hci_conn *conn, - struct bt_iso_qos *qos) +static void hci_bind_bis(struct hci_conn *conn, + struct bt_iso_qos *qos) { /* Update LINK PHYs according to QoS preference */ conn->le_tx_phy = qos->out.phy; conn->le_tx_phy = qos->out.phy; conn->iso_qos = *qos; conn->state = BT_BOUND; - - return conn; } static int create_big_sync(struct hci_dev *hdev, void *data) @@ -2119,11 +2117,7 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst, if (IS_ERR(conn)) return conn; - conn = hci_bind_bis(conn, qos); - if (!conn) { - hci_conn_drop(conn); - return ERR_PTR(-ENOMEM); - } + hci_bind_bis(conn, qos); /* Add Basic Announcement into Peridic Adv Data if BASE is set */ if (base_len && base) {