Skip to contentSkip to conversation

cfg80211: fix rcu in cfg80211_unregister_wdev

PATCH In review Dedy Lansky 2 participants 2 messages Jun 13, 2018 – Jun 15, 2018 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfg80211: fix rcu in cfg80211_unregister_wdev

Hi,

We are seeing intermittent crashes when calling cfg80211_unregister_wdev() and then immediately free'ing the wdev object, like is done in wil6210 (see [1]).
We believe this is due to cfg80211_unregister_wdev doing list_del_rcu() without synchronize_cpu() afterwards.

====================================

From: Dedy Lansky <[email protected]>
Subject: [PATCH] cfg80211: fix rcu in cfg80211_unregister_wdev

Callers of cfg80211_unregister_wdev can free the wdev object immediately after this function returns. This may crash the kernel because this wdev object is still in use by other threads. Add synchronize_rcu() after list_del_rcu to make sure wdev object can be safely freed.

---
 net/wireless/core.c | 1 +
 1 file changed, 1 insertion(+)
net/wireless/core.c +0 -0
index 5fe35aa..48e80973 100644
@@ -1012,6 +1012,7 @@ void cfg80211_unregister_wdev(struct wireless_dev

*wdev)

        nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);

        list_del_rcu(&wdev->list);
+       synchronize_rcu();
        rdev->devlist_generation++;

        switch (wdev->iftype) {

--
1.9.1

[1]
https://elixir.bootlin.com/linux/latest/source/drivers/net/wireless/ath/wil6
210/cfg80211.c#L2234

maintainer
#1 lore raw
Quoted 3 lines

We believe this is due to cfg80211_unregister_wdev doing list_del_rcu() without synchronize_cpu() afterwards.

Looks like all callers behave like you described...

I've applied this, but next time please put the extra text after --- below the Signed-off-by, and send patches that aren't whitespace damaged :)

johannes