CVE-2025-37786 net: dsa: free routing table on probe failure
- Published
- Updated
- Exploit status
- No public exploit known
- Technology
- Linux KernelUbuntuDebian
Description
In the Linux kernel, the following vulnerability has been resolved:
net: dsa: free routing table on probe failure
If complete = true in dsa_tree_setup(), it means that we are the last
switch of the tree which is successfully probing, and we should be
setting up all switches from our probe path.
After "complete" becomes true, dsa_tree_setup_cpu_ports() or any
subsequent function may fail. If that happens, the entire tree setup is
in limbo: the first N-1 switches have successfully finished probing
(doing nothing but having allocated persistent memory in the tree's
dst->ports, and maybe dst->rtable), and switch N failed to probe, ending
the tree setup process before anything is tangible from the user's PoV.
If switch N fails to probe, its memory (ports) will be freed and removed
from dst->ports. However, the dst->rtable elements pointing to its ports,
as created by dsa_link_touch(), will remain there, and will lead to
use-after-free if dereferenced.
If dsa_tree_setup_switches() returns -EPROBE_DEFER, which is entirely
possible because that is where ds->ops->setup() is, we get a kasan
report like this:
==================================================================
BUG: KASAN: slab-use-after-free in mv88e6xxx_setup_upstream_port+0x240/0x568
Read of size 8 at addr ffff000004f56020 by task kworker/u8:3/42
Call trace:
__asan_report_load8_noabort+0x20/0x30
mv88e6xxx_setup_upstream_port+0x240/0x568
mv88e6xxx_setup+0xebc/0x1eb0
dsa_register_switch+0x1af4/0x2ae0
mv88e6xxx_register_switch+0x1b8/0x2a8
mv88e6xxx_probe+0xc4c/0xf60
mdio_probe+0x78/0xb8
really_probe+0x2b8/0x5a8
__driver_probe_device+0x164/0x298
driver_probe_device+0x78/0x258
__device_attach_driver+0x274/0x350
Allocated by task 42:
__kasan_kmalloc+0x84/0xa0
__kmalloc_cache_noprof+0x298/0x490
dsa_switch_touch_ports+0x174/0x3d8
dsa_register_switch+0x800/0x2ae0
mv88e6xxx_register_switch+0x1b8/0x2a8
mv88e6xxx_probe+0xc4c/0xf60
mdio_probe+0x78/0xb8
really_probe+0x2b8/0x5a8
__driver_probe_device+0x164/0x298
driver_probe_device+0x78/0x258
__device_attach_driver+0x274/0x350
Freed by task 42:
__kasan_slab_free+0x48/0x68
kfree+0x138/0x418
dsa_register_switch+0x2694/0x2ae0
mv88e6xxx_register_switch+0x1b8/0x2a8
mv88e6xxx_probe+0xc4c/0xf60
mdio_probe+0x78/0xb8
really_probe+0x2b8/0x5a8
__driver_probe_device+0x164/0x298
driver_probe_device+0x78/0x258
__device_attach_driver+0x274/0x350
The simplest way to fix the bug is to delete the routing table in its
entirety. dsa_tree_setup_routing_table() has no problem in regenerating
it even if we deleted links between ports other than those of switch N,
because dsa_link_touch() first checks whether the port pair already
exists in dst->rtable, allocating if not.
The deletion of the routing table in its entirety already exists in
dsa_tree_teardown(), so refactor that into a function that can also be
called from the tree setup error path.
In my analysis of the commit to blame, it is the one which added
dsa_link elements to dst->rtable. Prior to that, each switch had its own
ds->rtable which is freed when the switch fails to probe. But the tree
is potentially persistent memory.
Upgrade path
12 packages: 10 fixed, 2 with no fix yet.
| Package | Affected | Fixed in | Status |
|---|---|---|---|
| cbl-mariner kernel(CBL-Mariner 2.0) | All versions | No fix listed | No fix yet |
| Microsoft cbl2 kernel 5.15.202.1-1 | All versions | No fix listed | No fix yet |
| azure linux kernel(Azure Linux 3.0) | < 6.6.92.2-1 | 6.6.92.2-1 | Fixed |
| debian/linux(Debian 12) | < 6.1.164-1; = 6.1.27-1; = 6.1.37-1; = 6.1.38-1 +44 more | 6.1.164-1 | Fixed |
| debian/linux(Debian 13) | < 6.12.25-1 | 6.12.25-1 | Fixed |
| debian/linux(Debian 14) | < 6.12.25-1 | 6.12.25-1 | Fixed |
| Linux kernel | < 5.15.201; < 6.1.164; < 6.6.88; < 6.12.25 +14 more | 5.15.201, 5c8066fbdb9653c6e9a224bdcd8f9c91a484f0de, 6.1.164, 6.6.88, 6.12.25, 6.14.4, 6.15, 6c20894d21600ca1e8549086dfbb986e277bf8a6, 8bf108d7161ffc6880ad13a0cc109de3cf631727, 51df5513cca6349d0bea01bab95cd96cf869976e, a038f5f15af455dfe35bc68549e02b950978700a, fb12b460ec46c9efad98de6d9ba349691db51dc7 | Fixed |
| ubuntu/linux(Ubuntu 22.04) | < 5.15.0-186.196 | 5.15.0-186.196 | Fixed |
| ubuntu/linux(Ubuntu 24.04) | < 6.8.0-100.100 | 6.8.0-100.100 | Fixed |
| ubuntu/linux-kvm(Ubuntu 22.04) | < 5.15.0-1104.109 | 5.15.0-1104.109 | Fixed |
| ubuntu/linux-raspi(Ubuntu 22.04) | < 5.15.0-1106.109 | 5.15.0-1106.109 | Fixed |
| ubuntu/linux-raspi(Ubuntu 24.04) | < 6.8.0-1047.51 | 6.8.0-1047.51 | Fixed |
Affected products
| Product | Affected versions | Fixed in |
|---|---|---|
| azure linux kernel(Azure Linux:3.0) | < 6.6.92.2-1 | 6.6.92.2-1 |
| cbl-mariner kernel(CBL-Mariner:2.0) | All versions | No fix listed |
| Microsoft cbl2 kernel 5.15.202.1-1 | All versions | No fix listed |
| debian/linux(Debian:12) | < 6.1.164-1 | 6.1.164-1 |
| debian/linux(Debian:12) | = 6.1.106-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.106-2 | No fix listed |
| debian/linux(Debian:12) | = 6.1.106-3 | No fix listed |
| debian/linux(Debian:12) | = 6.1.112-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.115-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.119-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.123-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.124-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.128-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.129-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.133-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.135-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.137-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.139-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.140-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.147-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.148-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.153-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.158-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.159-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.162-1 | No fix listed |
Show 51 more
| Product | Affected versions | Fixed in |
|---|---|---|
| debian/linux(Debian:12) | = 6.1.27-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.37-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-2 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-2~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-3 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-4 | No fix listed |
| debian/linux(Debian:12) | = 6.1.38-4~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.52-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.55-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.55-1~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.64-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.66-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.67-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.69-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.69-1~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.76-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.76-1~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.82-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.85-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.90-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.90-1~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.94-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.94-1~bpo11+1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.98-1 | No fix listed |
| debian/linux(Debian:12) | = 6.1.99-1 | No fix listed |
| debian/linux(Debian:13) | < 6.12.25-1 | 6.12.25-1 |
| debian/linux(Debian:14) | < 6.12.25-1 | 6.12.25-1 |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < 51df5513cca6349d0bea01bab95cd96cf869976e | 51df5513cca6349d0bea01bab95cd96cf869976e |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < 6c20894d21600ca1e8549086dfbb986e277bf8a6 | 6c20894d21600ca1e8549086dfbb986e277bf8a6 |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < fb12b460ec46c9efad98de6d9ba349691db51dc7 | fb12b460ec46c9efad98de6d9ba349691db51dc7 |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < 5c8066fbdb9653c6e9a224bdcd8f9c91a484f0de | 5c8066fbdb9653c6e9a224bdcd8f9c91a484f0de |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < a038f5f15af455dfe35bc68549e02b950978700a | a038f5f15af455dfe35bc68549e02b950978700a |
| Linux kernel | >= c5f51765a1f60b701840544faf3ca63204b8dc3c, < 8bf108d7161ffc6880ad13a0cc109de3cf631727 | 8bf108d7161ffc6880ad13a0cc109de3cf631727 |
| Linux kernel | = 5.5 | No fix listed |
| Linux kernel | < 5.15.201 | 5.15.201 |
| Linux kernel | < 6.1.164 | 6.1.164 |
| Linux kernel | < 6.6.88 | 6.6.88 |
| Linux kernel | < 6.12.25 | 6.12.25 |
| Linux kernel | < 6.14.4 | 6.14.4 |
| Linux kernel | < 6.15 | 6.15 |
| ubuntu/linux(Ubuntu:22.04) | < 5.15.0-186.196 | 5.15.0-186.196 |
| ubuntu/linux-kvm(Ubuntu:22.04) | < 5.15.0-1104.109 | 5.15.0-1104.109 |
| ubuntu/linux-raspi(Ubuntu:22.04) | < 5.15.0-1106.109 | 5.15.0-1106.109 |
| ubuntu/linux(Ubuntu:24.04) | < 6.8.0-100.100 | 6.8.0-100.100 |
| ubuntu/linux-raspi(Ubuntu:24.04) | < 6.8.0-1047.51 | 6.8.0-1047.51 |
| Linux kernel | >= 5.5, < 6.6.88 | 6.6.88 |
| Linux kernel | >= 6.7, < 6.12.25 | 6.12.25 |
| Linux kernel | >= 6.13, < 6.14.4 | 6.14.4 |
| Linux kernel | = 6.15-rc1 | No fix listed |
| Linux kernel | = 6.15-rc2 | No fix listed |
References
- MSRC Security Update Guide vendor-advisory
- CBL-Mariner Releases vendor-advisory
- Debian Security Tracker CVE-2025-37786 vendor-advisory
- git.kernel.org patch
- git.kernel.org patch
- git.kernel.org patch
- git.kernel.org patch
- git.kernel.org patch
- git.kernel.org patch
- Ubuntu CVE tracker vendor-advisory
- USN-7594-1 vendor-advisory
- USN-7594-2 vendor-advisory
- USN-7594-3 vendor-advisory
- USN-8028-1 vendor-advisory
- USN-8028-2 vendor-advisory
- USN-8031-1 vendor-advisory
- USN-8028-3 vendor-advisory
- USN-8028-4 vendor-advisory
- USN-8028-5 vendor-advisory
- USN-8031-2 vendor-advisory
- USN-8028-6 vendor-advisory
- USN-8031-3 vendor-advisory
- USN-8052-1 vendor-advisory
- USN-8028-7 vendor-advisory
- USN-8028-8 vendor-advisory
- USN-8052-2 vendor-advisory
- USN-8074-1 vendor-advisory
- USN-8074-2 vendor-advisory
- USN-8126-1 vendor-advisory
- USN-8575-1 vendor-advisory
- USN-8576-1 vendor-advisory
- USN-8575-2 vendor-advisory
- USN-8576-2 vendor-advisory
- USN-8575-3 vendor-advisory
- USN-8610-1 vendor-advisory
- USN-8620-1 vendor-advisory
- USN-8620-2 vendor-advisory
- USN-8620-3 vendor-advisory
- USN-8620-4 vendor-advisory
- USN-8668-1 vendor-advisory
- USN-8668-2 vendor-advisory
- www.cve.org