Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp718664rdb; Sun, 1 Oct 2023 02:22:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBaaLPuWcFtqhHYgan1PHld8/qzpvdNpEZqnDzQ56qGpsLyFAbBCseo2khJAOOEnYu0Q2W X-Received: by 2002:a17:902:e88b:b0:1c4:375c:110a with SMTP id w11-20020a170902e88b00b001c4375c110amr11938877plg.19.1696152146878; Sun, 01 Oct 2023 02:22:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696152146; cv=pass; d=google.com; s=arc-20160816; b=D3xZ4YcG4J4zZcZuILDvjY3FnQ9tJ6SfNsqbyv7bR25vFGWtMGljV8JyopI5YW4uWz kjsMJ35q5muk+GdxsRQBSM8zsJh2UGZu1QK5kJKDTYhhxqQF1BvRcF1RUCncyXocOB+U uHXi6uDhIOnUI0or/ORlZjVpMWXfvZkvWGILoe085YJZq2kMz2o3dIJ7irNAGFl1VOvT +FMvvLXhTfsJ/ik5tjGMxEG71QjJqDZcBISlA7DBPkY/XfC+ZyPUBn83SpaW734aEi1F fLbG06fP6JFM3URF/zhrnHuLOguCAEPqC1Nj+mJh33g1zTJep4kJ+zp7yoJOD412pS6z e6Kg== 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=eGQqYZ0FgUqrYy37FVP0MiI7B5zDK0F712BQATH/yqA=; fh=YoKn3rNui1Uy12poG2FqwVn8fhiNCgV4MVj74J55Nj8=; b=ESj+C7VnYoRAipXpnSPqte3gDOpByu0/LXCyxLw7Quro8rYB2aI5j9L/pxiw37Q+BH ItJD4l/UB/ed9YUNjYaIhx4O2ULvYQ59AzAjdZ5xnevWa1oai/WTjexSqX0ljL1ucjUW XY7pmK0Sxorerp9lxScQQxq2YC7CizBjsrgw7SZVUeS/425PTV6gqqsR2smif+RGPF6p Swxf/9WZIaWuOgHbGHc641cb2xXyIvgnry0AQsPKvRc1lhO/c+DCLXrWlRreM9SsJiYM 1OyuDR0f7B4FhzqQQi5fTjKNNzk0g7mFj1OzVmdW/AcMcFctOeNB+dfEAbSxmoOy7b5L NjGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b="v1/vfP37"; 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-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l10-20020a170902f68a00b001c76b4c349esi560740plg.218.2023.10.01.02.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 02:22:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b="v1/vfP37"; 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-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-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 snail.vger.email (Postfix) with ESMTP id 88921802C68E; Sun, 1 Oct 2023 01:11:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234453AbjJAILE (ORCPT + 99 others); Sun, 1 Oct 2023 04:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234402AbjJAILD (ORCPT ); Sun, 1 Oct 2023 04:11:03 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2087.outbound.protection.outlook.com [40.107.13.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472CCC2; Sun, 1 Oct 2023 01:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S81wK+Amgy0lDsjbrczVCT3kZJ8izBPYkNxr5oHfhuVxFKM2NI2rnOvTjk51PGc6r9et3f4zpQ0V6pC9yRH/OpDq6sIlhil8xg1m4CCgWy3rKR/SZq7PQHtJGRHVPAiIcw+mqsOe3r/xNpKVfSjbTdpbs1EnNK4auy/0oN2KwaCZgz/im3pHq542+EcYCJvuQWSjEN0UydX4Zk8UPFPtF7x8XHtfHkAWmfNLA0NxqMwQulMmd7c8KrmcV8vgjdnNWmFqRrsXo2tRdn0MK9RuS51SqQlURxCjia66zyTDSA93SiyesgdT7PCrxu1pRh3ZiJFEea5O2MWH2fA0p/nFcA== 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=eGQqYZ0FgUqrYy37FVP0MiI7B5zDK0F712BQATH/yqA=; b=JyAFQRjPaG2g+1drq5Nys6GiKw115sI2AP5d4EtIwSB3CHdQz7yIgPabz0wDERqCnAgv/E3YBBqNrNkI48yuaEDLh6JWfUtYfes1YkgQ/2cvbxxIPpgVn0h8DYa01xuaZGBL0KEpkunDQmrNWsW6otU3ZrMa+HpUVzjNaVBD35b0qpJa8aRMcsO0CiRJxznx0k4R56bMDXROi+lce6MU82RjbpYIRJIk6P9+yg0y47oZTc4MFKmFqZMMZschLavXLyHjYMTVYcVnQZFVoe9O8rkJnEM2XJc86Eejv9Ve0/Vy1Vl51lmrpUdVA4BNluiW/eurnEMdviD8cpLoESPUlA== 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=eGQqYZ0FgUqrYy37FVP0MiI7B5zDK0F712BQATH/yqA=; b=v1/vfP377zE0SJNeY61iL6URa82notbdIm72akwYdIOKBGKf8+fwZyvxy9XzNl/HrMoK62w4buen4G0XwTTms5ct5pKp2UmXh4uMJ2yeNNFhUOgrCrLf9jisqfxvb1K8/vQdTuE1Rq2bMQGEZvX33S35y60v0UWRh0CHLpv9Ov8alKjE5K2m1XqCeBQWF0y7jQON0WEJ4/21HmhDrOTi4Df+B9VqS8iPnNyVmpss88qcn6dIPAhEY6J0MJMJUM++JKxMcGD03JC+D3xjv+uL8BN5uPqhJ0UMVG+ngdoH60DlrzFPQrUCE9NJ1laC70xHII8MiAHziHfm5TdBDJws+Q== 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 AM9PR04MB8572.eurprd04.prod.outlook.com (2603:10a6:20b:437::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.23; Sun, 1 Oct 2023 08:10:57 +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:10:57 +0000 Date: Sun, 1 Oct 2023 16:10:46 +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: <20231001081046.GA14551@linux-691t> References: <20231001080328.GA14494@linux-691t> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231001080328.GA14494@linux-691t> User-Agent: Mutt/1.11.4 (2019-03-13) X-ClientProxiedBy: TYCP286CA0157.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:383::12) To DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7164:EE_|AM9PR04MB8572:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b646b5b-a635-4e29-9baf-08dbc255f127 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YwDHG8n2HLFuH74X7q1bdHwnPQHfrCB16E/gh1pvLYjbWnDtHqpzmS8xx/CIqrEOjTmO0c7DrlWQIgcTudbbL4IxIfjRkxJGk3C7dcvccC2g4JxdzyLOFNHkMKg2cOoGyKx4SItnapbxxUQNpK6Bjq9RHDwV299wCeQJlbXZLVYSZTz9GIMpk/x0ankPPX2XzkHxIV9V4TjmSF/6ObZsy9og7By9ksLOFex1PzhczEjJaVVXoXU7cqGXB2nkvu+8txAcqeWzkRM3dIH4+mDapPhsEo4CCv0R21mD1oQV0p0tQGSzUgElChJTh2Ky+rJY8DbOBpbtCN3EnK3yo5ToomMzBfovgT5DmO3TE+B8AmwJVEjqqYSKf89yPQ1zvfqY7nGFa/IK+MQ1UDFGgQzZivIusjjrA16AoEFJY8ZUIPndQPqgcyqqVnjGuSvO/WBe7EUFems0vRYh5QYiNZ6dg0x57E4FYzRScmFEeLkd1XzT6uditCEWrK0MsrroNEdMvyUc+DmiFEayAU+B9FoakaT2DJrdRCA9nu8FcJZ1bxI= 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)(376002)(346002)(39860400002)(136003)(396003)(366004)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(1076003)(26005)(33716001)(38100700002)(86362001)(33656002)(83380400001)(316002)(8936002)(8676002)(4326008)(5660300002)(41300700001)(110136005)(66476007)(66556008)(66946007)(2906002)(6506007)(6666004)(6512007)(9686003)(6486002)(966005)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zEMj0mD50TTEnaJySBBmqPou5dH7eNIYeO1VcLSkIkpR7HFzetpziBMP8OsZ?= =?us-ascii?Q?W7JsLwpylWmy6Zeawf+4Uestp/7sW8wcLwFS1l/S9T2ihLT9Zv1RKOuqSlvn?= =?us-ascii?Q?+PA4BkRc0jRTpqlqEEktzMbIr/61WNXsGqpkUS8YNKbk6ZqXSGd6kINBZPtD?= =?us-ascii?Q?EonTE9aUzcrDIn5CvsPzRIHXrc9AFcey+4MM18mdvsvM07wVbW+iGjLjg1c+?= =?us-ascii?Q?OiUSDsazCS2HXKdvD1pujLOQqRYUOFdxlm6ADuuhKJ37yiCvv/UTQ2cgANzX?= =?us-ascii?Q?SnrS3K6Z8B7CGu6LVFb4ryUDJL9TO3ot5cn9OhofELdfujIBMny3OxvxdL96?= =?us-ascii?Q?KPsIpCw+hLA1Fiygkx965AVHbfs1XpjXy+vbO312aWCEhuoMXkSf2+OAYchE?= =?us-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BUwzvCjKIetn0+wBGucFoFyC?= =?us-ascii?Q?6YBaz3nXSxRS1Ndm2NXl7RI6pZmZbAA4UuXGH5Ahy4lx1DnDaGNwnsZU7a3E?= =?us-ascii?Q?SbOqTv2wGbleThYC9J/pp9LpbARUrIXPTwjb0/FnFPdwEcr+f/hwZmw9UHt+?= =?us-ascii?Q?1m2RBmObJDWVDWeSnMMfS648JP5bTFW2+eBz3J73mtFdYKvmm2d/CVKMdll/?= =?us-ascii?Q?6oAzUYcwpOzlX9LiJLYaqqKfcIl7A+HtBIv8JMWyfZMbsesoqb9aPbDm4uoc?= =?us-ascii?Q?gzOTgqtcuWQ/WlZj37KXryNejHxWcaMMUmsgOU//?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b646b5b-a635-4e29-9baf-08dbc255f127 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:10:57.7861 (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: MdnDpaJKBBTeqAgC0Lj0ONTyLnmY6kwo/y4sjTQcuvYAFvi9BrSLXZLG0zEI9Isx X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8572 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:11:17 -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 95816a938cea..a20a94e85b1a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4692,6 +4692,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