提交 ccb6c136 编写于 作者: J Johannes Berg 提交者: John W. Linville

cfg80211: don't get expired BSSes

When kernel-internal users use cfg80211_get_bss()
to get a reference to a BSS struct, they may end
up getting one that would have been removed from
the list if there had been any userspace access
to the list. This leads to inconsistencies and
problems.

Fix it by making cfg80211_get_bss() ignore BSSes
that cfg80211_bss_expire() would remove.

Fixes http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2180

Cc: stable@kernel.org
Reported-by: NJiajia Zheng <jiajia.zheng@intel.com>
Tested-by: NJiajia Zheng <jiajia.zheng@intel.com>
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 31e79a59
...@@ -275,6 +275,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, ...@@ -275,6 +275,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
{ {
struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
struct cfg80211_internal_bss *bss, *res = NULL; struct cfg80211_internal_bss *bss, *res = NULL;
unsigned long now = jiffies;
spin_lock_bh(&dev->bss_lock); spin_lock_bh(&dev->bss_lock);
...@@ -283,6 +284,10 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, ...@@ -283,6 +284,10 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
continue; continue;
if (channel && bss->pub.channel != channel) if (channel && bss->pub.channel != channel)
continue; continue;
/* Don't get expired BSS structs */
if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) &&
!atomic_read(&bss->hold))
continue;
if (is_bss(&bss->pub, bssid, ssid, ssid_len)) { if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {
res = bss; res = bss;
kref_get(&res->ref); kref_get(&res->ref);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册