All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: lan966x: fix a couple off by one bugs
@ 2022-04-21 15:46 Dan Carpenter
  2022-04-25 10:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-04-21 15:46 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: UNGLinuxDriver, David S. Miller, Jakub Kicinski, Paolo Abeni,
	netdev, kernel-janitors

The lan966x->ports[] array has lan966x->num_phys_ports elements.  These
are assigned in lan966x_probe().  That means the > comparison should be
changed to >=.

The first off by one check is harmless but the second one could lead to
an out of bounds access and a crash.

Fixes: 5ccd66e01cbe ("net: lan966x: add support for interrupts from analyzer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_mac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
index 2679111ef669..005e56ea5da1 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
@@ -346,7 +346,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,
 
 			lan966x_mac_process_raw_entry(&raw_entries[column],
 						      mac, &vid, &dest_idx);
-			if (WARN_ON(dest_idx > lan966x->num_phys_ports))
+			if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
 				continue;
 
 			/* If the entry in SW is found, then there is nothing
@@ -393,7 +393,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,
 
 		lan966x_mac_process_raw_entry(&raw_entries[column],
 					      mac, &vid, &dest_idx);
-		if (WARN_ON(dest_idx > lan966x->num_phys_ports))
+		if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
 			continue;
 
 		mac_entry = lan966x_mac_alloc_entry(mac, vid, dest_idx);
-- 
2.20.1


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

* Re: [PATCH net] net: lan966x: fix a couple off by one bugs
  2022-04-21 15:46 [PATCH net] net: lan966x: fix a couple off by one bugs Dan Carpenter
@ 2022-04-25 10:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-25 10:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: horatiu.vultur, UNGLinuxDriver, davem, kuba, pabeni, netdev,
	kernel-janitors

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 21 Apr 2022 18:46:13 +0300 you wrote:
> The lan966x->ports[] array has lan966x->num_phys_ports elements.  These
> are assigned in lan966x_probe().  That means the > comparison should be
> changed to >=.
> 
> The first off by one check is harmless but the second one could lead to
> an out of bounds access and a crash.
> 
> [...]

Here is the summary with links:
  - [net] net: lan966x: fix a couple off by one bugs
    https://git.kernel.org/netdev/net/c/9810c58c7051

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:[~2022-04-25 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 15:46 [PATCH net] net: lan966x: fix a couple off by one bugs Dan Carpenter
2022-04-25 10:30 ` 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.