Skip to content

Wait for route RCU callbacks in homa_peer_free_net - #144

Open
randomizedcoder wants to merge 1 commit into
PlatformLab:mainfrom
randomizedcoder:fix/peer-free-net-rcu-barrier
Open

randomizedcoder wants to merge 1 commit into
PlatformLab:mainfrom
randomizedcoder:fix/peer-free-net-rcu-barrier

Conversation

@randomizedcoder

Copy link
Copy Markdown
Contributor

Bug: homa_peer_free_net releases routes with call_rcu(homa_route_free), and the callback dereferences route->key.hnet. hnet is pernet data, which cleanup_net frees right after .exit returns and before its own rcu_barrier. That is a use-after-free when a namespace that carried Homa traffic is deleted, and also on rmmod (unregister_pernet_subsys frees the init_net hnet the same way). It came in with 8db9f5e (routes).

Fix: call rcu_barrier() at the end of homa_peer_free_net, after dropping the lock.

Found: by the nix microVM smoke test (ip netns del after GRO traffic). On 7.3 under load: GPF in homa_route_free from rcu_do_batch in 3 of 8 runs.

Verified:

unpatched patched
VM, init_on_free=1, 6.12 + 7.3 8/8 oops in homa_route_free 8/8 pass
VM matrix (2 smoke + 4 two-VM pairs, rmmod after traffic) 6/6 oops in homa_route_free 6/6 pass
unit homa_peer_free_net__wait_for_rcu_callbacks fail pass (885/885, plus --ipv4)

The 7.3 build is clean both normal and __STRIP__=1, and checkpatch is clean.

🤖 Generated with Claude Code

homa_peer_free_net releases each route in the namespace with
call_rcu(homa_route_free), and homa_route_free dereferences
route->key.hnet to find the peertab. But hnet is the pernet data for
the namespace, which cleanup_net frees right after the exit methods
return (its rcu_barrier comes later). A callback that runs after that
reads freed memory.

Found by deleting network namespaces that had carried Homa traffic, in
a VM: with init_on_free=1 every run oopsed in homa_route_free (6.12 and
7.3); without it, 3 of 8 runs on 7.3 hit a general protection fault
there under load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
randomizedcoder added a commit to randomizedcoder/HomaModule that referenced this pull request Oct 31, 2026
…rmLab#148)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant