From patchwork Wed Mar 7 17:11:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Beichler X-Patchwork-Id: 882697 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=uni-rostock.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=uni-rostock.de header.i=@uni-rostock.de header.b="Se8TtJjF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zxKtz5T6Tz9sf8 for ; Thu, 8 Mar 2018 04:11:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934104AbeCGRLx (ORCPT ); Wed, 7 Mar 2018 12:11:53 -0500 Received: from mx1.uni-rostock.de ([139.30.22.71]:63850 "EHLO mx1.uni-rostock.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933487AbeCGRLu (ORCPT ); Wed, 7 Mar 2018 12:11:50 -0500 DKIM-Signature: v=1; c=relaxed/relaxed; d=uni-rostock.de; s=itmz-nsp; t=1520442709; bh=zRsWGUYSzxw4NEvkH4DOHmUJcp+mloGYEHLk1u4FMFc=; h= "Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id"; a=rsa-sha256; b= Se8TtJjFfrKqQk9RgExqdTlVrgdDatNNHMAcF5tqe/h5cj1CbUnmu0oXXBlagTbatHLjlQYqCQ+4HjMBR4nkmfMMITiGuq4LR38Qv/gwSEEr2BiqYBgOYaq8B2SpIO+Dk+eV6C2I2GrcL1RYSFjviFAUf0jzgoQr/IxpZVmzm9k= Received: from BB-manjaroVM.amd.e-technik.uni-rostock.de (139.30.201.113) by email1.uni-rostock.de (139.30.22.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1415.2; Wed, 7 Mar 2018 18:11:48 +0100 From: Benjamin Beichler To: CC: , , , , , , Benjamin Beichler Subject: [PATCH] mac80211_hwsim: fixed use-after-free bug in hwsim_exit_net Date: Wed, 7 Mar 2018 18:11:07 +0100 Message-ID: <20180307171107.2803-1-benjamin.beichler@uni-rostock.de> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-Originating-IP: [139.30.201.113] X-ClientProxiedBy: email1.uni-rostock.de (139.30.22.81) To email1.uni-rostock.de (139.30.22.81) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/net/wireless/mac80211_hwsim.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 7b6c3640a94f..93a7ae34653e 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3528,8 +3528,12 @@ 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); + hwsim_radios_generation++; + 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);