Article View: linux.kernel.netdev
Article #9657Re: [PATCH] ieee802154: nl-mac: validate device pointers before dereference
From: Andrew Lunn
Date: Mon, 02 Nov 2026 14:00
Date: Mon, 02 Nov 2026 14:00
97 lines
12175 bytes
12175 bytes
On Mon, Nov 02, 2026 at 08:17:21AM +0530, Kalpesh Solanki wrote:
> On Mon, Nov 02, 2026 at 01:13:xx +0100, Andrew Lunn wrote:
> > Did you consider the other fix? Is there a use case for setting a TUN
> > interface to ARPHRD_IEEE802154? If not, maybe return EOPNOTSUPP, or
> > EINVAL?
> >
> > Andrew
>
> Hi Andrew,
>
> Thanks for reviewing and raising this point!
>
> Regarding whether there is a use case for setting a TUN interface to
> ARPHRD_IEEE802154:
> In real hardware/subsystem usage, virtual 802.15.4 interfaces are typically
> handled via mac802154_hwsim or fakelb (which properly allocate wpan_phy and
> dev->ieee802154_ptr), rather than raw TUN. However, tun.c explicitly recognizes
> ARPHRD_IEEE802154 and ARPHRD_IEEE802154_MONITOR in tun_get_addr_len():
>
> case ARPHRD_IEEE802154:
> case ARPHRD_IEEE802154_MONITOR:
> return IEEE802154_EXTENDED_ADDR_LEN;
I looked at the history. Those two were added along with a bunch of
other ARPHRD_ values. There is nothing i could see to indicate
IEEE802154 was a deliberate choice. So i think you need the IEEE802154
Maintainers to comment on if this is useful or not.
> 1. Subsystem robustness / Defense-in-depth:
> ieee802154_llsec_dump_table(), ieee802154_dump_iface(), and
> ieee802154_nl_get_dev() assumed that any netdevice in the namespace
> with dev->type == ARPHRD_IEEE802154 has valid ieee802154_ptr and
> mlme_ops. When that assumption fails, it triggers a NULL dereference
> while holding genl_mutex, leaving the mutex permanently locked and
> deadlocking generic netlink system-wide for unprivileged users.
Which is good. An Opps with a splat makes it clear there is a bug. If
anybody cares, it will get reported and fixed.
Subsystem robustness / Defense-in-depth generally results in bugs
being hidden, rather than exposed.
The fact ieee802154 has ieee802154_ptr and the code unconditionally
accesses it suggests it is actually needed. So the commit message in
your change needs to argue why TUN is special and does not need
it. The commit message is all about "Why?". Why did you decided to fix
it this way, rather than some other way.
Is the correct fix to actually set ieee802154_ptr to something?
> Other parts of the ieee802154 subsystem already make this defensive check:
> - net/ieee802154/6lowpan/core.c (lowpan_newlink):
> if (wdev->type != ARPHRD_IEEE802154 || !wdev->ieee802154_ptr)
> - net/ieee802154/socket.c:
> if (dev->type == ARPHRD_IEEE802154 && dev->ieee802154_ptr && ...)
>
> Guarding nl-mac.c ensures the IEEE 802.15.4 netlink handlers are safe
> regardless of how an ARPHRD_IEEE802154 device was created or modified.
Now look at the history of this. Does the commit message adding this
code suggest why these checks are there?
I also wondered if IEEE802154 is special? struct net_device has:
#if IS_ENABLED(CONFIG_VLAN_8021Q)
struct vlan_info __rcu *vlan_info;
#endif
#if IS_ENABLED(CONFIG_NET_DSA)
struct dsa_port *dsa_ptr;
#endif
#if IS_ENABLED(CONFIG_TIPC)
struct tipc_bearer __rcu *tipc_ptr;
#endif
#if IS_ENABLED(CONFIG_CFG80211)
struct wireless_dev *ieee80211_ptr;
#endif
#if IS_ENABLED(CONFIG_IEEE802154) || IS_ENABLED(CONFIG_6LOWPAN)
struct wpan_dev *ieee802154_ptr;
#endif
#if IS_ENABLED(CONFIG_MPLS_ROUTING)
struct mpls_dev __rcu *mpls_ptr;
#endif
#if IS_ENABLED(CONFIG_MCTP)
struct mctp_dev __rcu *mctp_ptr;
#endif
#if IS_ENABLED(CONFIG_INET_PSP)
struct psp_dev __rcu *psp_dev;
#endif
Did you look at all of these? Can any of them cause issues in the same
way as ieee802154_ptr?
Something you learn after a while. If you find a bug, look around and
see if the same bug exists close by, because it often does.
Andrew
Technical Details
Message-ID:
<3eba5c55-e1ec-4301-ae09-a3982090d8b0@lunn.ch>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354706-linux-kernel-netdev=dewy.ruReferences:
<20261101092219.1278751-1-skalpesh942@gmail.com> <20261102024721.28129-1-skalpesh942@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354706-linux-kernel-netdev=dewy.ru From: andrew@lunn.ch (Andrew Lunn) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] ieee802154: nl-mac: validate device pointers before dereference Date: Mon, 2 Nov 2026 15:00:11 +0100 Organization: Usenet Network Message-ID: <3eba5c55-e1ec-4301-ae09-a3982090d8b0@lunn.ch> References: <20261101092219.1278751-1-skalpesh942@gmail.com> <20261102024721.28129-1-skalpesh942@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2937656"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:PYGcrTRp/ST5qU5TDUX6CNT0as0= sha256:wTB/fTdoj9ljqcdIA5o2ZX0pmtWyEJl8ON7UZwRxaa0= sha1:9F4/IZoGrAKNcmVfeyZ+C0cAs6c= sha256:EhK8SiQpWstQUbGONfxr6oDWyiCo4ThlgW186t2CyXU= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A4BA411251B; Mon, 2 Nov 2026 17:07:10 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.15 X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=lunn.ch X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pxXTdnaXhqBP; Mon, 2 Nov 2026 17:07:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-354706-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 9A900112519; Mon, 2 Nov 2026 17:06:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id A779760752B; Mon, 2 Nov 2026 14:01:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793628029; b=msjgrJv2DCYb1XQbStmBAfmotMlrKKbiF3mHCDmQNk395j3lcjDVaxA6QCqKt+IQkFLf 0fH/PBentrVyVxZuQEeEL37umaVbJCMMOXXXGKm9w+fztZOKZ+Id16l1fT880Pg079OlM mbOr0/9HrJ+BQ6IHCAbtgkJLR7d9LDyVfw/ZKfZgmixWs7CuKMSB5m5rxHpnHC2r7nzQ0 HC59osZWhRMCXrJpAmqC6tVVf9H7XMoDoHMRkVBfSCMQe3rduag3cm66F47sqi192Njxo gRe3a4a4QUIw1tOe1j2Q6jPe++GFbqQli+SnqtImQQKBTlTLCjqoRlkY5J9LFbzuE8A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793628029; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date: From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=2pMvQgzqKW4JHpA5fJ7fTyK99AJQvYuqkYywOmupdlI=; b=lknEKs8tU8UWayF8gQCPRVPKsrp8k5+psilcdmkvMWYSQytUUIPA0Bci/18M2Ix7ilAR yL4zWiPvKW+c/CizFbMAH0FNoM+DWt1ev6uBiFmuWsSG9DEsSEkSpsuYyLqQ9s1UzdWBw 8B8MMzubRJe6jbzhTJucekzDK3ZTL0WxenZQXIzrO7Uvx2uWD8tW+0PhQ/VdrJRWexuxm 49I2KdNNoW/P84LomYyXfxAWusK4pIxuTvgUcRJsap7HCdUWb2gdjCCL4Ov52omGT7CFG 2wkOzF+Er0XLTMQgpw27Rgm0sh/T8NdHULLXlP0FwWdyxEzSZi+Ws6ZkYGuZhiO7aig== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=QzSZVLpB; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1825560A2621; Mon, 2 Nov 2026 14:00:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=QzSZVLpB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793628028; b=A+t79mEI8v9jthhAuClVgdQTV4Zp0sgp4wUmGGCKUCa5qPEpvAA+qOukdNkAiwb+qISa /wjxP4Lmvr479XT5ddL9qETg7xzpoMwMN6zcIEyY6KoQSKoKPgGYDbL5uRHNEH7u9k1V5 EY3bc47NXmBAmwFtFsw5I02O1Dd7gan5aTZGB/dWUON14ILklEtVfw0WfuGVAe97NuMnG Mbbm5TqJvn9XmctTGjkwhulgTyjPD8gPkvwnlaAPuATx5O2Zaiz9T3tEeV9+cvm1kBBPL Z7l+GVf+dIDt/2DN1KWrVxc6qtaQu6JhgsFFibSCVmBwRR4VRx93ySty3yVapo3lauA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793628028; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=2pMvQgzqKW4JHpA5fJ7fTyK99AJQvYuqkYywOmupdlI=; b=WwHgrCI8PeloCe891rRuVMUitYiOOLUMFnLVCZmu54fyujt25HEFxWa3GdGk1AC0lplj Xe5Xd5WCvAAyHKxWFRY/GzEi+8pDH7LF+8ziA1cFzX8VXxXCsrcldO3oULvMTlxddP9ay 2Ou7sOHunkqIMZ03j03A+Tr28TteNYYLsnXV9fh4lqshb7DDnscfrfJiZEG32HWNi0vvP Z4TjBM9+F/Wems44D849gVDG2W91/fLBdKYrvVG2XXKucHgZyAC2RK/FBIpLwZeggVKIY rgh0Xp/hVzdixmoCfjRswWRBoR4Sv03xQ0ApBc0xiF9rs6BXTcuvjDUU0kwGp8hw7SQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=QzSZVLpB; arc=none smtp.remote-ip=156.67.10.101 X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45CCE606A32F; Mon, 2 Nov 2026 14:00:27 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45CCE606A32F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=2pMvQgzqKW4JHpA5fJ7fTyK99AJQvYuqkYywOmupdlI=; b=QzSZVLpBZ+yBBFUabsSXv7RsM3 lC1XiEmly6EqfPxp77xnAF9C7vRLCMkcYwJZdX8cDftwTetzlIw8HTV3VPR9xsTRXzjEMO8prDBp5 U3E14cQTmztTvFGei7hyNLSYGAuVrbPgeQvJKZMsrpMVKq2JZiCx84JpBRf28fcEVlYs=; X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from <andrew@lunn.ch>) id 1xNsa3-00Dnuc-14; Mon, 02 Nov 2026 15:00:11 +0100 X-Cc: alex.aring@gmail.com, stefan@datenfreihafen.org, miquel.raynal@bootlin.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+9ea34da5ca6100593c90@syzkaller.appspotmail.com, stable@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261102024721.28129-1-skalpesh942@gmail.com>