Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1907030rdb; Mon, 9 Oct 2023 06:48:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElg0ss1A0d5c1HMuoIq2gZhywLuBzK3FAlVebAXjEFdXOaXxLA1pTgW6zfA9b9sgKyoVHr X-Received: by 2002:a05:6a20:dd89:b0:16b:9541:85e6 with SMTP id kw9-20020a056a20dd8900b0016b954185e6mr8650484pzb.60.1696859321928; Mon, 09 Oct 2023 06:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696859321; cv=none; d=google.com; s=arc-20160816; b=SKwK/LV9JZL7eVOibPwo1kf8GV8PdvPaTCwaVa1c0jOJfi7uUJJe4A7finWeX0Q+7P K86C5gzMDtQ2EsWfpYXwxJOKleA4cJNwkRUHcZGgrRuRpm/Kz/ryTtrYVv0eCL9JGyrq OPNOwXPeOOKCBtYGLt2pIcUo3cVCq6Kpc/kBkkG0iO9hRZNMFBdOF61nvnlDJ2vR/4Ha +YgCce+qsop6YV7WXMq7PpGTFVezkn5ssqeZt2bN8vXJoOFQqQAvoJ6cJe2e3cNm/uJ8 jGUmCc0tvCtq4GKi7cokUtqz0vMN1BN8d8j8Z9FeaMfqSzjHkm8sKwlZ2sKEvAqjkCWU FABg== 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=yQGQ420tyGCVltFURnLiQMjBhJylh+AuChTxY7LRMdw=; fh=X1kN+EyMT8W5Tt6S7pXXMDVwvlJ7xG/6xb8j8vVWeeE=; b=HBexTOtxOj4FUEfpKKQ8cVwAH3ALSU9zPKQ6/Lq1KcdoUYnBp0HH05/VgjGHsMj/++ zxcCD5cS+5IT35SsYyQCgV13FLGb1u100bQA7b2LBWdnxitdrX+tW6m3JdD4trpKM8qo ThlCCM20bGiZH5APKH5LUjE7dSL9RX2k0GeCp3L10CsMQ+sZqh9jBJlBrHps4ECEdLty EUvTjhR8PfUphhKsiUSIXyHRl9maYzRMed4jnGPRnbdDisJwuGEJD61U8ctM/ChO/sBH EQLtI2J/JzICIGyGDXlmTuaxuYwgmW+UZIvrNjBwC4Ohh9nV0xlTfb0/kiJdOAtCAvfD tXWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=tUT2ZZjj; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k3-20020a6568c3000000b00577461b010fsi7680162pgt.685.2023.10.09.06.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=tUT2ZZjj; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D426380AD111; Mon, 9 Oct 2023 06:48:37 -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 S1377350AbjJINsg (ORCPT + 99 others); Mon, 9 Oct 2023 09:48:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376760AbjJINsg (ORCPT ); Mon, 9 Oct 2023 09:48:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB4794; Mon, 9 Oct 2023 06:48:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8CECC433C8; Mon, 9 Oct 2023 13:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696859314; bh=+HSuQE4uwcv/S7v9Nu+yPUKMpHFCIut7bedSD0CoE+8=; h=From:To:Cc:Subject:Date:From; b=tUT2ZZjjoyKrHy9spdRqLkKumZ59dlMndP1ekBAykHym+I9g1k39CRcqUXSeoVTqo Z3xuUbY7mXsnOwgIi7yBQdMycUPRHFK35wzu94NkC9wXqe/ov4uMJ3UABP+2vXkI9y UgteuuzSZhHsyo0DlcXKeFIzGGvj/2vjsvHXPD0PwUMqWZvXMU8qPTz9T5yoCbeEDu R1dUaGDrRW5kAPCebPaeAyyc3t1SX9N6IF0/VFFSi5q/r7GjWPMHOv9zDuGbTtPEas H4u/mTKT2CY5C6k5UY61G0i73TUhMGHtV5AmPgywk6CReOKL866HVwmyoAJWy+ZG2L S4CgJoKX+MF3A== From: Arnd Bergmann To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Lee, Chun-Yi" Cc: Arnd Bergmann , Kees Cook , Lee@vger.kernel.org, Luiz Augusto von Dentz , stable@vger.kernel.org, Iulia Tanasescu , Wenjia Zhang , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: mark bacmp() and bacpy() as __always_inline Date: Mon, 9 Oct 2023 15:48:19 +0200 Message-Id: <20231009134826.1063869-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 06:48:38 -0700 (PDT) X-Spam-Level: ** From: Arnd Bergmann These functions are simple wrappers around memcmp() and memcpy(), which contain compile-time checks for buffer overflow. Something in gcc-13 and likely other versions makes this trigger a warning when the functions are not inlined and the compiler misunderstands the buffer length: In file included from net/bluetooth/hci_event.c:32: In function 'bacmp', inlined from 'hci_conn_request_evt' at net/bluetooth/hci_event.c:3276:7: include/net/bluetooth/bluetooth.h:364:16: error: 'memcmp' specified bound 6 exceeds source size 0 [-Werror=stringop-overread] 364 | return memcmp(ba1, ba2, sizeof(bdaddr_t)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use the __always_inline annotation to ensure that the helpers are correctly checked. This has no effect on the actual correctness of the code, but avoids the warning. Since the patch that introduced the warning is marked for stable backports, this one should also go that way to avoid introducing build regressions. Fixes: d70e44fef8621 ("Bluetooth: Reject connection with the device which has same BD_ADDR") Cc: Kees Cook Cc: Lee, Chun-Yi Cc: Luiz Augusto von Dentz Cc: Marcel Holtmann Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann --- include/net/bluetooth/bluetooth.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 7ffa8c192c3f2..27ee1bf51c235 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -359,11 +359,11 @@ static inline bool bdaddr_type_is_le(u8 type) #define BDADDR_NONE (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) /* Copy, swap, convert BD Address */ -static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) +static __always_inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) { return memcmp(ba1, ba2, sizeof(bdaddr_t)); } -static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src) +static __always_inline void bacpy(bdaddr_t *dst, const bdaddr_t *src) { memcpy(dst, src, sizeof(bdaddr_t)); } -- 2.39.2