octeontx2-pf: fix a buffer overflow in otx2_set_rxfh_context()
PATCH 1/1 octeontx2-pf: fix a buffer overflow in otx2_set_rxfh_context()
This function is called from ethtool_set_rxfh() and "*rss_context" comes from the user. Add some bounds checking to prevent memory corruption.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +4 -0
@@ -786,6 +786,10 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir,if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP )return -EOPNOTSUPP ; +if (*rss_context !=ETH_RXFH_CONTEXT_ALLOC && + *rss_context >=MAX_RSS_GROUPS ) +return -EINVAL ; + rss = &pfvf->hw.rss_info;if (!rss->enable) {
Signature · 1 line
2.30.2
Quoted 27 lines · Dan Carpenter
This function is called from
ethtool_set_rxfh()and "*rss_context" comes from the user. Add some bounds checking to prevent memory corruption.Fixes 81a4362016e7 ("octeontx2-pf: Add RSS multi group support")Signed-off-by Dan Carpenter <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +4
-1@@ -786,6 +786,10 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir,if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP )return -EOPNOTSUPP ; +if (*rss_context !=ETH_RXFH_CONTEXT_ALLOC && + *rss_context >=MAX_RSS_GROUPS ) +return -EINVAL ; + rss = &pfvf->hw.rss_info;if (!rss->enable) { --
Quoted 2 lines
2.30.2
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Wed, 12 May 2021 13:11:43 +0300 you wrote:
This function is called from
ethtool_set_rxfh()and "*rss_context" comes from the user. Add some bounds checking to prevent memory corruption.Fixes 81a4362016e7 ("octeontx2-pf: Add RSS multi group support")Signed-off-by Dan Carpenter <[email protected]>[...]
Here is the summary with links:
- [net] octeontx2-pf: fix a buffer overflow in otx2_set_rxfh_context()
https://git.kernel.org/netdev/net/c/e5cc361e2164
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html