From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384698; b=fcdby8zbzVH55zE0jyi/iI5t4O5mUCDvPgDip26PauN0gqnb7nGlRO7xD898/6sdBedD mT13fEDzeuI0JpesawC1Y/R5Xlurf/5b34X56vRhjjmtyJ11FztCNmhprmggDtYzpk5as P/4Ve2UpYLJmZUG8uSeZi+atLEynySObdXyH96nlm1OQW1NIxnEPpuSdXKk3MP9Y03mSn BNT8WP5I4UVc7pf2dzppx4jv8GmxXKJUhaHLJCOtwHjXagxPw9tFBxrtnHCybtk4cQ7/I bGI21aC7DYRZoRANVXR3NhTWZX6gygxICmmg2jfwaj3FvOecD5v6fvuy6j1MnKzB3Iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384698; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Mdzcf5u/EGTjTFETCV3Z6kYx7QnuZiO3ZtXyQlzPxQs=; b=jqbAOHWBnReaAeQ4ynK0/uEtqbeSV9uz+x1c0HuWqkzeymaC3ZrkXT+GD1HaqJeoL8W9 hmJpyFJ+xLqiF0BQj5GJSXiMyc+/QG9W4mrEVC9kXjnykCW5ac3JkSjPEugDNTkb2/JqQ NiwqAdjWMXq5JcQ/cG2i0bCGynsMmL78eYClhX9vPPtIdyoJhsVoeP3oCnw0GsyTs+CvK 9BDRUMFjO5jUgBfzHDCMuJZnlcf0WEOXYehOEn9upjECFc6yyeGD7R9HqzESN0UgydJCY AE45TRGO7kI66gPAwvjlJnrO/ke888V0xPHXcHzK0VnSJuddmZEX7neSFB0v0Qr+SGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YmTBIc9R; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7468606A681; Fri, 4 Dec 2026 11:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YmTBIc9R Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21EF41F000C2; Fri, 4 Dec 2026 11:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384698; bh=Mdzcf5u/EGTjTFETCV3Z6kYx7QnuZiO3ZtXyQlzPxQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YmTBIc9RksGZ03FeKcTgTWWVgKX8jQmaai2NiHew8mgdUlfPYTw4KuXEEghPKAFsx gM+0zezphFV/N4muzIbJxSbIZCP60oq3ROayW6sHT72YzEB+pejNX/2hQD0OVcdfn3 GH8HqyQfVesl61/CKfo2+eBwB7CJHUwoVrJ5A0dc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+9ea34da5ca6100593c90@syzkaller.appspotmail.com, Kalpesh Solanki , Willem de Bruijn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0255/1167] tun: disallow setting IEEE 802.15.4 and 6LoWPAN link types via TUNSETLINK Date: Fri, 4 Dec 2026 18:54:42 +0900 Message-ID: <20261204100708.706767898@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kalpesh Solanki [ Upstream commit 968f2b94a5964b75d9c0da84523e42530c1891f0 ] A userspace application can set the link type of a TUN/TAP interface to ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR, or ARPHRD_6LOWPAN via ioctl(fd, TUNSETLINK, arg) because tun_get_addr_len() explicitly recognized these types. However, TUN devices cannot function as genuine IEEE 802.15.4 or 6LoWPAN interfaces: 1. They lack wpan_phy, channels, PAN IDs, and MLME operations, and tun never initializes dev->ieee802154_ptr or dev->ml_priv. When an unprivileged user creates a TUN interface in a user+net namespace, changes its link type to ARPHRD_IEEE802154, and issues a netlink dump request (such as IEEE802154_LLSEC_LIST_KEY), ieee802154_llsec_dump_table() unconditionally dereferences dev->ieee802154_ptr / ieee802154_mlme_ops(dev), triggering a supervisor null-pointer dereference / general protection fault. Similar dereferences occur across net/ieee802154/nl-phy.c (ieee802154_del_iface) and net/ieee802154/socket.c. 2. Similarly, the 6LoWPAN subsystem assumes via lowpan_dev(dev) that netdev_priv(dev) is struct lowpan_dev. On a TUN device, netdev_priv(dev) is struct tun_struct. On netdev events (such as NETDEV_DOWN in net/6lowpan/core.c:lowpan_device_event), it clears bits in lowpan_dev(dev)->ctx.table flags, which corrupts private memory inside tun_struct. Rather than scattering checks across subsystems, fix the issue at the source: disallow setting ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR, and ARPHRD_6LOWPAN via TUNSETLINK by returning -EINVAL. Cast arg to unsigned short in the comparison to prevent upper-bit truncation bypasses (e.g. arg = ARPHRD_IEEE802154 | 0x10000). Fixes: ff4cc3ac93e1 ("[TUNTAP]: Allow setting the linktype of the tap device from userspace") Reported-by: syzbot+9ea34da5ca6100593c90@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=9ea34da5ca6100593c90 Signed-off-by: Kalpesh Solanki Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20261109083037.22337-1-skalpesh942@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/tun.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index df752791ecabd..e81a97944d7c9 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3261,6 +3261,10 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, netif_info(tun, drv, tun->dev, "Linktype set failed because interface is up\n"); ret = -EBUSY; + } else if ((unsigned short)arg == ARPHRD_IEEE802154 || + (unsigned short)arg == ARPHRD_IEEE802154_MONITOR || + (unsigned short)arg == ARPHRD_6LOWPAN) { + ret = -EINVAL; } else { ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, tun->dev); -- 2.53.0