Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2186990iof; Tue, 7 Jun 2022 22:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAh32gO75Qr5FGc+XcI5a/9sc5pmzgOCYoQ19hb+UyEQ3wnSPZX8n4aG0nbL7e8bg4Wvec X-Received: by 2002:a17:90b:3e8a:b0:1e9:d56e:347b with SMTP id rj10-20020a17090b3e8a00b001e9d56e347bmr4913763pjb.42.1654666455138; Tue, 07 Jun 2022 22:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666455; cv=none; d=google.com; s=arc-20160816; b=r0q40AfsOOHrY1QkvgtI8rvMFOl//nuOs3ITRgj9C81KOTr94D8PtWqsp/dKHaVQXK iFe/ueNzZhGhSC7NjAoEWBCmY1O+1e5BMABmDXPO3IduNzMBt4bzrzfDz0GBfvg3CMPs IKA5qtisHYVXLEqovTaUIGJBRCzEHJdE6dq1jcTPE2IZanNvGB7i4OSeixvsqw0FBYLG h8X+G3+idW0S+cyTUAe1FWuTT6tt753fcCFVTdWUv0F215rroLZWmOMFleNA0xz2js5E N4zxXdY/snBfvvSeh4Gp9kav07sKtjI1P8n8Bbj5omO69UrQKQS3TcnnI+unIXQwHIuU gY6Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9o/3dXr+sv+ZdcwmLCyoHpgpxN4A53lCsvRSo5jKsvA=; b=GqVs3k//ONjaSUNVcfzq9wduD6Y8Awy0ixFrHFjKy5850ZGkeRnpmFPI6iAiqPgB9+ Dojfq0jXaaHND0IKbtvO3DGdyBOJRF50/uFmv8MNSoIakul32wIKiWxfz9JxvqWXGyM9 qV/MoCoVxkf4ZF7dV0WCbKIgw79M8ohrklGzBeBNS00MyuDmrmbT3ez3Q/We8YknDtVa 4KVZEEg5bDQNg+BjNoZ0y0P04SZq7yNJc8cetIvxdPmOy7/Zn5hkig30RO21Xuxv3RSi iLxbEeYA9iic6H2EZRLwPkfur54k7400uTlBBXRDCnuXFQOeUJmHbUv0YcjMnNvK5KTv ga/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pv3uXzSO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q1-20020a170902eb8100b00161bc840c77si26408729plg.548.2022.06.07.22.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:34:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pv3uXzSO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A0D5B2DF116; Tue, 7 Jun 2022 22:01:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386860AbiFGWtc (ORCPT + 99 others); Tue, 7 Jun 2022 18:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381301AbiFGVk0 (ORCPT ); Tue, 7 Jun 2022 17:40:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCAE232377; Tue, 7 Jun 2022 12:06:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63091B82182; Tue, 7 Jun 2022 19:06:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDC28C385A5; Tue, 7 Jun 2022 19:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628791; bh=ygdYPuMUgBOhxnz9oYloPim/aXSmTjxLzeGUoSJ8knM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pv3uXzSOLIsFDf+Lmqe0ykuyG0ZI/wyGKpu1IdZA23ZrbplFJnqN1bePjf7T7cUrL /rjZrrO6P8UAbzc2TaRhldMCY5iC8aV2hxFkpERdSlrA6MT4U+kZxDw2/qvBd9kQp4 vFNfYVsJT/SwuZCP5pNpshAyLGKkwGJsDDQFn1Ng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.18 455/879] Bluetooth: protect le accept and resolv lists with hdev->lock Date: Tue, 7 Jun 2022 18:59:33 +0200 Message-Id: <20220607165016.077001742@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Niels Dossche [ Upstream commit 5e2b6064cbc5fd582396768c5f9583f65085e368 ] Concurrent operations from events on le_{accept,resolv}_list are currently unprotected by hdev->lock. Most existing code do already protect the lists with that lock. This can be observed in hci_debugfs and hci_sync. Add the protection for these events too. Fixes: b950aa88638c ("Bluetooth: Add definitions and track LE resolve list modification") Fixes: 0f36b589e4ee ("Bluetooth: Track LE white list modification via HCI commands") Signed-off-by: Niels Dossche Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a835ce6f8430..0270e597c285 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1835,7 +1835,9 @@ static u8 hci_cc_le_clear_accept_list(struct hci_dev *hdev, void *data, if (rp->status) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_clear(&hdev->le_accept_list); + hci_dev_unlock(hdev); return rp->status; } @@ -1855,8 +1857,10 @@ static u8 hci_cc_le_add_to_accept_list(struct hci_dev *hdev, void *data, if (!sent) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); return rp->status; } @@ -1876,8 +1880,10 @@ static u8 hci_cc_le_del_from_accept_list(struct hci_dev *hdev, void *data, if (!sent) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); return rp->status; } @@ -1949,9 +1955,11 @@ static u8 hci_cc_le_add_to_resolv_list(struct hci_dev *hdev, void *data, if (!sent) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type, sent->peer_irk, sent->local_irk); + hci_dev_unlock(hdev); return rp->status; } @@ -1971,8 +1979,10 @@ static u8 hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, void *data, if (!sent) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type); + hci_dev_unlock(hdev); return rp->status; } @@ -1987,7 +1997,9 @@ static u8 hci_cc_le_clear_resolv_list(struct hci_dev *hdev, void *data, if (rp->status) return rp->status; + hci_dev_lock(hdev); hci_bdaddr_list_clear(&hdev->le_resolv_list); + hci_dev_unlock(hdev); return rp->status; } -- 2.35.1