mirror of
https://github.com/torvalds/linux.git
synced 2026-09-12 04:23:03 +02:00
net: dsa: bcm_sf2: bound the CFP rule dump by the caller's buffer size
bcm_sf2_cfp_rule_get_all() walks the whole cfp.unique bitmap into
rule_locs[] without consulting nfc->rule_cnt, which is how many entries
the caller had room for. ETHTOOL_GRXCLSRLALL requires no CAP_NET_ADMIN
and the ioctl sizes the buffer from the rule_cnt userspace passes in, so
once an admin has installed CFP rules any user can ask for fewer slots
than there are rules and run off the end of the allocation. A rule_cnt
of 0 leaves the buffer pointer NULL and the walk dereferences it.
Fixes: 7318166cac ("net: dsa: bcm_sf2: Add support for ethtool::rxnfc")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20260903032611.3000029-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
1746ef2e2d
commit
cdb719f4b8
|
|
@ -1088,6 +1088,8 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,
|
|||
unsigned int index = 1, rules_cnt = 0;
|
||||
|
||||
for_each_set_bit_from(index, priv->cfp.unique, priv->num_cfp_rules) {
|
||||
if (rules_cnt == nfc->rule_cnt)
|
||||
return -EMSGSIZE;
|
||||
rule_locs[rules_cnt] = index;
|
||||
rules_cnt++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user