From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-69.sinamail.sina.com.cn (mail115-69.sinamail.sina.com.cn [218.30.115.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 053D92913 for ; Sun, 19 Jan 2025 07:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737273233; cv=none; b=Wc9E60YT0X5lSooJogmB4zGFqTMcZYFHqli9GPavIRoI6V/FQFUBdQ2IalF15UgLqRsVFpJaZQmEOcqHiseFxVSVIkSGGwx89EDbXdcbUdUavb4rO7Z+pTli3RPtbZdoo3dx+s241FBjui5M8C0CLnODreLx5gsTBIVVqz9MARM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737273233; c=relaxed/simple; bh=pIAK0b/m8xykEdoL8ezP9LHvksuDPDninMwsAcTQVng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qUlgFAO9AG8semAr1bSQj6786EFx5Q4BV33qzFiS8ERdJ0CcwiVBeIjg5Ka16c9m7fVEc5zLg6wxRt4Ou9Zf7kthOyAJAAtPEEuKGr7JnBF2PKNBedsmQPwtAKhqYonHQ7oAwRGHRj84wCk/jGXlNEFFx/adg0NX/aUzde4s1ek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([116.24.10.102]) by sina.com (10.185.250.22) with ESMTP id 678CAE4200006C45; Sun, 19 Jan 2025 15:48:21 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 2613197602596 X-SMAIL-UIID: E3AA4D3C9A7047C7895F68DE411C11B5-20250119-154821-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [bluetooth?] [wireless?] WARNING in free_netdev (2) Date: Sun, 19 Jan 2025 15:48:07 +0800 Message-ID: <20250119074808.2137-1-hdanton@sina.com> In-Reply-To: <678add43.050a0220.303755.0016.GAE@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 17 Jan 2025 14:44:19 -0800 > syzbot found the following issue on: > > HEAD commit: 8d20dcda404d selftests: drv-net-hw: inject pp_alloc_fail e.. > git tree: net-next > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13ffc2b0580000 #syz test diff -pur p/include/linux/netdevice.h q/include/linux/netdevice.h --- p/include/linux/netdevice.h 2025-01-19 14:23:21.962713400 +0800 +++ q/include/linux/netdevice.h 2025-01-19 14:44:32.303599900 +0800 @@ -2047,6 +2047,7 @@ enum netdev_reg_state { * FIXME: cleanup struct net_device such that network protocol info * moves out. */ +extern unsigned long extra_netdev_locks; struct net_device { /* Cacheline organization can be found documented in diff -pur p/net/core/dev.c q/net/core/dev.c --- p/net/core/dev.c 2025-01-19 14:26:04.863348200 +0800 +++ q/net/core/dev.c 2025-01-19 15:43:55.326734000 +0800 @@ -10269,14 +10269,19 @@ static bool from_cleanup_net(void) #endif } +unsigned long extra_netdev_locks = 0; static void rtnl_drop_if_cleanup_net(void) { + if (extra_netdev_locks) + return; if (from_cleanup_net()) __rtnl_unlock(); } static void rtnl_acquire_if_cleanup_net(void) { + if (extra_netdev_locks) + return; if (from_cleanup_net()) rtnl_lock(); } @@ -11606,8 +11611,6 @@ void free_netdev(struct net_device *dev) return; } - mutex_destroy(&dev->lock); - kfree(dev->ethtool); netif_free_tx_queues(dev); netif_free_rx_queues(dev); diff -pur p/net/wireless/core.c q/net/wireless/core.c --- p/net/wireless/core.c 2025-01-19 14:29:30.497265000 +0800 +++ q/net/wireless/core.c 2025-01-19 14:40:07.687903000 +0800 @@ -1247,8 +1247,11 @@ static void _cfg80211_unregister_wdev(st if (wdev->netdev) { sysfs_remove_link(&wdev->netdev->dev.kobj, "phy80211"); - if (unregister_netdev) + if (unregister_netdev) { + extra_netdev_locks++; unregister_netdevice(wdev->netdev); + extra_netdev_locks--; + } } list_del_rcu(&wdev->list); --