Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp728696rdb; Sun, 1 Oct 2023 03:02:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOa3X6juEIZuCbRkVRdH1oYevlMWvW23zR3A3RhR/TNCtwffFytNsJLGCdn0w21et+NlAo X-Received: by 2002:a17:90a:55c7:b0:274:4f21:deae with SMTP id o7-20020a17090a55c700b002744f21deaemr6029267pjm.35.1696154543549; Sun, 01 Oct 2023 03:02:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696154543; cv=pass; d=google.com; s=arc-20160816; b=Yk0D42b1CPTnlWlkEFnhQnUT06JfygRewFoBkxuHIHv9m15uTZO765v6BKwWMlPrAV OvT0tgam9DabbBi+tai2MsqYkM44XMj8ychEDxEuUsZVuCmCFWJ9nDelCnCBA+0Vt1yY 7JQBdDJmBeecNBJdy3lBizEy7akcDzlZj1BC7HKR+buIaSiAGJIoxuPkWlvO4UW4fNU2 /1cKtFGLsXeSFqaiCwnrxm8gVacmBHPBYxuXzvY7sI1KGWabSlcDHX0VtslxGyhOCno5 qE4HTUDJPefeYb/pwWpf/Ys+mRPiL7AoPFAU9XZA5Q7Ji/QnH8q3/y3X2jg2mJLNE2Xi ch5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:in-reply-to :content-disposition:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QngHf0069SUpa+0aQXtb/GwNP/xfzgPDh2waFl1kvHs=; fh=YoKn3rNui1Uy12poG2FqwVn8fhiNCgV4MVj74J55Nj8=; b=EDY0mMhIbckpTdlgrDbP58yMVtvJr2Q0Vp5jBjnTMgzLhvc/S/vrxqA6UWlLqUEyii Kcn8nbr3/4rFvGwYEOQDsd4h43mwzHkgfxSgriW9F+2wy36w/8FvNM9lYeQo5ExzUraE BKF0T+ikMO+rQ9bDWdxp8fMkwdTFNX87kVRR8Le7roIUvKgbFgVka8uBf9kEUDUARhfd 3ZFof6jel7Rnr0oINX8i3g315e9/B1d6f2DK8rIlR4mQkQhcgXXCMjEWVA1ktZFcLs3e KOldWwxf8VN+yN4Jq8QGdzDss+bqQvfRGkeIg3UA4TVqsB2R/IJrZyHGL/FO1qVolEBc uk0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=Bd2DBWx+; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id kk18-20020a17090b4a1200b002748c1bbd79si6046416pjb.6.2023.10.01.03.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 03:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=Bd2DBWx+; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0FD70801D762; Sun, 1 Oct 2023 02:00:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234624AbjJAI7t (ORCPT + 99 others); Sun, 1 Oct 2023 04:59:49 -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-Type: text/plain; charset=us-ascii 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: =?us-ascii?Q?jmqxeUt+WXuqYOzNe1Nr1ijS9QRvkFCMTEZ+q+kGf3kmyi1Loxni/iTYKftk?= =?us-ascii?Q?H6lE5VXzvl7ghnf9OTsYnGmlruFgNOwlhEK5z4nVv/01Uhh0D17T2wvrF1ih?= =?us-ascii?Q?vhirtsPiOx7eFUttPu9mb01USBVuMJ0+ZP9RJu28Rh74eSyNKtz0yJXFrolr?= =?us-ascii?Q?esP5cam8VXC9YhT86fDQNZdOLdoSwpSCAwAssER11fdd4ReFCAg4WU+5llAT?= =?us-ascii?Q?K9LNcZNh2Bzxy23af1G0UPzyioStyIutInLrGlkRHI1BvDEoIvOeaZIsuVYH?= =?us-ascii?Q?CR19DJbSWEF1bby4OhFV5jk6w1tRJt9eyLoYY9eO8Qzn6LLb1CAdmKB+1DR2?= =?us-ascii?Q?Q581L4UUM7gQiiA7PdzlR+WzBA86A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SW?= =?us-ascii?Q?ZJ/0s33E7eJITrswjbetQRxIfv24g8LjbazYUX9CfWZcTXfUh3P5JTpgaCW/?= =?us-ascii?Q?I5u1Yo+jHw7kzYs1sT/DGU03EYGjb8d7vjnWIt5VW6gzGAXzl7t/x/C/6aDi?= =?us-ascii?Q?t3trNv2KpAzXTn46fs/Q0UP0jT4tT+xK4eKey3zlNVS3dxrFFUCkVd5xGPA1?= =?us-ascii?Q?isLEaMS2pvZbwcRTyiskYQmsRqt93vVJdCyxOGeaah39B0CrZUjek+02ajr4?= =?us-ascii?Q?CsOpy/sooinZ5RvgF44rJMtDa8DBsjQxi4KMhYTnmOwbpIjOWNCf/rKKHWVG?= =?us-ascii?Q?JXk2GodDNwb3OkZJeWkDgRzT8YIJgq4XGi2+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 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 01 Oct 2023 02:00:00 -0700 (PDT) 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); -- 2.35.3