From nobody Mon May 12 05:15:39 2025
Received: from ksmg01.maxima.ru (ksmg01.maxima.ru [81.200.124.38])
	(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 9886024169D;
	Thu,  3 Apr 2025 08:20:44 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=81.200.124.38
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743668448; cv=none;
 b=njDI6c5W0cun9OxxTzJzReIZAgg5DIDY6sofbZNPd8/uOac2LfZmR2EYJ+kSHk16Hr62T5xdDEMJkZb+CWT02EA9vthewDnI8t3Lia5wIUSK6e1PYpjrgjUNX+Y1F4KyqTSkouF4ggSaRQ00pTgSMijBwK9U8hEd+RGbEvvSSM8=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743668448; c=relaxed/simple;
	bh=SB7Kn52oYQ248jEmcpDOI//T3/m6hPEZlOSJZ2uEp+A=;
	h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Type;
 b=Q1A3MGGebZPdLliPF7yruTc4uBdsQHYP6O3dmkg2M6j3gHA1HvInIunucbr698mp5teK37NCgKoTDdxZExgeRTmUfsWhDxKJy/LbcgvRcLN9ipTT3ccf4xV0dBUlJ728ewzpWz7APv+TzCVBg90a3ChPu21dEv/yGLFgHhJcSPo=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=mt-integration.ru;
 spf=pass smtp.mailfrom=mt-integration.ru;
 dkim=pass (2048-bit key) header.d=mt-integration.ru
 header.i=@mt-integration.ru header.b=RfB3VLRT;
 arc=none smtp.client-ip=81.200.124.38
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=mt-integration.ru
Authentication-Results: smtp.subspace.kernel.org;
 spf=pass smtp.mailfrom=mt-integration.ru
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=mt-integration.ru
 header.i=@mt-integration.ru header.b="RfB3VLRT"
Received: from ksmg01.maxima.ru (localhost [127.0.0.1])
	by ksmg01.maxima.ru (Postfix) with ESMTP id 5F5EDC001E;
	Thu,  3 Apr 2025 11:20:42 +0300 (MSK)
DKIM-Filter: OpenDKIM Filter v2.11.0 ksmg01.maxima.ru 5F5EDC001E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mt-integration.ru;
	s=sl; t=1743668442; bh=fooqjpgdl4KPLJhSgTy90MCWqkARgoelhKCc0ecb9V8=;
	h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From;
	b=RfB3VLRT6NkOcpK2wDkP7IVZTIf68Iz7/eiU26ppbOgEXB9NsffT5Qc3gf0qFbVJV
	 QeooItlcfE3IIML6crna89MORBFUxvI3Rwqy8UdCnI+OGa/idN0Z5zOhUtGex/Cbz2
	 ll2IHeYOS4eYduXbWQkF5/nDePlBwNLkCF544lXi8LS6U1Y8VnAq+GUdB85Tu4wBtD
	 ptPJnxh5hStN7FH9fXwxYx6RzKYxNVEZvd+VtYETLtdI1xVjEPqSvCjjGVON+DxZrz
	 0VL5kFLLK7xbavxrCSomPn9CJ0C0I+Tit3ib+APpBOSfdoAJk462b0aPn8HcLTiI+o
	 xjRHYPAbuaung==
Received: from ksmg01.maxima.ru (autodiscover.maxima.ru [81.200.124.61])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "*.maxima.ru",
 Issuer "GlobalSign GCC R3 DV TLS CA 2020" (verified OK))
	by ksmg01.maxima.ru (Postfix) with ESMTPS;
	Thu,  3 Apr 2025 11:20:42 +0300 (MSK)
Received: from db126-1-abramov-14-d-mosos.mti-lab.com (172.25.20.118) by
 mmail-p-exch01.mt.ru (81.200.124.61) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1544.4; Thu, 3 Apr 2025 11:20:41 +0300
From: Ivan Abramov <i.abramov@mt-integration.ru>
To: Alexander Aring <alex.aring@gmail.com>
CC: Ivan Abramov <i.abramov@mt-integration.ru>,
	<syzbot+e0bd4e4815a910c0daa8@syzkaller.appspotmail.com>, Stefan Schmidt
	<stefan@datenfreihafen.org>, Miquel Raynal <miquel.raynal@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon
 Horman <horms@kernel.org>, <linux-wpan@vger.kernel.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lvc-project@linuxtesting.org>
