Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35170 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934792AbeB1QPU (ORCPT ); Wed, 28 Feb 2018 11:15:20 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dominik Brodowski" , "Johannes Berg" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: Subject: [PATCH 3.16 205/254] nl80211: take RCU read lock when calling ieee80211_bss_get_ie() In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dominik Brodowski commit 7a94b8c2eee7083ddccd0515830f8c81a8e44b1a upstream. As ieee80211_bss_get_ie() derefences an RCU to return ssid_ie, both the call to this function and any operation on this variable need protection by the RCU read lock. Fixes: 44905265bc15 ("nl80211: don't expose wdev->ssid for most interfaces") Signed-off-by: Dominik Brodowski Signed-off-by: Johannes Berg Signed-off-by: Ben Hutchings --- net/wireless/nl80211.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2354,12 +2354,13 @@ static int nl80211_send_iface(struct sk_ const u8 *ssid_ie; if (!wdev->current_bss) break; + rcu_read_lock(); ssid_ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, WLAN_EID_SSID); - if (!ssid_ie) - break; - if (nla_put(msg, NL80211_ATTR_SSID, ssid_ie[1], ssid_ie + 2)) - goto nla_put_failure_locked; + if (ssid_ie && + nla_put(msg, NL80211_ATTR_SSID, ssid_ie[1], ssid_ie + 2)) + goto nla_put_failure_rcu_locked; + rcu_read_unlock(); break; } default: @@ -2370,6 +2371,8 @@ static int nl80211_send_iface(struct sk_ return genlmsg_end(msg, hdr); + nla_put_failure_rcu_locked: + rcu_read_unlock(); nla_put_failure_locked: wdev_unlock(wdev); nla_put_failure: