net: fix dst->dev lifetime races
Get series with b4
b4 am [email protected]Versions newest first
- v2 Latest4 patches 0 repliesNew
Changes in v2 from the cover letter
- Combine the separate IPv4 and IPv6 submissions into one series, as requested by Ido and Kuniyuki.
- Add the post-flush synchronize_net() patch suggested by Ido.
- Add the ip6_dst_neigh_lookup() patch suggested by Ido.
- Distinguish the dynamically reproduced findings from the source-inspection findings and document the validation limits.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | net: wait for RCU readers after flushing routesnet/ | +1 | 0 replies | |
| 2/4 | ipv4: route: fix use-after-free in ipv4_confirm_neigh()net/ | +9 | 0 replies | |
| 3/4 | ipv6: route: fix use-after-free in ip6_confirm_neigh()net/ | +9 | 0 replies | |
| 4/4 | ipv6: route: fix use-after-free in ip6_dst_neigh_lookup()net/ | +9 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH net v2 0/4] net: fix dst->dev lifetime races
The conversion of dst->dev to an RCU-protected pointer left two route confirmation callbacks and the IPv6 neighbour lookup callback loading it without RCU protection. Also, netdev_run_todo() did not wait for readers after flushing routes that can release the last dst-held device reference.
Patch 1 adds the teardown-side grace period after the route flushes. Patches 2 and 3 protect the IPv4 and IPv6 confirmation callbacks. Patch 4 protects the IPv6 neighbour lookup callback, matching its IPv4 counterpart.
Finding and validation:
- Patches 2 and 3 came from an AI-assisted source audit. Delay-assisted KASAN runs on the exact v7.4-rc3 commit reproduced both bugs:
BUG: KASAN: slab-use-after-free in ipv4_confirm_neigh+0xcc8/0xce0
BUG: KASAN: slab-use-after-free in ip6_confirm_neigh+0x6a7/0xbd0The delay was debug-only window amplification and is not in this series.
- Ido identified the missing grace period in patch 1 and the unprotected lookup in patch 4 during review. Both were validated by source inspection; those two windows have not been triggered independently at runtime.
Testing:
- KASAN reruns on v7.4-rc2 with the callback fixes corresponding to patches 2 and 3 completed without a report. The IPv4 run made 392065 callback calls across 110 dst_dev_put() calls and 48 device frees. The IPv6 run made 13144 callback calls across 36 dst_dev_put() calls and 48 device frees.
- On the current net tree base below, these objects built with W=1:
net/core/dev.o, net/ipv4/route.o, and net/ipv6/route.o.
- A full allmodconfig or allyesconfig build and networking selftests were not run.
This is treated as a regular bug: the demonstrated teardown needs privileged network-device administration, and no privilege-boundary crossing or exploit has been demonstrated.
Changes since v1:
- Combine the separate IPv4 and IPv6 submissions into one series, as requested by Ido and Kuniyuki.
- Add the post-flush synchronize_net() patch suggested by Ido.
- Add the ip6_dst_neigh_lookup() patch suggested by Ido.
- Distinguish the dynamically reproduced findings from the source-inspection findings and document the validation limits.
v1 IPv6:
https://lore.kernel.org/netdev/[email protected]/
v1 IPv4:
https://lore.kernel.org/netdev/[email protected]/
Review:
https://lore.kernel.org/netdev/20261125190113.GA421469@shredder/
AI assistance disclosure: Codex was used for the source audit, test-harness automation, patch drafting, and changelog drafting. The runtime results above come from the described QEMU/KASAN runs. The Signed-off-by tags were added at the submitter's explicit request.
Zhou Qiuyue (4):
net: wait for RCU readers after flushing routes
ipv4: route: fix use-after-free in ipv4_confirm_neigh()
ipv6: route: fix use-after-free in ip6_confirm_neigh()
ipv6: route: fix use-after-free in ip6_dst_neigh_lookup()
net/core/dev.c | 1 + net/ipv4/route.c | 12 +++++++++--- net/ipv6/route.c | 24 ++++++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-)
base-commit: e1055cbfd6eb578417f3ce983cf44462e8465267
Signature · 1 line
2.56.1.windows.1