From: Roman Gushchin <roman.gushchin@linux.dev>
To: alex.aring@gmail.com, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com
Cc: horms@kernel.org, netdev@vger.kernel.org,
linux-wpan@vger.kernel.org, linux-bluetooth@vger.kernel.org,
linux-kernel@vger.kernel.org,
Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH net] 6lowpan: fix netdev_priv() type confusion in lowpan_event()
Date: Fri, 6 Nov 2026 22:59:30 +0000 [thread overview]
Message-ID: <20261106225930.1379968-1-roman.gushchin@linux.dev> (raw)
lowpan_event() assumes any netdevice with dev->type == ARPHRD_6LOWPAN
has a struct lowpan_dev in netdev_priv(dev). However, non-6LoWPAN
devices can also have ARPHRD_6LOWPAN, e.g. a TUN device via TUNSETLINK
or a bonding device inheriting dev->type from its lower device.
Bringing such a device up or down causes lowpan_event() to read and
overwrite unrelated netdev_priv() memory. Since unprivileged users can
create TUN and bonding devices in a user and network namespace, they
can corrupt struct bonding and trigger a slab use-after-free.
Also check dev->ndisc_ops == &lowpan_ndisc_ops, which is set only by
lowpan_register_netdevice() on genuine 6LoWPAN devices.
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Fixes: 5609c185f24d ("6lowpan: iphc: add support for stateful compression")
Fixes: 2ad3ed59198c ("6lowpan: add 802.15.4 short addr slaac")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-97b284e0-576e-4373-b62f-eb132f482b91
---
net/6lowpan/6lowpan_i.h | 13 ++++++++++---
net/6lowpan/core.c | 2 +-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/net/6lowpan/6lowpan_i.h b/net/6lowpan/6lowpan_i.h
index 01853cec0209..07f11d4dde6e 100644
--- a/net/6lowpan/6lowpan_i.h
+++ b/net/6lowpan/6lowpan_i.h
@@ -2,19 +2,26 @@
#ifndef __6LOWPAN_I_H
#define __6LOWPAN_I_H
+#include <linux/if_arp.h>
#include <linux/netdevice.h>
#include <net/6lowpan.h>
-/* caller need to be sure it's dev->type is ARPHRD_6LOWPAN */
+extern const struct ndisc_ops lowpan_ndisc_ops;
+
+static inline bool lowpan_is_dev(const struct net_device *dev)
+{
+ return dev->type == ARPHRD_6LOWPAN &&
+ dev->ndisc_ops == &lowpan_ndisc_ops;
+}
+
+/* caller must ensure lowpan_is_dev(dev) is true */
static inline bool lowpan_is_ll(const struct net_device *dev,
enum lowpan_lltypes lltype)
{
return lowpan_dev(dev)->lltype == lltype;
}
-extern const struct ndisc_ops lowpan_ndisc_ops;
-
int addrconf_ifid_802154_6lowpan(u8 *eui, struct net_device *dev);
#ifdef CONFIG_6LOWPAN_DEBUGFS
diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 850d4a185f55..748103d37e31 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -113,7 +113,7 @@ static int lowpan_event(struct notifier_block *unused,
struct in6_addr addr;
int i;
- if (dev->type != ARPHRD_6LOWPAN)
+ if (!lowpan_is_dev(dev))
return NOTIFY_DONE;
idev = __in6_dev_get(dev);
--
2.56.0.455.g6c5a503b38-goog
next reply other threads:[~2026-11-06 22:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 22:59 Roman Gushchin [this message]
2026-11-06 23:02 ` netdev-bot+sinfo
2026-11-06 23:10 ` Roman Gushchin
2026-11-06 23:50 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106225930.1379968-1-roman.gushchin@linux.dev \
--to=roman.gushchin@linux.dev \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®