Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2134145iof; Tue, 7 Jun 2022 20:53:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvZVTeAF6Qz7Wc5ljin442Wgh6cebOicDLs01Ov/NUUWucU3ZrXsazq1X3523AYzx1IjsE X-Received: by 2002:a17:903:32c5:b0:164:1a67:30c5 with SMTP id i5-20020a17090332c500b001641a6730c5mr31722741plr.31.1654660416617; Tue, 07 Jun 2022 20:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654660416; cv=none; d=google.com; s=arc-20160816; b=yRMUH7aMjLpxM7BAqtivSDtPuNk11tx1kgh+HfN982AV2PR2HiT1kW4VhrTK2CtruD mWZNKfsfwFwA0/q8oHQ0GT2H0aRhItIoHWz0BuCLF8+DMG9JNymTW00eEiXaimJWdwMq d6YHi1odVBwQbMTp7TzlV3Hmq1tRdafqsuLDVoLM172dDte7BplgY7SSWwkLbwa9rFcc E5pzs+Z4h+aUtQ0+nNlxTVO/k+7M7zxHnfCk4NIfuE8BhulFV45Juy7EeKYQ3jI9hjpW ggRKfXQVN3EwCqpzHn24XtEZXslsJlOfk0mO/3X23lF6zMg0R+cJA9i8Jx7GJZjCDXGC rJ3Q== 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=/3BsYdXAhsjHEs6wtF3MU0VVeaJTZnm6H/cjIs9rvwU=; b=Hma874nnUZPWz2Qj0baOMiDYv36+z+240f/uGpghOgnXXzHBF/OuDbdltjt42Vimv3 d+MeNxGeN+I9heQgSHtoh/085eHueolooul5R6rcnybTdnQCQyLYCns9MCeT6Wltt6WM 4Y4QOzGxKDfHfPaD9t9P/gZMN16HzhFCHPBgbmp7LvP27amJ3PmgPrzD+ia9InSJFPKf ImP8gKCtP01df4WUvuVqmv/u9gpp8lGWRGgKJ59BLCwj7WkaS8qvl6dRdMHddPUBkkF1 IQPJ+zOJTQUzPEEW9rvbSd0NhMzoV9GFLAgQ8d/OU4UTF55IXliugrDCepLG5WaSn3R+ GLrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e6XRoCzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k192-20020a636fc9000000b003fa6b42a47bsi29602366pgc.837.2022.06.07.20.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e6XRoCzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 1B5E94012E4; Tue, 7 Jun 2022 20:23:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386744AbiFGWtX (ORCPT + 99 others); Tue, 7 Jun 2022 18:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381303AbiFGVk0 (ORCPT ); Tue, 7 Jun 2022 17:40:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C4921F9BB; Tue, 7 Jun 2022 12:06:28 -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 B974CB822C0; Tue, 7 Jun 2022 19:06:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 367C3C385A2; Tue, 7 Jun 2022 19:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628785; bh=fBS2BidZn5RqdMjmAq72Xd9LzbXKHWPaJR3JL95dGIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6XRoCzmLP9oje7NrAFt7lNmfSWPLDVgp1Ozgfpzay3PbNCx0IabrvRXk//yvnwdB V/9DV4wLVE35Rk1eUX6GdCtqAcbZroIUTh2xw7Zvv2u1CuYnI1A1o13ibAdWdv/ERM LHgw/aEWnzedshj5TGjBosstkfpiisHIaqrP4eFw= 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 453/879] Bluetooth: use hdev lock in activate_scan for hci_is_adv_monitoring Date: Tue, 7 Jun 2022 18:59:31 +0200 Message-Id: <20220607165016.018255763@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 50a3633ae5e98cf1b80ef5b73c9e341aee9ad896 ] hci_is_adv_monitoring's function documentation states that it must be called under the hdev lock. Paths that leads to an unlocked call are: discov_update => start_discovery => interleaved_discov => active_scan and: discov_update => start_discovery => active_scan The solution is to take the lock in active_scan during the duration of the call to hci_is_adv_monitoring. Fixes: c32d624640fd ("Bluetooth: disable filter dup when scan for adv monitor") Signed-off-by: Niels Dossche Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_request.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 42c8047a9897..f4afe482e300 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2260,6 +2260,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) if (err < 0) own_addr_type = ADDR_LE_DEV_PUBLIC; + hci_dev_lock(hdev); if (hci_is_adv_monitoring(hdev)) { /* Duplicate filter should be disabled when some advertisement * monitor is activated, otherwise AdvMon can only receive one @@ -2276,6 +2277,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) */ filter_dup = LE_SCAN_FILTER_DUP_DISABLE; } + hci_dev_unlock(hdev); hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, -- 2.35.1