Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3717031pxb; Tue, 19 Apr 2022 08:28:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzFT6Y6mEeFFiEJXZ9yEj/zSyTK3OBxFQIj54rB8KWtohVR/UhRL3siD/HrijeTBRW+Nsg X-Received: by 2002:a17:907:72cb:b0:6ef:aecf:1bd7 with SMTP id du11-20020a17090772cb00b006efaecf1bd7mr9397446ejc.515.1650382135899; Tue, 19 Apr 2022 08:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650382135; cv=none; d=google.com; s=arc-20160816; b=q1yYfa15zQ4jM0QSS3GqowJAwpYZaD12wULZuV9nolKmf6r2MNcDv2cAPULLU4/VzC GDP60J7Qa3eZy7STX1GZIw1hCu9ytw0COpnhyHDnRv47AiOLvSWdjiK2KiK2RT5sxo/Z iCVBDeeWFz4nZPTFlHB+V+8Oc4FKkEISDp51/xFmbHNJvwjA02FjgbT+hRxZEhBf6Rxg rXV0sZgufkfRjYPsGKCEXRUmp47taOPTYP4wMV7lqyODUbwuqbxYijH3eiu9ARoGo4oL FkH6ceMN+Us/wmJnvvTeNwiQt9Bfyv9+bkBECLabfUnbmDChs3zIUu1TEgn6M3SvLezP hOLA== 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=G59UisIfs97RQasmo4c6/4ycQzXHFsK6KbYMbLa2r10=; b=uR61b7cSQqDpi97ud66ZQjXE8PDuT7qh+ack5QWhtXsb/cbk5Be3Vt/39n/lx+UpGf 1rQl6LZj+osSrxajU/OZ0MYbXAaobuuLtBzIym0ZEeVpSYtzmb4HUpeLSzbP8Kc4yM6f JAA/Twm6SD8dtePHbGVURbqyAipb+vNqUq9FppXT2MhwZnmtjPeR6lFeuWg66JIIR7EF /nhUDn5R9LrVahVXQ3PnnYaZ8oyhjYteuR9fm3CFzxfGUC4sooQ/dTaSengzTC32hsK9 7jV5Q45ORDfiTTCCauMsYvNtGXZ+RA2JwP3YZnp2ifNQlMOBKTPxeEG7cWXhNpFAVkh6 XBNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fopWR2ST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv37-20020a1709072be500b006e802115fc7si8128023ejc.526.2022.04.19.08.28.30; Tue, 19 Apr 2022 08:28:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fopWR2ST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238897AbiDRM1X (ORCPT + 99 others); Mon, 18 Apr 2022 08:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238778AbiDRM0O (ORCPT ); Mon, 18 Apr 2022 08:26:14 -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 B09E0E01E; Mon, 18 Apr 2022 05:20:07 -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 725DEB80EC1; Mon, 18 Apr 2022 12:20:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6F0DC385A1; Mon, 18 Apr 2022 12:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284405; bh=qZQBsX8kMeWOoOIEuv5t0Jmahj8cLDrFPtcjkPWKtWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fopWR2STUs33FpbhfytReWvgQSUE+g9xS7B94JB3k4EwxWL6WejC5aIS/huEBydC9 9Kr+98l02icV+A1YX8nIxzGEG1PiTOCTgtLDXFwDnbFs5LoNBrTINBuBsIswHfi4Xl B5ObOzfdUa5uau27UHAhT2oeBXOYBMX5h9r+5b2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rameshkumar Sundaram , Johannes Berg , Sasha Levin Subject: [PATCH 5.17 087/219] cfg80211: hold bss_lock while updating nontrans_list Date: Mon, 18 Apr 2022 14:10:56 +0200 Message-Id: <20220418121208.920151613@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Rameshkumar Sundaram [ Upstream commit a5199b5626cd6913cf8776a835bc63d40e0686ad ] Synchronize additions to nontrans_list of transmitting BSS with bss_lock to avoid races. Also when cfg80211_add_nontrans_list() fails __cfg80211_unlink_bss() needs bss_lock to be held (has lockdep assert on bss_lock). So protect the whole block with bss_lock to avoid races and warnings. Found during code review. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Rameshkumar Sundaram Link: https://lore.kernel.org/r/1649668071-9370-1-git-send-email-quic_ramess@quicinc.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index b2fdac96bab0..4a6d86432910 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2018,11 +2018,13 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy, /* this is a nontransmitting bss, we need to add it to * transmitting bss' list if it is not there */ + spin_lock_bh(&rdev->bss_lock); if (cfg80211_add_nontrans_list(non_tx_data->tx_bss, &res->pub)) { if (__cfg80211_unlink_bss(rdev, res)) rdev->bss_generation++; } + spin_unlock_bh(&rdev->bss_lock); } trace_cfg80211_return_bss(&res->pub); -- 2.35.1