Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2116013rdb; Mon, 9 Oct 2023 13:08:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEyp2hr3G/zFosULKclyRyJ/iJ/UXKxtn4EE0bx1oPPLJriaLOSHozkdrCULVB79YQ9eEM X-Received: by 2002:a17:903:192:b0:1c8:9bc6:2a09 with SMTP id z18-20020a170903019200b001c89bc62a09mr5130101plg.15.1696882112425; Mon, 09 Oct 2023 13:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696882112; cv=none; d=google.com; s=arc-20160816; b=m1a/ucCZJBHht3ehaxZH/2E5FE77dXcg9tVcbJi9QVXcyKLmYNMWe+tPPkHMYjhgKg NlScCpblZVSA6oZFBgTCaxH/Ml2Clv/bJxdZaAMbZ48oixz3pWmW7WKxvYe7FhVkHlf4 MO1ldBHQ7i7bNsgwtksXczfoO72SQ0yMDrPK8RAHLDrFDf+TmREBUmnaQDmD8O+La4hq EYyUft/iTbXYoNV2Nbq5SA1sNm7P5VIuUbmXXmI1T7EGUOjnoanfy/GBT2WfVyaRp9Ja S8K2a/A/OcI9E2H3OBR24Oyz3sf7PZ+IaEDZnugmCz/5H2zIMV/LbhwqXQOIjg/zzzja kbRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=Qnk/hYJGt8vMGvwYuS7TovawYU4FITkdWpH78jnqJOs=; fh=Z8+E5HyUX7I2rUt3XmkVDWN1S8tMfsyhQOZJZCwURAs=; b=GTue5YX5CZa6Mj/plK+JcDpc4jUTJaY7Kzz1RdznERLsx4LEwBpFLGZQgHYpswlEcJ LfK3w2NA6aOZvkpew4SRFX5u+LpVH9GtJK594LNhaLFq7kb9umLxTzMTS9YUglp2THOO MNYNg1YnUv6t4pTOn56kMnp3EtLNKv+XZcNM+0oOTXcgSx6LHfaMGPUd2go38PicSzXb wpEVzfNrUKJAEgDjIrl76L8m3RwIVTJUAbfEh9H125USW5nWqpyzJ06b7noiIC4T0EfZ vz0bqJV+uJvAMR4uWssLy1fIPPalvb9kylYTxTqKiZlTYdYPU93HBDOe1VlmPlnfb+qV dReA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=mqCFhRXp; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=f0ypCYly; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ki11-20020a170903068b00b001b662f49f60si9961755plb.419.2023.10.09.13.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=mqCFhRXp; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=f0ypCYly; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1DD3C803335C; Mon, 9 Oct 2023 13:08:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378540AbjJIUI1 (ORCPT + 99 others); Mon, 9 Oct 2023 16:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378528AbjJIUI0 (ORCPT ); Mon, 9 Oct 2023 16:08:26 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE46FBA; Mon, 9 Oct 2023 13:08:23 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 24AEF5C032A; Mon, 9 Oct 2023 16:08:23 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Mon, 09 Oct 2023 16:08:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1696882103; x=1696968503; bh=Qn k/hYJGt8vMGvwYuS7TovawYU4FITkdWpH78jnqJOs=; b=mqCFhRXpOKbM3+gzw6 p5PhWXSGZc4ogwVsdkuo+A43m0smOPhhYMz78yJvgnl3rvP/0KP/Yyz47bWfbLI5 hACl6ENILilhp63gtNoE5sEtTvbwNsWX/LXMcHpkz0wzqkQE8Ndlz+z4YS7AQUAf GljZGp1E/6Pjf+6/oSfGUGj03jNY8coKUztcfYu6K6U7LoTipcfr2cXV0LybV0HE ehUr7BFFu5YfclBwoo7jtAeBLE7wuQUYAW5JBxqOd8miccBlDvavQBA9jw44/zt/ Ge4jceNUA6w2jbKSIJ1YxQ0vJUesse+nKNVZfS7xAecqP9LaZE21UO2MfTUxCKeS 2mjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1696882103; x=1696968503; bh=Qnk/hYJGt8vMG vwYuS7TovawYU4FITkdWpH78jnqJOs=; b=f0ypCYly03Y1wuHi2Z6wYewa6ofwr rXHCSBaMW1h7QfTvDtRJwi8rU0it8is84Gbt/RLmh+5rwaZC2VGVfi5QImFok+Ag mEIIlgBptd4PLeaTwBDVRgIEVsFrDPX7L0GvXn9/qZu+uEHyu99V5qODgUkk7gvX 75yD99Q0SXtM8SsEcJQK80aqK8WE+t0TR5LWxJiesFQx07hgjT26Qcgso1mdmUof MW7qKZq/6nH8plFrjV+oJqp0ma9r4r4s0Zu2Thn5TCQyecftNC2Di+ozRCGJBgYY DdWoVysC07AELOwJjOIO5+j0ZErv0f0ymPN+5W2vU8YmpSwGAXc5CpOEA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrheefgddugeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepgeetiefhjedvhfeffffhvddvvdffgfetvdetiefghefhheduffeljeeuuddv lefgnecuffhomhgrihhnpehprghsthgvsghinhdrtghomhenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 18E3BB60089; Mon, 9 Oct 2023 16:08:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-958-g1b1b911df8-fm-20230927.002-g1b1b911d MIME-Version: 1.0 Message-Id: <15f6b85f-b1ce-409a-a728-38a7223a7c6c@app.fastmail.com> In-Reply-To: <202310091246.ED5A2AFB21@keescook> References: <20231009134826.1063869-1-arnd@kernel.org> <2abaad09-b6e0-4dd5-9796-939f20804865@app.fastmail.com> <202310090902.10ED782652@keescook> <73f552a4-4ff5-441a-a624-ddc34365742f@app.fastmail.com> <202310091246.ED5A2AFB21@keescook> Date: Mon, 09 Oct 2023 22:08:01 +0200 From: "Arnd Bergmann" To: "Kees Cook" Cc: "Arnd Bergmann" , "Marcel Holtmann" , "Johan Hedberg" , "Luiz Augusto von Dentz" , "David S . Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Chun-Yi Lee" , "Luiz Augusto von Dentz" , stable@vger.kernel.org, "Iulia Tanasescu" , "Wenjia Zhang" , linux-bluetooth@vger.kernel.org, Netdev , linux-kernel@vger.kernel.org Subject: Re: [PATCH] Bluetooth: mark bacmp() and bacpy() as __always_inline Content-Type: text/plain X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:08:28 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023, at 21:48, Kees Cook wrote: > On Mon, Oct 09, 2023 at 08:23:08PM +0200, Arnd Bergmann wrote: >> On Mon, Oct 9, 2023, at 18:02, Kees Cook wrote: >> > On Mon, Oct 09, 2023 at 05:36:55PM +0200, Arnd Bergmann wrote: >> >> On Mon, Oct 9, 2023, at 15:48, Arnd Bergmann wrote: >> >> >> >> Sorry, I have to retract this, something went wrong on my >> >> testing and I now see the same problem in some configs regardless >> >> of whether the patch is applied or not. >> > >> > Perhaps turn them into macros instead? >> >> I just tried that and still see the problem even with the macro, >> so whatever gcc is doing must be a different issue. Maybe it >> has correctly found a codepath that triggers this? >> >> If you are able to help debug the issue better, >> see these defconfigs for examples: >> >> https://pastebin.com/raw/pC8Lnrn2 >> https://pastebin.com/raw/yb965unC > > This seems like a GCC bug. It is complaining about &hdev->bdaddr for > some reason. This silences it: > > - if (!bacmp(&hdev->bdaddr, &ev->bdaddr)) { > + a = hdev->bdaddr; > + if (!bacmp(&a, &ev->bdaddr)) { Right, I see this addresses all instances. I tried another thing and this also seems to address them for me: --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3273,7 +3273,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data, /* Reject incoming connection from device with same BD ADDR against * CVE-2020-26555 */ - if (!bacmp(&hdev->bdaddr, &ev->bdaddr)) { + if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n", &ev->bdaddr); hci_reject_conn(hdev, &ev->bdaddr); and also this one does the trick: --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -266,7 +266,7 @@ void bt_err_ratelimited(const char *fmt, ...); #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) #endif -#define bt_dev_name(hdev) ((hdev) ? (hdev)->name : "null") +#define bt_dev_name(hdev) ((hdev)->name) #define bt_dev_info(hdev, fmt, ...) \ BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) So what is actually going on is that the bt_dev_dbg() introduces the idea that hdev might be NULL because of the check. Arnd