Skip to contentSkip to conversation

net: fealnx: fixed possible out of band acces to an array

PATCH In review Ilya Krutskih 3 participants 3 messages Nov 10, 2025 – Nov 11, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fealnx: fixed possible out of band acces to an array

fixed possible out of band access to an array
If the fealnx_init_one() function is called more than MAX_UNITS times or card_idx is less than zero

Added a check: 0 <= card_idx < MAX_UNITS

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/net/ethernet/fealnx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/fealnx.c +3 -3
index 6ac8547ef9b8..c7f2141a01fe 100644
@@ -491,8 +491,8 @@ static int fealnx_init_one(struct pci_dev *pdev,
 
 	card_idx++;
 	sprintf(boardname, "fealnx%d", card_idx);
-
-	option = card_idx < MAX_UNITS ? options[card_idx] : 0;
+	if (card_idx >= 0)
+		option = card_idx < MAX_UNITS ? options[card_idx] : 0;
 
 	i = pci_enable_device(pdev);
 	if (i) return i;
@@ -623,7 +623,7 @@ static int fealnx_init_one(struct pci_dev *pdev,
 		np->default_port = option & 15;
 	}
 
-	if (card_idx < MAX_UNITS && full_duplex[card_idx] > 0)
+	if ((0 <= card_idx && MAX_UNITS > card_idx) && full_duplex[card_idx] > 0)
 		np->mii.full_duplex = full_duplex[card_idx];
 
 	if (np->mii.full_duplex) {
Signature · 1 line
2.43.0
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] net: fealnx: fixed possible out of band acces to an array

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to Ilya Krutskih
Quoted 3 lines · Ilya Krutskih

fixed possible out of band access to an array
If the fealnx_init_one() function is called more than MAX_UNITS times or card_idx is less than zero

The code already validates against the >= MAX_UNITS case and card_idx can never be less than zero at those points under normal circumstances, making this patch unnecessary.

However, card_idx will overflow with enough calls and that is something that should probably be fixed