]> git.baikalelectronics.ru Git - kernel.git/commit
netns: protect netns ID lookups with RCU
authorGuillaume Nault <gnault@redhat.com>
Mon, 13 Jan 2020 21:39:22 +0000 (22:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:47:31 +0000 (09:47 +0200)
commit91ac71ac0563c5c8c01d41c5d3423359102d20f9
treea4a475762e2ebb867abf091533106643d646f8b0
parentda4caf0f385fb0ba8e01419e897d0b5e694bc51f
netns: protect netns ID lookups with RCU

commit edd3a10d0875b9a2708498baf6116aab1e815d9b upstream.

__peernet2id() can be protected by RCU as it only calls idr_for_each(),
which is RCU-safe, and never modifies the nsid table.

rtnl_net_dumpid() can also do lockless lookups. It does two nested
idr_for_each() calls on nsid tables (one direct call and one indirect
call because of rtnl_net_dumpid_one() calling __peernet2id()). The
netnsid tables are never updated. Therefore it is safe to not take the
nsid_lock and run within an RCU-critical section instead.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
net/core/net_namespace.c