Subject: [PATCH net v2 2/3] ieee802154: Avoid calling WARN_ON() on -ENOMEM in
 cfg802154_switch_netns()
Date: Thu, 3 Apr 2025 11:20:20 +0300
Message-ID: <20250403082021.990667-3-i.abramov@mt-integration.ru>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250403082021.990667-1-i.abramov@mt-integration.ru>
References: <20250403082021.990667-1-i.abramov@mt-integration.ru>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-ClientProxiedBy: mmail-p-exch02.mt.ru (81.200.124.62) To
 mmail-p-exch01.mt.ru (81.200.124.61)
X-KSMG-AntiPhishing: NotDetected, bases: 2025/04/03 06:59:00
X-KSMG-AntiSpam-Auth: dmarc=none header.from=mt-integration.ru;spf=none
 smtp.mailfrom=mt-integration.ru;dkim=none
X-KSMG-AntiSpam-Envelope-From: i.abramov@mt-integration.ru
X-KSMG-AntiSpam-Info: LuaCore: 54 0.3.54
 464169e973265e881193cca5ab7aa5055e5b7016, {rep_avail},
 {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to},
 81.200.124.61:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;ksmg01.maxima.ru:7.1.1;127.0.0.199:7.1.2;lore.kernel.org:7.1.1;mt-integration.ru:7.1.1,
 FromAlignment: s, ApMailHostAddress: 81.200.124.61
X-KSMG-AntiSpam-Interceptor-Info: scan successful
X-KSMG-AntiSpam-Lua-Profiles: 192326 [Apr 03 2025]
X-KSMG-AntiSpam-Method: none
X-KSMG-AntiSpam-Rate: 0
X-KSMG-AntiSpam-Status: not_detected
X-KSMG-AntiSpam-Version: 6.1.1.11
X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.1.8310,
 bases: 2025/04/03 03:59:00 #27851158
X-KSMG-AntiVirus-Status: NotDetected, skipped
X-KSMG-LinksScanning: NotDetected, bases: 2025/04/03 06:59:00
X-KSMG-Message-Action: skipped
X-KSMG-Rule-ID: 7
Content-Type: text/plain; charset="utf-8"

It's pointless to call WARN_ON() in case of an allocation failure in
dev_change_net_namespace() and device_rename(), since it only leads to
useless splats caused by deliberate fault injections, so avoid it.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Reported-by: syzbot+e0bd4e4815a910c0daa8@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/000000000000f4a1b7061f9421de@google.=
com/#t
Fixes: 66e5c2672cd1 ("ieee802154: add netns support")
Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
---
v2: Add Reported-by and Closes tags as per Kuniyuki Iwashima's observation.
Make sure to commit against latest netdev/net.

 net/ieee802154/core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index 84d514430e45..987c633e2c54 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -228,8 +228,10 @@ int cfg802154_switch_netns(struct cfg802154_registered=
_device *rdev,
 			continue;
 		wpan_dev->netdev->netns_immutable =3D false;
 		err =3D dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d");
-		if (err)
+		if (err) {
+			WARN_ON(err && err !=3D -ENOMEM);
 			break;
+		}
 		wpan_dev->netdev->netns_immutable =3D true;
 	}
=20
@@ -237,7 +239,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_=
device *rdev,
 		goto errout;
=20
 	err =3D device_rename(&rdev->wpan_phy.dev, dev_name(&rdev->wpan_phy.dev));
-	WARN_ON(err);
+	WARN_ON(err && err !=3D -ENOMEM);
=20
 	if (err)
 		goto errout;
@@ -258,7 +260,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_=
device *rdev,
 		wpan_dev->netdev->netns_immutable =3D false;
 		err =3D dev_change_net_namespace(wpan_dev->netdev, net,
 					       "wpan%d");
-		WARN_ON(err);
+		WARN_ON(err && err !=3D -ENOMEM);
 		wpan_dev->netdev->netns_immutable =3D true;
 	}
=20
--=20
2.39.5