Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 0/4] net: fix dst->dev lifetime races
@ 2026-11-27  4:38 Zhou Qiuyue
  2026-11-27  4:03 ` [PATCH net v2 1/4] net: wait for RCU readers after flushing routes Zhou Qiuyue
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zhou Qiuyue @ 2026-11-27  4:38 UTC (permalink / raw)
  To: netdev
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Willem de Bruijn,
	Kuniyuki Iwashima, Hangbin Liu

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/0xbd0

  The 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/20261123133000.1.n0ps1edzz@gmail.com/
v1 IPv4:
https://lore.kernel.org/netdev/20261123133000.2.n0ps1edzz@gmail.com/
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
-- 
2.56.1.windows.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-27  5:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  4:38 [PATCH net v2 0/4] net: fix dst->dev lifetime races Zhou Qiuyue
2026-11-27  4:03 ` [PATCH net v2 1/4] net: wait for RCU readers after flushing routes Zhou Qiuyue
2026-11-27  4:03 ` [PATCH net v2 2/4] ipv4: route: fix use-after-free in ipv4_confirm_neigh() Zhou Qiuyue
2026-11-27  4:03 ` [PATCH net v2 3/4] ipv6: route: fix use-after-free in ip6_confirm_neigh() Zhou Qiuyue
2026-11-27  4:03 ` [PATCH net v2 4/4] ipv6: route: fix use-after-free in ip6_dst_neigh_lookup() Zhou Qiuyue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox