net: lan966x: fix a couple off by one bugs
PATCH 1/1 net: lan966x: fix a couple off by one bugs
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.
--- drivers/net/ethernet/microchip/lan966x/lan966x_mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +2 -2
@@ -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);
Signature · 1 line
2.20.1
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Thu, 21 Apr 2022 18:46:13 +0300 you wrote:
The lan966x->ports[] array has
lan966x->num_phys_portselements. These are assigned inlan966x_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html