Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2119381rdb; Mon, 9 Oct 2023 13:16:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8q4j23rnvk0k5VFxoGSWqFTcQRm5NOFGoCO7x+sPF7Er7pcGIBpOrqbLVxY6BxXQOtdn7 X-Received: by 2002:a17:903:120e:b0:1bb:c64f:9a5e with SMTP id l14-20020a170903120e00b001bbc64f9a5emr16460234plh.5.1696882562251; Mon, 09 Oct 2023 13:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696882562; cv=none; d=google.com; s=arc-20160816; b=yBoFjEGk8K6Gd6mg4rXaafeeJVVaI/JYsDjSqXetO2JlhjH/5eicJP19t5/+dcIKr3 Rn48FnZDyaEQ1Pa7iqq3rkdelARn3UpGNacKh1UcOEJLjTj7+dBmIeZlzfuVOy2F95uH +tHaAlkvQYf3uWQpUt2eeBrZMW9Q78H0XZZ7vTt3MrhGdq6H70GZ0am9grPgKcImzlDs KnSkpYhTd6oQGZmjezh1aAaXOiPdQgrnNIYX47wQGzSbpjodEszwtoWe/OrWfiXnn7vr obmSlKk8/9Hs4HoasaMfcpRtzzR+aBUhNW7fBv33hXYSmB69Pi6FJVJDNu5U2ARxn9ro TClQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KDFbaSwdbSiZRdRTlwqK2IxJqwEgX2EDTqDwpd1TSYQ=; fh=j39M5x8lM9OeDq+4uJmo++qoWNl0k2U7RpibHOsIYJo=; b=NNr0CEl4wfomjshYIwAMPogItBBnq0HLfGdHcgMCxhEc5rRzjGA85FHC6RUI02bb+W 3Oy7sBVxKzzgkFNRqlfHuysqKv3S1/h2CyWv8Ss77NngO4CVBxzx+ojGr1I3iRuucnK2 llhjzXnzll6FYWP2asD3pFdgKSs95oWzJ2AGvfEyaoTS43XJLO9/H4TpeTzHTxSXeRzZ iLPRUvA84u7cr3tLQWTKVUF3qAa53opl4Bz99XvqrY+n/L0ba3uRLt1wPusyqaYvz/VQ QB5Ej469dtuSNsElaVDLsbnhspHw8h/JiIrXzKOzbHJYJQFMznkp/9yPgqG1c6V9HuNM 1IRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=St5eDxRC; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l20-20020a170903005400b001c474ff2fdesi414601pla.378.2023.10.09.13.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:16:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=St5eDxRC; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4F2D681D6D83; Mon, 9 Oct 2023 13:15:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378545AbjJIUPj (ORCPT + 99 others); Mon, 9 Oct 2023 16:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378543AbjJIUPi (ORCPT ); Mon, 9 Oct 2023 16:15:38 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C131A6 for ; Mon, 9 Oct 2023 13:15:36 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c88b46710bso23775405ad.1 for ; Mon, 09 Oct 2023 13:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696882536; x=1697487336; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KDFbaSwdbSiZRdRTlwqK2IxJqwEgX2EDTqDwpd1TSYQ=; b=St5eDxRCX6O+tz2OOkDeq4l0ftdhO5hCp8dYhPEIIUPkv6Zi9R828WiwUgKujVEXfS 86SfoQUAo/tIXfHLWMc8pF5AAH4gmHMikDe/2qGSOHc1pVPmM9WiOH6br9C/kG5QpIOP ZR0/wHV/Ikp4iOs3IUbgW9jtNpyQQQGkJ8GBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696882536; x=1697487336; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KDFbaSwdbSiZRdRTlwqK2IxJqwEgX2EDTqDwpd1TSYQ=; b=Jhe7/zgZzeixX7jke5hF2DzcLjXMgh5vqhj7prFV+jQSbmzqM4J0gUd+wglsI+hpDj oA4mrJa0Nuzk4oZ0UeqFz+uHH6iaXWS0h+erwf8B8MeO1j3kWYCEcRRxI/bNoVaK8jcx n4kJ+Hmy6vPClXDpyyrsvK26ZfKLOWrEfFlT59pXqHi24GBE2JVBamDm8C5l5LLjJDEE PW9oL46Pm2z+tQUExlUx324IWFjyaItWN090p85/yrw8ShaHyTsauwFjMPL2hJeW+/K4 VXJLK2sMeRZktzA13fzvDZE6Mrj3aae8dG18oSX8AIZvKPA6rNR+f1z1SCID6nH6YuBx r0dw== X-Gm-Message-State: AOJu0Yz2WHQCSEsCe0uQFnHEd4qbMg4hN9T1Pdt44pFugv5lnUYqvv1T U0y5fz9/xl9+3raZLuzjYm060w== X-Received: by 2002:a17:902:e847:b0:1bd:d92d:6b2 with SMTP id t7-20020a170902e84700b001bdd92d06b2mr16471450plg.10.1696882535935; Mon, 09 Oct 2023 13:15:35 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id b19-20020a170902ed1300b001c737950e4dsm10038137pld.2.2023.10.09.13.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:15:34 -0700 (PDT) Date: Mon, 9 Oct 2023 13:15:32 -0700 From: Kees Cook To: Arnd Bergmann 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 Message-ID: <202310091310.F560494@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> <15f6b85f-b1ce-409a-a728-38a7223a7c6c@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15f6b85f-b1ce-409a-a728-38a7223a7c6c@app.fastmail.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:15:50 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 10:08:01PM +0200, Arnd Bergmann wrote: > 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. Oh thank you for finding that. Yeah, it looked to me like it thought hdev was NULL, but I couldn't find where. :) I think the best work-around here is your "hdev && " addition. -- Kees Cook