The NETDEV scope represents a singleton root shaper in the per-device hierarchy. All code assumes NETDEV shapers have id 0: net_shaper_default_parent() hardcodes parent->id = 0 when returning the NETDEV parent for QUEUE/NODE children, and the UAPI documentation describes NETDEV scope as "the main shaper" (singular, not plural). Make sure we reject non-0 IDs like we reject out of range queues. Fixes: 4b623f9f0f59 ("net-shapers: implement NL get operation") Signed-off-by: Jakub Kicinski --- net/shaper/shaper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c index 16bf24d9e3ca..2adf8b0e1105 100644 --- a/net/shaper/shaper.c +++ b/net/shaper/shaper.c @@ -535,6 +535,13 @@ static int net_shaper_validate_caps(struct net_shaper_binding *binding, return -EOPNOTSUPP; } + if (shaper->handle.scope == NET_SHAPER_SCOPE_NETDEV && + shaper->handle.id != 0) { + NL_SET_ERR_MSG(info->extack, + "Netdev scope is a singleton, must use ID 0"); + return -EINVAL; + } + if (shaper->handle.scope == NET_SHAPER_SCOPE_QUEUE && binding->type == NET_SHAPER_BINDING_TYPE_NETDEV && shaper->handle.id >= binding->netdev->real_num_tx_queues) { -- 2.54.0