net: shaper: protect late read accesses to the hierarchy
authorJakub Kicinski <kuba@kernel.org>
Tue, 17 Mar 2026 16:10:13 +0000 (09:10 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 19 Mar 2026 12:47:15 +0000 (13:47 +0100)
commit0f9ea7141f365b4f27226898e62220fb98ef8dc6
tree937487a70af1af2d07e1a2ff1cac8af7501139e1
parent8a63baadf08453f66eb582fdb6dd234f72024723
net: shaper: protect late read accesses to the hierarchy

We look up a netdev during prep of Netlink ops (pre- callbacks)
and take a ref to it. Then later in the body of the callback
we take its lock or RCU which are the actual protections.

This is not proper, a conversion from a ref to a locked netdev
must include a liveness check (a check if the netdev hasn't been
unregistered already). Fix the read cases (those under RCU).
Writes needs a separate change to protect from creating the
hierarchy after flush has already run.

Fixes: 4b623f9f0f59 ("net-shapers: implement NL get operation")
Reported-by: Paul Moses <p@1g4.org>
Link: https://lore.kernel.org/20260309173450.538026-1-p@1g4.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260317161014.779569-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/shaper/shaper.c