From patchwork Sun Oct 1 08:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joeyli X-Patchwork-Id: 13405331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 727B3E748ED for ; Sun, 1 Oct 2023 08:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234641AbjJAI7u (ORCPT ); Sun, 1 Oct 2023 04:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbjJAI7t (ORCPT ); Sun, 1 Oct 2023 04:59:49 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2041.outbound.protection.outlook.com [40.107.6.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E848BD; Sun, 1 Oct 2023 01:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwMMvlsQQIP5kRkm86ZgmAXUy6U2PnDBUzbhOzOPbVqYNkhYdhuPnPOSOgGuWskOfJ9KXrV5IM9uXdxqpviWYx6OgXBs++S9TY6Uo7EAsmEKUOQ0ACyqiNbRyNF/i5LA+whbiq/RAYK7SbWz2HcW+OnhNkP2S/ctccubZ6F6/3amzeahvMNCiyWGQs6XgD500gsMHopUR8TTqJIpvo4LJCSWL4akin3OBHMnJ/o7CiLAncG+Op/m31iSab0bnJF4xojtnp7AuW7OcDzkSspaEZ9zlEI7FFZRS1ginkvHQNy3+GPpCzU84uEIH3Fl+/E6wic6Ev/vG7Ef+ZQ2f0g5ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QngHf0069SUpa+0aQXtb/GwNP/xfzgPDh2waFl1kvHs=; b=clIwgu0BO4SshjGZAwvz9wRB1OlPiNdGToOuJ3k06JZx4lFgwaHroftfzjibRDVf6HIbnDqx6U5guinx0GQRz7wY+v7svbvfuuoipJC8htICjG3jvuYi7AaETgbSsLYcS0tuxquPvq3Gp29IfytvEyNJZo2DjjPbXeRBQs9gGDxwGPVB+mwWYbpHwMh6DTuw9LUOyXg01Xs0VML3ErUBz/Zg3NsPRhnnUF7p8adHNmcgpULIiGU0bLixObXPidd2M4ErxzyM0r7QF2eHd5Jdt/pWkUX7mU9innPI8U15Fh/BR4ZR7xNycjtYk3f4Bvvg6HsIEX+mEcscuaU0Vd116A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QngHf0069SUpa+0aQXtb/GwNP/xfzgPDh2waFl1kvHs=; b=Bd2DBWx+gXh4bZPeOzRyOe3QHnDv8K98YHW9TwZz1CDx4nKy0kgo+GEb2/6HXU7ZQZS7O2+Mir4ZOPRHLByH4FHzEiusA4Pq0sJtWo/lT6wsGBqx8r1lIglP8C/vVrYW14cCksOgHdUudAcgQs6iWjA61pC7TR9ga3bzN2Esqv6orfmWNx/VzjX3p530Po8nBqDmSVmDZWAd1kEAljTqa+traCu4VyqVK6WEhvlJZYeu3RwzNEFIXbPjdWMKcZOy30mfJcBw4RlSmY6BcTyThu8NQov84qxmaAgdTOQASWWHyOYipPZ9uggh8D78ObN/PtZq6WQ98xxS8syv3LeHJQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) by VI1PR04MB10050.eurprd04.prod.outlook.com (2603:10a6:800:1db::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Sun, 1 Oct 2023 08:59:43 +0000 Received: from DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::8647:4673:b19:acc2]) by DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::8647:4673:b19:acc2%4]) with mapi id 15.20.6813.027; Sun, 1 Oct 2023 08:59:43 +0000 Date: Sun, 1 Oct 2023 16:59:31 +0800 From: "Lee, Chun-Yi" To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_event: Ignore NULL link key Message-ID: <20231001085931.GA17048@linux-691t> References: <20231001084934.GA16906@linux-691t> Content-Disposition: inline In-Reply-To: <20231001084934.GA16906@linux-691t> User-Agent: Mutt/1.11.4 (2019-03-13) X-ClientProxiedBy: TYAPR01CA0212.jpnprd01.prod.outlook.com (2603:1096:404:29::32) To DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7164:EE_|VI1PR04MB10050:EE_ X-MS-Office365-Filtering-Correlation-Id: 79126a2e-1a36-4622-9ad4-08dbc25cc127 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gCAzoYkumOXx6z2XNojFq1VlJr9QXa12qlL5DB8K4uupqFMDXEbVlkYFw+GkiWv02RVrd3zvDf6tMeCP/EpQ3nyIgZCeEFw7EJWn5NQsZY27/cSIC46hvdP/mxbsaJZWOmXBWqqa6APIZkNtsrW/vHpn5qu03ECtywNt9HjN+7MAa86UVeqo01mqK13g+NJmDOfiA1DkWxDmOieeAI3J10LfhNBfQteZVdLrfw2HlUqyQ7tR+qaHWNVU0vXtAK0GJxrrYHrocASUfgK+1OmYXtuiWALcbpSlc2NzTR/QqrVg55dQ5QSQJYab9QH4cSgK+UAlb4XZ2imK44O/9XuVbwkQqvh3MQ2QRA/ZvJGCLxF7OaZ8mMrjtjYsDJcLTX+fttE8sQQIsN8jc+BDUBk7eSEX6MtQaAttqbi+dyvGjYsZ3NI+ZinOKvsOfzFCWEksyYQtp3/LQIvyX4qo9A/IQMnvETDNu6GLXV3BT/aOEkXcb5qD+BGSPU2kzwFnnIsTDwaOVDV4hFePBExTY18CHZfdjD9fiKb4mDmdJglzij8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB7164.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(366004)(396003)(376002)(136003)(346002)(39850400004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(41300700001)(6506007)(26005)(5660300002)(8936002)(2906002)(8676002)(4326008)(316002)(1076003)(86362001)(83380400001)(6512007)(110136005)(6486002)(66946007)(66556008)(9686003)(33656002)(478600001)(966005)(33716001)(6666004)(38100700002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jmqxeUt+WXuqYOzNe1Nr1ijS9QRvkFCMTEZ+q+kGf3kmyi1Loxni/iTYKftkH6lE5VXzvl7ghnf9OTsYnGmlruFgNOwlhEK5z4nVv/01Uhh0D17T2wvrF1ihvhirtsPiOx7eFUttPu9mb01USBVuMJ0+ZP9RJu28Rh74eSyNKtz0yJXFrolresP5cam8VXC9YhT86fDQNZdOLdoSwpSCAwAssER11fdd4ReFCAg4WU+5llATK9LNcZNh2Bzxy23af1G0UPzyioStyIutInLrGlkRHI1BvDEoIvOeaZIsuVYHCR19DJbSWEF1bby4OhFV5jk6w1tRJt9eyLoYY9eO8Qzn6LLb1CAdmKB+1DR2Q581L4UUM7gQiiA7PdzlR+WzBA86AYsDObrUi/IHIhjs+FDYZTQ1d+nzNx3Hal1ApwQCNsR4jLy85wAf9oWAg5iSSKwYcG5tkqdEjCR+TkOxDSMLMOENpO8WWHiVtZd7T/aWJ6yTeJ1SzckMZFpCEZWFUMbOWSJtSw0zIFKOZHnZzOzBCjXGZmvnlzv4sZfU4RTpe2V6b2IjZc/xdPBEd5/PeWE/3DukxxwpyP+QozEnUCXRql/Qudy0L3Au1luOr/QrFVUegFABxM29M6fDZEezlWFrqstd7eba8NQReaS4FSdKDXzX+AunORHNrzTc3RRPtbJLNcOJMxfw69knj+wyWVJKL8GIJ4jZuFpQdfJQVWPGj5FBEzpgU6LS7aAW4Iagx/uwD21t4Kbmr5R76MEV2P6or1nVbqO5EW8BwYd/Yp9JhVmqFA+2nX537h5YhU+5Nmk/zJZ3nBc3DBVAAvQP6lQ3DRJf79hFv21u1XX7WQ+cLLLz1gmEcDTZmEPK6SJ19M2pTPo8KKhFRSvq1mJnkaGsfXCo28WpCckBfatBv6vtYgHgqQ0kcqd5MvOvwhZmFJB2lbjiv5Y137/+tzeaYdZ/ojI/Z908mLCaOLpkRMYxG4IiAIg5L0OkXDpAp+8mvmOKTz+60NkvSjgNMwSJun1DzI4UL2V8DlAy8I0RxHWwA8tB56DtTTFfzoIFv3lfJfo4e7+W4TDGVxDPJBTiNmy+Bk+aF+Y7u7aCvd1wbZuwaMM52eEZYBoxyNlAY77DEUeSn8zmqLMvft46pBwjhrOjwmXQwPMZBz2lXiK31WRqP+fbbYoUJaRwmbrzfXtD+HU9938wEtVgkqttWaQIOKKTY66rdm38pjrjwOPUGXi1Jy2nqjT+QeCr9ZYSm+SWZJ/0s33E7eJITrswjbetQRxIfv24g8LjbazYUX9CfWZcTXfUh3P5JTpgaCW/I5u1Yo+jHw7kzYs1sT/DGU03EYGjb8d7vjnWIt5VW6gzGAXzl7t/x/C/6aDit3trNv2KpAzXTn46fs/Q0UP0jT4tT+xK4eKey3zlNVS3dxrFFUCkVd5xGPA1isLEaMS2pvZbwcRTyiskYQmsRqt93vVJdCyxOGeaah39B0CrZUjek+02ajr4CsOpy/sooinZ5RvgF44rJMtDa8DBsjQxi4KMhYTnmOwbpIjOWNCf/rKKHWVGJXk2GodDNwb3OkZJeWkDgRzT8YIJgq4XGi2+Yq6z X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79126a2e-1a36-4622-9ad4-08dbc25cc127 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB7164.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2023 08:59:43.7465 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2VCQOHLnbVixDqEAWJkTnaOFE3aXJBZNFQ0no2M/61j5xYkfEK1wjwpvoAotUBOr X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10050 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change is used to relieve CVE-2020-26555. The description of the CVE: Bluetooth legacy BR/EDR PIN code pairing in Bluetooth Core Specification 1.0B through 5.2 may permit an unauthenticated nearby device to spoof the BD_ADDR of the peer device to complete pairing without knowledge of the PIN. [1] The detail of this attack is in IEEE paper: BlueMirror: Reflections on Bluetooth Pairing and Provisioning Protocols [2] It's a reflection attack. The paper mentioned that attacker can induce the attacked target to generate null link key (zero key) without PIN code. In BR/EDR, the key generation is actually handled in the controller which is below HCI. Thus, we can ignore null link key in the handler of "Link Key Notification event" to relieve the attack. A similar implementation also shows in btstack project. [3] v3: Drop the connection when null link key be detected. v2: - Used Link: tag instead of Closes: - Used bt_dev_dbg instead of BT_DBG - Added Fixes: tag Fixes: 55ed8ca10f35 ("Bluetooth: Implement link key handling for the management interface") Link: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26555 [1] Link: https://ieeexplore.ieee.org/abstract/document/9474325/authors#authors [2] Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L3722 [3] Signed-off-by: Lee, Chun-Yi --- net/bluetooth/hci_event.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 35f251041eeb..2830abbdd329 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4741,6 +4741,14 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data, if (!conn) goto unlock; + /* Ignore NULL link key against CVE-2020-26555 */ + if (!memcmp(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { + bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR", &ev->bdaddr); + hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); + hci_conn_drop(conn); + goto unlock; + } + hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_drop(conn); From patchwork Sun Oct 1 08:59:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joeyli X-Patchwork-Id: 13405332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2902AE748E9 for ; Sun, 1 Oct 2023 09:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234641AbjJAJAQ (ORCPT ); Sun, 1 Oct 2023 05:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234625AbjJAJAP (ORCPT ); Sun, 1 Oct 2023 05:00:15 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2067.outbound.protection.outlook.com [40.107.6.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD207BD; Sun, 1 Oct 2023 02:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVXwoLgAnd93Qor6vrcJkkdKLDoiV7oKsOE7+MxG3KsdgZaPnv1mdI6zZRfo3TXaaR/6sUXrs7fFhX0syIGNKuZBgtBt4fvuoDoNE4sYzZnDy7tu20hhHX3YJFsHmq377++3NYRKEYEEOVlO7G2NYTHC4l5XsXwNFz/Po/i9CCXd3XllG/0ahfTuJJ0aODgALzv/vMv4rmUQ12gYomAycA+ASZEwFi6ruEh7pZs4aKNB9MACJzQb1o44Hhv8f2CcqWB5LEq5CD4kW05KEoXX7JbicHSDMQVNfkZiRa+4mdujr6hcVFBnZzNic2vaztIybssphDG2ugEEFQpklVq/bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TLwD7it/TSK+76lV5tq2KGOJx5RfM+Z883h1j8vuQ5c=; b=eQA85Cubn8x5BfzT5CW9llzCCP1Nh8nHzk/xHc3p1kJejv3hQB37/UkZsIFWGwPSDbWIQqY+qzsG03l4JMLXBtATMe1rF8/q97OabKJOG5l9TMN0a2iBvTqvWvfPGalgOqVaDV5KFGReGlluiZD0oA2Wgtc5fe8tCXomlauKj6B+LBPLEj/v3cZPXlR0A9hxn05tV95QgLlKag9d5XVBdUNpz2hjhltqEvQg0ALMfko1CK+QnEMDAudDxTezZa7T17yJdgTLnaRYcOavshqLNd15q4DceStl5VR4b9V6YrbPeYK+8LuFVnIpQjRaUHkNKANU5ZuD0AA0/7stHyhPug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TLwD7it/TSK+76lV5tq2KGOJx5RfM+Z883h1j8vuQ5c=; b=RwCDIhXcKNJmH6ziL8aELpdMYOir6yfriG/OZfOM4Pi6Edyk/ViYWc9mKtT3+pWS04s+V0K81ld+ju0WQdSO9eiZAWJEuVz3HZwOU4r6u7rs7S0SlRu+9ySwlI9oH8YEjLjIW2nUZUTb6Y1/B2XhDPUzHtM4GyvzO0i3YM9JBljotGYQch+c5qQVmkWeGt5yduIgJfuD2EcJbAc89enalhJR5fURdeDEYWd+4eL4/l+UxgsKIH+kE3pxJ9D1OeuaxdERT4Kdd3fomGR8phrHTO8yqnh3WFfF+UqGGQ32bbQyUU+5tNNumtDbtMAdq7SpgAw7xHUwKSAjh39UUdQDpQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) by VI1PR04MB10050.eurprd04.prod.outlook.com (2603:10a6:800:1db::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Sun, 1 Oct 2023 09:00:10 +0000 Received: from DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::8647:4673:b19:acc2]) by DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::8647:4673:b19:acc2%4]) with mapi id 15.20.6813.027; Sun, 1 Oct 2023 09:00:10 +0000 Date: Sun, 1 Oct 2023 16:59:58 +0800 From: "Lee, Chun-Yi" To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: Reject connection with the device which has same BD_ADDR Message-ID: <20231001085958.GA17052@linux-691t> References: <20231001084934.GA16906@linux-691t> Content-Disposition: inline In-Reply-To: <20231001084934.GA16906@linux-691t> User-Agent: Mutt/1.11.4 (2019-03-13) X-ClientProxiedBy: TYCP286CA0221.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c5::7) To DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7164:EE_|VI1PR04MB10050:EE_ X-MS-Office365-Filtering-Correlation-Id: abb63cf1-5bf5-48c6-70b8-08dbc25cd130 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OaxsbfIJzMBxgvowZUaTPXwF0d18OG7hZ4epSx+0NBjzm2Gt/UwnV+7Cx7Z58EK4HWq9nxPrYsJ8xxsYHmq/aeYzOLRcf22UMi8HNBK2bFQm6mzmYwqdkDSJZqbHDTDtRv1Yzi6DrRcrOxSsAl+bB60RHbSKIzR0dP9NNL7Ot1UexhUmLAWjQW+yD4DIcq2vAxER4EUCpeP8e2puG2X1K8lwsifVvc925uztPtu/1CegwRGFtF4bU+wCyXo9hg9uiKfc3uCs3L6JL/BXTw0VHgmgj+QtvQ/E4kRNJZn5O/2zk8DUK5Yd9Euyio8d9TE31RB6FWvtuF8+1VXHVUviKYD73MdykOIuGzy3pxLtZIlB0y3sHK4eEB9ZdV0g9amhHbh2HIqFIz6KvWHMJ/zZ+RMsgX0uZOv+y7qtXPJhN1js/V9dkY0Wv10cDhlEnDuSe5Wkfn2cN1ky5OeMdBeIZF9nIl/Q3tqAxfxriiihLsvz57csgv4Ks7aJjQ+NUaQg05rgW9kJ6OpAiT9qYKyDO21XROPLn+DvTmSKduakFhQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB7164.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(366004)(396003)(376002)(136003)(346002)(39850400004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(41300700001)(6506007)(26005)(5660300002)(8936002)(2906002)(8676002)(4326008)(316002)(1076003)(86362001)(83380400001)(6512007)(110136005)(6486002)(66946007)(66556008)(9686003)(33656002)(478600001)(966005)(33716001)(6666004)(38100700002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: duQWpZi4uVhOGnWWAkmvLG53lutLdKS/a8vYzPNCxLNNa6tTWpYzMrWTj2IphxqKp25eRPy/ffOoeuQtc4FoIXnxh/cdxtwLKLbR0NkijsF5UA4y6Lh8emg88DB+kLVqAMJubCQtEbi20uXUaCwfstRz77z8hrvRbCbmIzwevFUXheL4kUt152FSjHY/S16ROH9d8GqIJ9VvvklUQRWhJ5V39kSwZS7qXRkoKSIiGJruYqgBmjxXCzg9YX1xKa2YaNK9sO81d0z7hdTxzVioB2K35tArELQWsWf4FcJtZVoVBaDAlZ9KQR1ZkE1/pOo8Dax40cdxFCdTpiaMjGYAT/+NlSWkn8czZTOi3dmUpbg1BVw5swtTs1EeuEx3CemV6Us0R6nQeBU/i0esKUrFD7orPiM+2TISN3hklAXENnaHjunumb0s2KMAJTBREnj0LqPgcCMmOk3gHNhzA2k+A8C1OqIkYgyPgefIF63r5whPvXar0r7wLXwwl0sJ8PnZ+/J5gutxx/I883u5ts1ryYLwus9XWRHzBBT407DRzl76u6u76BdrHFZH8JHzjnoIUjetD776/AtbHIFjQnrkDHX9BFct/LCvWsJWk/YAc2eJALTyZf6QnX0TKYU/8BDB9nD6aLzgoLLxeJats+1ryvjrvRJcHySKv05WUS1qMIOo8WkfM5d/jrCD6Tr52wtkssix5E8r1IjstE2TwQQRkunBxuVMSbPKMh/hfWL6tinJTRpzRF8qcLUOai1GX+nMDlkPNTQtsJIVw5wDJYlZMqujb6W42HW55oqWu3wkzwqm1K3ckmZVLXpugLHW5A9hruDIeQWPF80RZ22W41Xu/Y4YulElwwV8fVDo/M/o13U0T7c1o+IR8sLC5yy6lptez8XfKPXDuL9vsM6fpcTusgVd/V0Iv18vn0zF2QKP4bENlcTdroCfPIyHsmK5/C2oz+PeJPv1hRQDyxqbq+G0tTOBIun9EelVB7lwDPcVek3Ik0fGqPNxFye6MFATiamWoIhiAlfkD0Bswq0oVQx+7+Pu8sIZPBGaWu5cSpxknKJJo5p+aEW0KOy3HDBUmDDRj+hkiBufCo8StaZuf8+UkEO2mnHYZUWFurW0vsjXLCiS6roIncwlq3MuCJ+MikGSVXfcWekndhCWujOauYX5cyZhoRWM8isUl07rzfJUyezcKcmHQIzx4LltedhrsGk52puVEDyTQAYyRaOCkRdYCJG8Vwn4nkjavcbL8rUlARhhVvZMaSAmZN/kh4/YJNkskBBV8BabLqxHuli26MMzA153rgf7KP+TZaBFlCHWMvTDNhIms/7H4/0TkMgZRVyOoMOmOnZM5pTuT64MQ3sjE07MITbbutgGcnewNjaKSkV0ljBUGtgIMTfNusuVthEBB+lXTwjc3MJ2Q3tjl08plu2KkhvKsPy90wDNMJdGsofRc8oJuktoGECgfE+MEv5nEFEi0koKqNqqk4tHb1iJc257/XNsGCbjOG/CqftSr/H/oxFDh7DVp1R76I3zes1AvETTAgmvN/qW5MlkxHTn1RJpOR1nsae/+dLWp7LS+w1qj5gWEcJHmBntKMLx+e3M X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: abb63cf1-5bf5-48c6-70b8-08dbc25cd130 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB7164.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2023 09:00:10.6873 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fBRiIaWf5AUVaI6fShZM5JBvL88H0OKbztsH5l+4dBocpWjCVexPVatz9gNjXxyK X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10050 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change is used to relieve CVE-2020-26555. The description of the CVE: Bluetooth legacy BR/EDR PIN code pairing in Bluetooth Core Specification 1.0B through 5.2 may permit an unauthenticated nearby device to spoof the BD_ADDR of the peer device to complete pairing without knowledge of the PIN. [1] The detail of this attack is in IEEE paper: BlueMirror: Reflections on Bluetooth Pairing and Provisioning Protocols [2] It's a reflection attack. The paper mentioned that attacker can induce the attacked target to generate null link key (zero key) without PIN code. In BR/EDR, the key generation is actually handled in the controller which is below HCI. A condition of this attack is that attacker should change the BR_ADDR of his hacking device (Host B) to equal to the BR_ADDR with the target device being attacked (Host A). Thus, we reject the connection with device which has same BD_ADDR both on HCI_Create_Connection and HCI_Connection_Request to prevent the attack. A similar implementation also shows in btstack project. [3][4] Link: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26555 [1] Link: https://ieeexplore.ieee.org/abstract/document/9474325/authors#authors [2] Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L3523 [3] Link: https://github.com/bluekitchen/btstack/blob/master/src/hci.c#L7297 [4] Signed-off-by: Lee, Chun-Yi --- net/bluetooth/hci_conn.c | 7 +++++++ net/bluetooth/hci_event.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 9d5057cef30a..21c831f1fec6 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1627,6 +1627,13 @@ struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, return ERR_PTR(-EOPNOTSUPP); } + /* Reject outgoing connection to device with same BD ADDR against CVE-2020-26555 */ + if (!bacmp(&hdev->bdaddr, dst)) + { + bt_dev_dbg(hdev, "Reject connection to the device with same BD_ADDR %pMR\n", dst); + return ERR_PTR(-ECONNREFUSED); + } + acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); if (!acl) { acl = hci_conn_add(hdev, ACL_LINK, dst, HCI_ROLE_MASTER); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2830abbdd329..df97dd64be6a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3267,6 +3267,14 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data, bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); + /* Reject incoming connection from device with same BD ADDR against CVE-2020-26555 */ + if (!bacmp(&hdev->bdaddr, &ev->bdaddr)) + { + bt_dev_dbg(hdev, "Reject connection from the device with same BD_ADDR %pMR\n", &ev->bdaddr); + hci_reject_conn(hdev, &ev->bdaddr); + return; + } + mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, &flags);