Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba667382 authored by Hangyu Hua's avatar Hangyu Hua Committed by Greg Kroah-Hartman
Browse files

net: ethernet: mvpp2_main: fix possible OOB write in mvpp2_ethtool_get_rxnfc()



[ Upstream commit 51fe0a470543f345e3c62b6798929de3ddcedc1d ]

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: 90b509b3 ("net: mvpp2: cls: Add Classification offload support")
Signed-off-by: default avatarHangyu Hua <hbh25y@gmail.com>
Reviewed-by: default avatarMarcin Wojtas <mw@semihalf.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5624f26a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4233,6 +4233,11 @@ static int mvpp2_ethtool_get_rxnfc(struct net_device *dev,
		break;
	case ETHTOOL_GRXCLSRLALL:
		for (i = 0; i < MVPP2_N_RFS_ENTRIES_PER_FLOW; i++) {
			if (loc == info->rule_cnt) {
				ret = -EMSGSIZE;
				break;
			}

			if (port->rfs_rules[i])
				rules[loc++] = i;
		}