From patchwork Thu Oct 13 17:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414469wrs; Thu, 13 Oct 2022 11:15:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+uZ9RzN42YWQCjL1fCjKDbp/CU1qIns2w3D9gOvev+/hufzgTgVn0uymQBzt2gOXKVwC+ X-Received: by 2002:a63:df03:0:b0:462:cfa2:2871 with SMTP id u3-20020a63df03000000b00462cfa22871mr970901pgg.225.1665684926330; Thu, 13 Oct 2022 11:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684926; cv=none; d=google.com; s=arc-20160816; b=iPoWekoy0yT+2QPycu/+0/ypfNaz6Wif1XndUqNggk5x32I2pmmowgAOjQEOSarMED Qcf7TlmY4qjnB1rk175e1riVCAkdJz4XPgGpN78ObS7OCTMpy+tV+0XOpNraS3NXgulw FXsy6KMRrwIOx+ZT/l5JR1ju42hl0vovEEKWGxhRU+xq5TsPKbrhynQYaZar83xU+XB+ GYv34lZludOd9JS6K0dbjY07Pyr6DDts5/OsjzROiq3BWo0iYaoLo1Tx2oU8dOfZq1+v ttNeEIasGXiDo6QSwRxtkkIfLen8HfSzNBoQGIX0lz2ifCpIdLInv8KeN3QzN7T0IRzj IvtA== 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=JG7ZWaoeTOylZfqZiuII2mkdTcd2ePXcBWm+skZIpv0=; b=GxvRaxi5tpas2yzz1wKzIlU4FQW6Hurm4B741xLBvc4z/Bx5Llc++AXwTnxXZNGJ68 Q9LqyqRWiQ5r8hueQSEKpxYukc2MLaYWo0K8yPDWV39PMdbIPQYQ5ckTCWo6nAX8uEne UfCnRHJAHTz1woAKxdju/bkxxz/PYIC5qYSKsm6lX/BaMoC5evgRu0bvVSS0Lrhnxc0S lr2nETKMJ7VuuL+IjPsER70iwyvDfPMlot5ge0TSkutpHepki1VgZUT9kKxy6H9XhIkF m9nW9xrUD90qB8+srCBGGJ54qCNY8UaHYzqtAhrZcWXz8AFSNDY+B4ipkHaSdQbtTBCz fNmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M+Lpco07; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170903234100b00180680b8f1bsi484280plh.264.2022.10.13.11.15.12; Thu, 13 Oct 2022 11:15:26 -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=M+Lpco07; 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 S232007AbiJMSN5 (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbiJMSMn (ORCPT ); Thu, 13 Oct 2022 14:12:43 -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 D26FE170DF4; Thu, 13 Oct 2022 11:09:27 -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 56CC0B82035; Thu, 13 Oct 2022 17:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADD0AC433C1; Thu, 13 Oct 2022 17:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683896; bh=cJQs9i7XIYPlZuA7D9TEzytPMEnPOPWZP3TKAyK7eCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+Lpco07SMBWlS9An3BAEFpcdJGjcQj5Q33IBI+bxrlBOtGLZwBxe3luQjcRqGBlP E38Sf95FDroou5I2bjjbHU88ceB7Cs+8qzD7BnJ/cpQunPda1qOn1wYHQ3M43LOgKQ 139hS7NJ2CJCglCizB2X2cz9d9pGRw3LSuzZNJUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 23/27] wifi: cfg80211: update hidden BSSes to avoid WARN_ON Date: Thu, 13 Oct 2022 19:52:52 +0200 Message-Id: <20221013175144.394551591@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597237234150659?= X-GMAIL-MSGID: =?utf-8?q?1746597237234150659?= 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 @@ -1609,6 +1609,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, @@ -1632,7 +1649,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)) { @@ -1660,16 +1676,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); @@ -2319,6 +2326,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);