All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mac80211_hwsim: fix use-after-free bug in hwsim_exit_net
@ 2018-04-25 12:57 Benjamin Beichler
  2018-04-25 13:02 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Beichler @ 2018-04-25 12:57 UTC (permalink / raw)
  To: stable; +Cc: Benjamin Beichler, Johannes Berg

commit 8cfd36a0b53aeb4ec21d81eb79706697b84dfc3d upstream.

When destroying a net namespace, all hwsim interfaces, which are not
created in default namespace are deleted. But the async deletion of the
interfaces could last longer than the actual destruction of the
namespace, which results to an use after free bug. Therefore use
synchronous deletion in this case.

Fixes: 100cb9ff40e0 ("mac80211_hwsim: Allow managing radios from
non-initial namespaces")
Reported-by: syzbot+70ce058e01259de7bb1d@syzkaller.appspotmail.com
Signed-off-by: Benjamin Beichler <benjamin.beichler@uni-rostock.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 This patch is prepared for linux-4.16.y branch

 drivers/net/wireless/mac80211_hwsim.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 35b21f8152bb..20af54378cc0 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3484,8 +3484,11 @@ static void __net_exit hwsim_exit_net(struct net *net)
 		list_del(&data->list);
 		rhashtable_remove_fast(&hwsim_radios_rht, &data->rht,
 				       hwsim_rht_params);
-		INIT_WORK(&data->destroy_work, destroy_radio);
-		queue_work(hwsim_wq, &data->destroy_work);
+		spin_unlock_bh(&hwsim_radio_lock);
+		mac80211_hwsim_del_radio(data,
+					 wiphy_name(data->hw->wiphy),
+					 NULL);
+		spin_lock_bh(&hwsim_radio_lock);
 	}
 	spin_unlock_bh(&hwsim_radio_lock);
 }
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mac80211_hwsim: fix use-after-free bug in hwsim_exit_net
  2018-04-25 12:57 [PATCH] mac80211_hwsim: fix use-after-free bug in hwsim_exit_net Benjamin Beichler
@ 2018-04-25 13:02 ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-04-25 13:02 UTC (permalink / raw)
  To: Benjamin Beichler; +Cc: stable, Johannes Berg

On Wed, Apr 25, 2018 at 02:57:42PM +0200, Benjamin Beichler wrote:
> commit 8cfd36a0b53aeb4ec21d81eb79706697b84dfc3d upstream.
> 
> When destroying a net namespace, all hwsim interfaces, which are not
> created in default namespace are deleted. But the async deletion of the
> interfaces could last longer than the actual destruction of the
> namespace, which results to an use after free bug. Therefore use
> synchronous deletion in this case.
> 
> Fixes: 100cb9ff40e0 ("mac80211_hwsim: Allow managing radios from
> non-initial namespaces")
> Reported-by: syzbot+70ce058e01259de7bb1d@syzkaller.appspotmail.com
> Signed-off-by: Benjamin Beichler <benjamin.beichler@uni-rostock.de>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  This patch is prepared for linux-4.16.y branch

Many thanks, snuck this one in now :)

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] mac80211_hwsim: fix use-after-free bug in hwsim_exit_net
@ 2018-04-24 18:18 Benjamin Beichler
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Beichler @ 2018-04-24 18:18 UTC (permalink / raw)
  To: stable; +Cc: Benjamin Beichler, Johannes Berg

commit 8cfd36a0b53aeb4ec21d81eb79706697b84dfc3d upstream.

When destroying a net namespace, all hwsim interfaces, which are not
created in default namespace are deleted. But the async deletion of the
interfaces could last longer than the actual destruction of the
namespace, which results to an use after free bug. Therefore use
synchronous deletion in this case.

Fixes: 100cb9ff40e0 ("mac80211_hwsim: Allow managing radios from
non-initial namespaces")
Reported-by: syzbot+70ce058e01259de7bb1d@syzkaller.appspotmail.com
Signed-off-by: Benjamin Beichler <benjamin.beichler@uni-rostock.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 drivers/net/wireless/mac80211_hwsim.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 4182c3775a72..2681b5339810 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3346,8 +3346,11 @@ static void __net_exit hwsim_exit_net(struct net *net)
 			continue;
 
 		list_del(&data->list);
-		INIT_WORK(&data->destroy_work, destroy_radio);
-		schedule_work(&data->destroy_work);
+		spin_unlock_bh(&hwsim_radio_lock);
+		mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy),
+					 NULL);
+		spin_lock_bh(&hwsim_radio_lock);
+
 	}
 	spin_unlock_bh(&hwsim_radio_lock);
 }
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-25 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25 12:57 [PATCH] mac80211_hwsim: fix use-after-free bug in hwsim_exit_net Benjamin Beichler
2018-04-25 13:02 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2018-04-24 18:18 Benjamin Beichler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.