netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 net] net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx()
@ 2020-05-06 10:16 Dan Carpenter
  2020-05-06 10:16 ` [PATCH 2/2 net] net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del() Dan Carpenter
  2020-05-06 21:18 ` [PATCH 1/2 net] net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx() David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-05-06 10:16 UTC (permalink / raw)
  To: David S. Miller, Maxime Chevallier
  Cc: Matteo Croce, Russell King, Antoine Tenart, Ioana Ciornei, netdev,
	kernel-janitors

The "rss_context" variable comes from the user via  ethtool_get_rxfh().
It can be any u32 value except zero.  Eventually it gets passed to
mvpp22_rss_ctx() and if it is over MVPP22_N_RSS_TABLES (8) then it
results in an array overflow.

Fixes: 895586d5dc32 ("net: mvpp2: cls: Use RSS contexts to handle RSS tables")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 1fa60e985b43a..2b5dad2ec650c 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -4329,6 +4329,8 @@ static int mvpp2_ethtool_get_rxfh_context(struct net_device *dev, u32 *indir,
 
 	if (!mvpp22_rss_is_supported())
 		return -EOPNOTSUPP;
+	if (rss_context >= MVPP22_N_RSS_TABLES)
+		return -EINVAL;
 
 	if (hfunc)
 		*hfunc = ETH_RSS_HASH_CRC32;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-06 21:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-06 10:16 [PATCH 1/2 net] net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx() Dan Carpenter
2020-05-06 10:16 ` [PATCH 2/2 net] net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del() Dan Carpenter
2020-05-06 21:18   ` David Miller
2020-05-06 21:18 ` [PATCH 1/2 net] net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx() David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).