Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2827142pxb; Mon, 1 Nov 2021 02:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs5q/T5xkI6Mv2vzv/nBqYJJ4/5UY2nG4iGGTWr5+uuQhlBu2cO9v+4ENYo5GxR9LePW7m X-Received: by 2002:aa7:d155:: with SMTP id r21mr29065235edo.341.1635759526210; Mon, 01 Nov 2021 02:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759526; cv=none; d=google.com; s=arc-20160816; b=GK8o3NmO1LyWD2e4a74D/TXcvDNsnLEr/crXQEB+hreMCLdIYVYlOszyz5tFulO8Xx 0kUSwhoUP31o1e2vNFYGImPknprFFm41uNylJ1+nTTaiVRWk6rAApM82VStGwItUpA2j EuNYHX+PTPdMB4ZkBfvEXj/BojkpH85yof7D/M5MzdAGK1oXccrHiQelakW6UsTik21z k32W3eueO0lSalCiIZVf1hj7cBaRje7jGQGDQ6zeDr2eA++ASztCzq5aCYHSmRYNNV01 6GVmSxYTxMKbWxFdzazMXzP8meqgLqzlJIgkmXV6DjCpzuF0SNRnkz7ld7iXej8ocfmd E8SA== 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=7Cai9vBBcPRkiarNoL+4K0AJmuTSMSpZbsvYJRVTE+s=; b=k7VsGJHGAnYN4PAJWLAAx1ERtSYT9bQ+Xh3Pr2ZsLlSl01XGPvc86hmYOQBoO4w8rm 6ib2c+0mFhaRjs2bBUdrj8lJAdsYBbAMXbfuAzynzSJIdNa2DWjypTueDLkYUmnnljUk UUzyRZ0p16Pi2L0aGcw+sP5RFNW4WtmlZa/NyL8KtWpxEsJ+QN/ZOpLwSo7UbxwKNztT I0FxxxfTarpWcvZ/32xn8DIKNMftECLa4Pj0lay5HcvtKui70YQmJWDWrlq3yrHm9xTZ 7Oy+7NNjdhSp4gXL5WKZUisp6WYngQRIfpwqJba5NUFsvxyJoqd+4xZTFTnLTD93R5Qq v42A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cPOviT/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si19559494edc.386.2021.11.01.02.38.22; Mon, 01 Nov 2021 02:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cPOviT/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbhKAJhO (ORCPT + 99 others); Mon, 1 Nov 2021 05:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:43594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233622AbhKAJdr (ORCPT ); Mon, 1 Nov 2021 05:33:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3F24061265; Mon, 1 Nov 2021 09:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758716; bh=pvJr1WrYLJxcxoBfz2R65K5Wa7sWMt1a0oeZCQbtU80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPOviT/1E+P4LJkdDP5Jh3mxHURZxWMQ+VEVRgP/nMgyJ4Ysl3y1NoUg0t8H5TfMy CmyTtSRHX1k9cqjMHM8Xy4R8oHTKKKfRgA2/Q/LmvEsosgclRfZsFVkY4Tskq1J8QM gR7KsLP7/bVHpvvpZun3/9USE5nmyXERKN7Ewrtk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg Subject: [PATCH 5.10 28/77] cfg80211: scan: fix RCU in cfg80211_add_nontrans_list() Date: Mon, 1 Nov 2021 10:17:16 +0100 Message-Id: <20211101082517.840847610@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit a2083eeb119fb9307258baea9b7c243ca9a2e0b6 upstream. The SSID pointer is pointing to RCU protected data, so we need to have it under rcu_read_lock() for the entire use. Fix this. Cc: stable@vger.kernel.org Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Link: https://lore.kernel.org/r/20210930131120.6ddfc603aa1d.I2137344c4e2426525b1a8e4ce5fca82f8ecbfe7e@changeid Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -418,14 +418,17 @@ cfg80211_add_nontrans_list(struct cfg802 } ssid_len = ssid[1]; ssid = ssid + 2; - rcu_read_unlock(); /* check if nontrans_bss is in the list */ list_for_each_entry(bss, &trans_bss->nontrans_list, nontrans_list) { - if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len)) + if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len)) { + rcu_read_unlock(); return 0; + } } + rcu_read_unlock(); + /* add to the list */ list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list); return 0;