Skip to content

Commit 51fe0a4

Browse files
HBh25Ydavem330
authored andcommitted
net: ethernet: mvpp2_main: fix possible OOB write in mvpp2_ethtool_get_rxnfc()
rules is allocated in ethtool_get_rxnfc and the size is determined by rule_cnt from user space. So rule_cnt needs to be check before using rules to avoid OOB writing or NULL pointer dereference. Fixes: 90b509b ("net: mvpp2: cls: Add Classification offload support") Signed-off-by: Hangyu Hua <[email protected]> Reviewed-by: Marcin Wojtas <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9b90aca commit 51fe0a4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5586,6 +5586,11 @@ static int mvpp2_ethtool_get_rxnfc(struct net_device *dev,
55865586
break;
55875587
case ETHTOOL_GRXCLSRLALL:
55885588
for (i = 0; i < MVPP2_N_RFS_ENTRIES_PER_FLOW; i++) {
5589+
if (loc == info->rule_cnt) {
5590+
ret = -EMSGSIZE;
5591+
break;
5592+
}
5593+
55895594
if (port->rfs_rules[i])
55905595
rules[loc++] = i;
55915596
}

0 commit comments

Comments
 (0)