]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: avoid UAF on deleted altname
authorJakub Kicinski <kuba@kernel.org>
Wed, 18 Oct 2023 01:38:15 +0000 (18:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 10:03:08 +0000 (12:03 +0200)
commitb92433493bcc81674851fd9869ba1d474fa6f032
treeac2538536a10b1d9f4e3004c1e94f59a8ec4f9dc
parent1cf912054a08a548ff229fc6225a34e46bd02786
net: avoid UAF on deleted altname

commit 1a83f4a7c156fa6bbd6b530e89fa3270bf3d9d1b upstream.

Altnames are accessed under RCU (dev_get_by_name_rcu())
but freed by kfree() with no synchronization point.

Each node has one or two allocations (node and a variable-size
name, sometimes the name is netdev->name). Adding rcu_heads
here is a bit tedious. Besides most code which unlists the names
already has rcu barriers - so take the simpler approach of adding
synchronize_rcu(). Note that the one on the unregistration path
(which matters more) is removed by the next fix.

Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/dev.c