All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] octeontx2-af: cn10k: fix an array overflow in is_lmac_valid()
@ 2021-03-02 11:21 Dan Carpenter
  2021-03-03 16:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-03-02 11:21 UTC (permalink / raw)
  To: Sunil Goutham, hariprasad
  Cc: Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep,
	David S. Miller, Jakub Kicinski, netdev, kernel-janitors

The value of "lmac_id" can be controlled by the user and if it is larger
then the number of bits in long then it reads outside the bitmap.
The highest valid value is less than MAX_LMAC_PER_CGX (4).

Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 9caa375d01b1..68deae529bc9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -56,7 +56,9 @@ static bool is_dev_rpm(void *cgxd)
 
 bool is_lmac_valid(struct cgx *cgx, int lmac_id)
 {
-	return cgx && test_bit(lmac_id, &cgx->lmac_bmap);
+	if (!cgx || lmac_id < 0 || lmac_id >= MAX_LMAC_PER_CGX)
+		return false;
+	return test_bit(lmac_id, &cgx->lmac_bmap);
 }
 
 struct mac_ops *get_mac_ops(void *cgxd)
-- 
2.30.1


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

* Re: [PATCH net] octeontx2-af: cn10k: fix an array overflow in is_lmac_valid()
  2021-03-02 11:21 [PATCH net] octeontx2-af: cn10k: fix an array overflow in is_lmac_valid() Dan Carpenter
@ 2021-03-03 16:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-03 16:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: sgoutham, hkelam, lcherian, gakula, jerinj, sbhatta, davem, kuba,
	netdev, kernel-janitors

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 2 Mar 2021 14:21:54 +0300 you wrote:
> The value of "lmac_id" can be controlled by the user and if it is larger
> then the number of bits in long then it reads outside the bitmap.
> The highest valid value is less than MAX_LMAC_PER_CGX (4).
> 
> Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> [...]

Here is the summary with links:
  - [net] octeontx2-af: cn10k: fix an array overflow in is_lmac_valid()
    https://git.kernel.org/netdev/net/c/2378b2c9ecf4

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-03-04  0:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 11:21 [PATCH net] octeontx2-af: cn10k: fix an array overflow in is_lmac_valid() Dan Carpenter
2021-03-03 16:50 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.