(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

xfrm: Check netif_is_alive() in xfrm_bundle_create() and xfrm_create_dummy_bundle().

struct dst_entry passed to xfrm_bundle_create() and xfrm_create_dummy_bundle() could outlive synchronize_net() in unregister_netdevice_many_notify(). For example, ip_route_output_flow() calls __ip_route_output_key() to fetch a dst under RCU, but calls xfrm_lookup_route() outside of that RCU critical section. Thus, xfrm_fill_dst() could add a new uncached route after the first NETDEV_UNREGISTER notification and rely on the rebroadcast in netdev_wait_allrefs_any(). The following patches will move the uncached route flush for dying netdev from the NETDEV_UNREGISTER handler to netdev_run_todo(), where the rebroadcast is also skipped due to dev->dismantle, making such late additions problematic. Let's check netif_is_alive() after fetching dst_dev_rcu(dst) under RCU. This ensures that xfrm either finishes adding the uncached route before synchronize_net() or fails with -ENODEV. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Tested-by: Chris J Arges <carges@cloudflare.com> Link: https://patch.msgid.link/20261001204752.2572265-5-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>


Author Kuniyuki Iwashima Committer Jakub Kicinski Date Commit Parent 2e65372a
+2 -2
1 changed file
+2 -2
1 changed file