nl80211: take RCU read lock when calling ieee80211_bss_get_ie()

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: 44905265bc ("nl80211: don't expose wdev->ssid for most interfaces")
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Dominik Brodowski 2018-01-15 08:12:15 +01:00 committed by Johannes Berg
parent a48a52b7be
commit 7a94b8c2ee

View file

@ -2618,12 +2618,13 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
const u8 *ssid_ie; const u8 *ssid_ie;
if (!wdev->current_bss) if (!wdev->current_bss)
break; break;
rcu_read_lock();
ssid_ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, ssid_ie = ieee80211_bss_get_ie(&wdev->current_bss->pub,
WLAN_EID_SSID); WLAN_EID_SSID);
if (!ssid_ie) if (ssid_ie &&
break; nla_put(msg, NL80211_ATTR_SSID, ssid_ie[1], ssid_ie + 2))
if (nla_put(msg, NL80211_ATTR_SSID, ssid_ie[1], ssid_ie + 2)) goto nla_put_failure_rcu_locked;
goto nla_put_failure_locked; rcu_read_unlock();
break; break;
} }
default: default:
@ -2635,6 +2636,8 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
genlmsg_end(msg, hdr); genlmsg_end(msg, hdr);
return 0; return 0;
nla_put_failure_rcu_locked:
rcu_read_unlock();
nla_put_failure_locked: nla_put_failure_locked:
wdev_unlock(wdev); wdev_unlock(wdev);
nla_put_failure: nla_put_failure: