Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BA8511F949 for ; Mon, 28 Jul 2025 11:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753701743; cv=none; b=ijRbCtnP+7vtVoSyaHGZiOKElxKS5XaFSFSqvuH0+e7YSxv5OEymsToZzQD1SJWHlDi2QxqOV1oAtW+vUyjHTBY2b3Z9P7gYViLLNRGZ2CRSm+am4AWRtx8EqEsYKeLyJbuG37zXqJJylb4FO3PYpFVXhSVrgE8ODKPc/s/eiEs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753701743; c=relaxed/simple; bh=ZoGQyRz1884ZybBtX23cLtMTa35Fh7YUMMuQovWH9cg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gR2X+M4Yjh6geUQZEZdYuXyVFMOJE6RcM7jNrbOMGT4Apl/Mh6d4QDIOIFKnPQP0vw10whRB6OB4ibNB8fbutf1gk60UNU0a1muIT++nkyxtpCLZbOPBopx4uL4OePrbdC6mr0lvYu0lepWpQpX7vPHec6qotgbXtU17NFimEVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ALTRCQS0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ALTRCQS0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 928D7C4CEE7; Mon, 28 Jul 2025 11:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753701743; bh=ZoGQyRz1884ZybBtX23cLtMTa35Fh7YUMMuQovWH9cg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ALTRCQS0RG/BPyQJdj46+93Hjx2Yv57gkNMGATIT5GDlKpayXp/3yKCtnxInK+dFY L3wKB5t9W9FMhdZAeOh6e3pec8uxgqtztRoe6sBWAm1LOhtvbnNMC9L/2zDdATzs54 S9VbBccE9EYyHLEp8tSpq547CHSCSyg2oocHItUM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38470: net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime Date: Mon, 28 Jul 2025 13:22:13 +0200 Message-ID: <2025072811-CVE-2025-38470-a4d4@gregkh> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=6935; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=qzU8hCg+zzkC0UCZ0ovnYLhLX+J5eb6nb1Q8gm1xAgw=; b=owGbwMvMwCRo6H6F97bub03G02pJDBntscnzNk6RlXt+kC/8I8vBxD1nXeqLm5aIzsyz+bxZ8 qrDV7/+jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjI2g0M8/2usm4QYPF4eHPL NkneG7syhU6u+ciwYP70n4p7OToWv/ZMcv8na6Vhwvw0EAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime Assuming the "rx-vlan-filter" feature is enabled on a net device, the 8021q module will automatically add or remove VLAN 0 when the net device is put administratively up or down, respectively. There are a couple of problems with the above scheme. The first problem is a memory leak that can happen if the "rx-vlan-filter" feature is disabled while the device is running: # ip link add bond1 up type bond mode 0 # ethtool -K bond1 rx-vlan-filter off # ip link del dev bond1 When the device is put administratively down the "rx-vlan-filter" feature is disabled, so the 8021q module will not remove VLAN 0 and the memory will be leaked [1]. Another problem that can happen is that the kernel can automatically delete VLAN 0 when the device is put administratively down despite not adding it when the device was put administratively up since during that time the "rx-vlan-filter" feature was disabled. null-ptr-unref or bug_on[2] will be triggered by unregister_vlan_dev() for refcount imbalance if toggling filtering during runtime: $ ip link add bond0 type bond mode 0 $ ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q $ ethtool -K bond0 rx-vlan-filter off $ ifconfig bond0 up $ ethtool -K bond0 rx-vlan-filter on $ ifconfig bond0 down $ ip link del vlan0 Root cause is as below: step1: add vlan0 for real_dev, such as bond, team. register_vlan_dev vlan_vid_add(real_dev,htons(ETH_P_8021Q),0) //refcnt=1 step2: disable vlan filter feature and enable real_dev step3: change filter from 0 to 1 vlan_device_event vlan_filter_push_vids ndo_vlan_rx_add_vid //No refcnt added to real_dev vlan0 step4: real_dev down vlan_device_event vlan_vid_del(dev, htons(ETH_P_8021Q), 0); //refcnt=0 vlan_info_rcu_free //free vlan0 step5: delete vlan0 unregister_vlan_dev BUG_ON(!vlan_info); //vlan_info is null Fix both problems by noting in the VLAN info whether VLAN 0 was automatically added upon NETDEV_UP and based on that decide whether it should be deleted upon NETDEV_DOWN, regardless of the state of the "rx-vlan-filter" feature. [1] unreferenced object 0xffff8880068e3100 (size 256): comm "ip", pid 384, jiffies 4296130254 hex dump (first 32 bytes): 00 20 30 0d 80 88 ff ff 00 00 00 00 00 00 00 00 . 0............. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 81ce31fa): __kmalloc_cache_noprof+0x2b5/0x340 vlan_vid_add+0x434/0x940 vlan_device_event.cold+0x75/0xa8 notifier_call_chain+0xca/0x150 __dev_notify_flags+0xe3/0x250 rtnl_configure_link+0x193/0x260 rtnl_newlink_create+0x383/0x8e0 __rtnl_newlink+0x22c/0xa40 rtnl_newlink+0x627/0xb00 rtnetlink_rcv_msg+0x6fb/0xb70 netlink_rcv_skb+0x11f/0x350 netlink_unicast+0x426/0x710 netlink_sendmsg+0x75a/0xc20 __sock_sendmsg+0xc1/0x150 ____sys_sendmsg+0x5aa/0x7b0 ___sys_sendmsg+0xfc/0x180 [2] kernel BUG at net/8021q/vlan.c:99! Oops: invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 0 UID: 0 PID: 382 Comm: ip Not tainted 6.16.0-rc3 #61 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:unregister_vlan_dev (net/8021q/vlan.c:99 (discriminator 1)) RSP: 0018:ffff88810badf310 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff88810da84000 RCX: ffffffffb47ceb9a RDX: dffffc0000000000 RSI: 0000000000000008 RDI: ffff88810e8b43c8 RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff6cefe80 R10: ffffffffb677f407 R11: ffff88810badf3c0 R12: ffff88810e8b4000 R13: 0000000000000000 R14: ffff88810642a5c0 R15: 000000000000017e FS: 00007f1ff68c20c0(0000) GS:ffff888163a24000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f1ff5dad240 CR3: 0000000107e56000 CR4: 00000000000006f0 Call Trace: rtnl_dellink (net/core/rtnetlink.c:3511 net/core/rtnetlink.c:3553) rtnetlink_rcv_msg (net/core/rtnetlink.c:6945) netlink_rcv_skb (net/netlink/af_netlink.c:2535) netlink_unicast (net/netlink/af_netlink.c:1314 net/netlink/af_netlink.c:1339) netlink_sendmsg (net/netlink/af_netlink.c:1883) ____sys_sendmsg (net/socket.c:712 net/socket.c:727 net/socket.c:2566) ___sys_sendmsg (net/socket.c:2622) __sys_sendmsg (net/socket.c:2652) do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94) The Linux kernel CVE team has assigned CVE-2025-38470 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.36 with commit ad1afb00393915a51c21b1ae8704562bf036855f and fixed in 6.1.147 with commit d43ef15bf4856c8c4c6c3572922331a5f06deb77 Issue introduced in 2.6.36 with commit ad1afb00393915a51c21b1ae8704562bf036855f and fixed in 6.6.100 with commit bb515c41306454937464da055609b5fb0a27821b Issue introduced in 2.6.36 with commit ad1afb00393915a51c21b1ae8704562bf036855f and fixed in 6.12.40 with commit 8984bcbd1edf5bee5be06ad771d157333b790c33 Issue introduced in 2.6.36 with commit ad1afb00393915a51c21b1ae8704562bf036855f and fixed in 6.15.8 with commit 93715aa2d80e6c5cea1bb486321fc4585076928b Issue introduced in 2.6.36 with commit ad1afb00393915a51c21b1ae8704562bf036855f and fixed in 6.16 with commit 579d4f9ca9a9a605184a9b162355f6ba131f678d Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-38470 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: net/8021q/vlan.c net/8021q/vlan.h Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/d43ef15bf4856c8c4c6c3572922331a5f06deb77 https://git.kernel.org/stable/c/bb515c41306454937464da055609b5fb0a27821b https://git.kernel.org/stable/c/8984bcbd1edf5bee5be06ad771d157333b790c33 https://git.kernel.org/stable/c/93715aa2d80e6c5cea1bb486321fc4585076928b https://git.kernel.org/stable/c/579d4f9ca9a9a605184a9b162355f6ba131f678d