Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1304376rwi; Thu, 13 Oct 2022 11:45:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jBDV95cbOVqKuIRkCFy6WHIfZxT1py5S9fOxR96+6C1mVGH4WtayqMtVi5Q1mbpgYPdrw X-Received: by 2002:a17:907:6d27:b0:78d:46f6:c59e with SMTP id sa39-20020a1709076d2700b0078d46f6c59emr866417ejc.30.1665686733198; Thu, 13 Oct 2022 11:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686733; cv=none; d=google.com; s=arc-20160816; b=VryTV7jdJPu1GDLI46Zmg6LaT4pzgtMtFBOr6CnOt8yCoic3RBdPKgno/okgmtium5 xwjuTOFlXlpmI69j1p1E1X/KB/BdV4VxQP62h/DQf561GsoqnhH+pj0pMHM83PF45L60 E6PLoJkGiE9ltsZ1Q3uor/+vQwRxSnpSR3iXiu2NzbZ/7qrxBstPcKoWFFDhZhwzGkVT WSbF6ySoQXGmdaJKW3O8wRXzwrO6FkGupzCG2Bi3okUxv/r9Ti5l8x5MW7hCKOkDnwU/ j+j1KJjcit+LoKuTjI6u405ZpXwOHz6Txcopkj9s8QIR9uxWbQmYesDNjrgoEhUnCU14 NkGg== 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=F7pNw869a/nqE2lJ0T3vRMwgsF8gWuf/Ri4rOBZyVNA=; b=sxmrgum0YQpFsofhr/C9gcHrs8TWgATEeJoTd6k2g8XpiJnIYzroJKZgGvKolBeNUf w9h/XH+RBhf1q9teGyNtxTEkb5vv7KlnrWcqKDuaeUg4EOfrzgO/PoGCFucwKvCqyPZt EILyCW7wg/k40H2qtZ7r1d4MYhTWFNyTzXVQxhcptc0x0kydmoiaoEE9GBvpnA481BD6 llPZjSvw/hfzktFoLucpnaYFEjGQLCjFaZ8YjQ5uk/rmzWZxzb9kdk+NsSUpmrrjAW1Z GIlTt8Nh0HYQsOI0jh8uhJDHSOsRqnW2XWKYZw2GTCszgPKmFhHZ4N4+X9L2a+T3noGs +qTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cpDXaARa; 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 js4-20020a17090797c400b00778d193ca81si388359ejc.550.2022.10.13.11.45.07; Thu, 13 Oct 2022 11:45:33 -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=cpDXaARa; 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 S230112AbiJMRzt (ORCPT + 99 others); Thu, 13 Oct 2022 13:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbiJMRyv (ORCPT ); Thu, 13 Oct 2022 13:54:51 -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 113C015B331; Thu, 13 Oct 2022 10:54:01 -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 EDF5EB8201E; Thu, 13 Oct 2022 17:53:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BF0FC4314A; Thu, 13 Oct 2022 17:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683638; bh=sSqsu/k7yCRo955wozzFH4QiJ3MfdL8o3wAU2EqhNQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cpDXaARaAKdpMcESmUg2Ys2A4dqGbT0nS9wsTNBH7/r7PNDw+k/LgTxNq4nPC/K6Y fsWwYhI2cPlS1oTk8xSwP92Hlxd9B6+9jmTd6D84BstbnV9yo75WALu0UWScOXHIRE 9gjV6N0Veny6lEN3STF06wl5dyEw9sh/TfRv7iSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?S=C3=B6nke=20Huster?= , Johannes Berg Subject: [PATCH 5.4 36/38] wifi: cfg80211: update hidden BSSes to avoid WARN_ON Date: Thu, 13 Oct 2022 19:52:37 +0200 Message-Id: <20221013175145.450004794@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175144.245431424@linuxfoundation.org> References: <20221013175144.245431424@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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: Johannes Berg commit c90b93b5b782891ebfda49d4e5da36632fefd5d1 upstream. When updating beacon elements in a non-transmitted BSS, also update the hidden sub-entries to the same beacon elements, so that a future update through other paths won't trigger a WARN_ON(). The warning is triggered because the beacon elements in the hidden BSSes that are children of the BSS should always be the same as in the parent. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1099,6 +1099,23 @@ struct cfg80211_non_tx_bss { u8 bssid_index; }; +static void cfg80211_update_hidden_bsses(struct cfg80211_internal_bss *known, + const struct cfg80211_bss_ies *new_ies, + const struct cfg80211_bss_ies *old_ies) +{ + struct cfg80211_internal_bss *bss; + + /* Assign beacon IEs to all sub entries */ + list_for_each_entry(bss, &known->hidden_list, hidden_list) { + const struct cfg80211_bss_ies *ies; + + ies = rcu_access_pointer(bss->pub.beacon_ies); + WARN_ON(ies != old_ies); + + rcu_assign_pointer(bss->pub.beacon_ies, new_ies); + } +} + static bool cfg80211_update_known_bss(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *known, @@ -1122,7 +1139,6 @@ cfg80211_update_known_bss(struct cfg8021 kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); } else if (rcu_access_pointer(new->pub.beacon_ies)) { const struct cfg80211_bss_ies *old; - struct cfg80211_internal_bss *bss; if (known->pub.hidden_beacon_bss && !list_empty(&known->hidden_list)) { @@ -1150,16 +1166,7 @@ cfg80211_update_known_bss(struct cfg8021 if (old == rcu_access_pointer(known->pub.ies)) rcu_assign_pointer(known->pub.ies, new->pub.beacon_ies); - /* Assign beacon IEs to all sub entries */ - list_for_each_entry(bss, &known->hidden_list, hidden_list) { - const struct cfg80211_bss_ies *ies; - - ies = rcu_access_pointer(bss->pub.beacon_ies); - WARN_ON(ies != old); - - rcu_assign_pointer(bss->pub.beacon_ies, - new->pub.beacon_ies); - } + cfg80211_update_hidden_bsses(known, new->pub.beacon_ies, old); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); @@ -1798,6 +1805,8 @@ cfg80211_update_notlisted_nontrans(struc } else { old = rcu_access_pointer(nontrans_bss->beacon_ies); rcu_assign_pointer(nontrans_bss->beacon_ies, new_ies); + cfg80211_update_hidden_bsses(bss_from_pub(nontrans_bss), + new_ies, old); rcu_assign_pointer(nontrans_bss->ies, new_ies); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head);