mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
devlink: validate the port index in the rate set request
port-index is the only way rate-set can address a leaf (port) rate object, but it was never listed in the request, so the generated policy has no entry for it. The op declares .maxattr = DEVLINK_ATTR_PARENT_DEV, so the attribute still reaches info->attrs[], validated against a zeroed slot - NLA_UNSPEC, length 0 - which GENL_DONT_VALIDATE_STRICT accepts at any length. devlink_port_get_from_attrs() then runs nla_get_u32() on it. Handed a zero-length port-index the kernel reads the four bytes past the payload, which are the next attribute's header, and acts on the port index those spell out. Since we're reading a linear skb the OOB read is still within the same memory allocation, it's just garbage. We also do not echo the garbage back to the user so it's not an info leak either. Hence not treating this is a real bug fix. rate-new is left alone on purpose. It creates rate nodes, resolved by name through devlink_rate_node_get_from_attrs(), and never looks at port-index. Link: https://patch.msgid.link/20260915161341.1053476-10-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
826e2a736e
commit
2a22788ba2
|
|
@ -2447,6 +2447,7 @@ operations:
|
|||
- bus-name
|
||||
- dev-name
|
||||
- index
|
||||
- port-index
|
||||
- rate-node-name
|
||||
- rate-tx-share
|
||||
- rate-tx-max
|
||||
|
|
|
|||
|
|
@ -618,6 +618,7 @@ static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_PARENT_DE
|
|||
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
|
||||
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
|
||||
[DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range),
|
||||
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
|
||||
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
|
||||
[DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64, },
|
||||
[DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64, },
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user