]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rtnetlink: Protect struct rtnl_af_ops with SRCU.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 16 Oct 2024 18:53:57 +0000 (11:53 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 22 Oct 2024 09:02:05 +0000 (11:02 +0200)
commit6ab0f866948323724e95cf14d9e47fd77703c192
treee237cbc9f355ef692a274210fe667b5a9a1d00d1
parent26eebdc4b005ccd4cf63f4fef4c9c0adf9bfa380
rtnetlink: Protect struct rtnl_af_ops with SRCU.

Once RTNL is replaced with rtnl_net_lock(), we need a mechanism to
guarantee that rtnl_af_ops is alive during inflight RTM_SETLINK
even when its module is being unloaded.

Let's use SRCU to protect ops.

rtnl_af_lookup() now iterates rtnl_af_ops under RCU and returns
SRCU-protected ops pointer.  The caller must call rtnl_af_put()
to release the pointer after the use.

Also, rtnl_af_unregister() unlinks the ops first and calls
synchronize_srcu() to wait for inflight RTM_SETLINK requests to
complete.

Note that rtnl_af_ops needs to be protected by its dedicated lock
when RTNL is removed.

Note also that BUG_ON() in do_setlink() is changed to the normal
error handling as a different af_ops might be found after
validate_linkmsg().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/rtnetlink.h
net/core/rtnetlink.c