* [PATCH] net: fealnx: fixed possible out of band acces to an array
@ 2025-11-10 13:44 Ilya Krutskih
2025-11-10 13:55 ` kernel test robot
2025-11-11 16:22 ` I Viswanath
0 siblings, 2 replies; 3+ messages in thread
From: Ilya Krutskih @ 2025-11-10 13:44 UTC (permalink / raw)
To: sdl
Cc: Ilya Krutskih, andrew+netdev, davem, edumazet, kuba, pabeni, tglx,
mingo, netdev, linux-kernel, stable, lvc-project
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.
Signed-off-by: Ilya Krutskih <devsec@tpz.ru>
---
drivers/net/ethernet/fealnx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index 6ac8547ef9b8..c7f2141a01fe 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -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) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fealnx: fixed possible out of band acces to an array
2025-11-10 13:44 [PATCH] net: fealnx: fixed possible out of band acces to an array Ilya Krutskih
@ 2025-11-10 13:55 ` kernel test robot
2025-11-11 16:22 ` I Viswanath
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-11-10 13:55 UTC (permalink / raw)
To: Ilya Krutskih; +Cc: stable, oe-kbuild-all
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: stable@vger.kernel.org" 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
Link: https://lore.kernel.org/stable/20251110134423.432612-1-devsec%40tpz.ru
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fealnx: fixed possible out of band acces to an array
2025-11-10 13:44 [PATCH] net: fealnx: fixed possible out of band acces to an array Ilya Krutskih
2025-11-10 13:55 ` kernel test robot
@ 2025-11-11 16:22 ` I Viswanath
1 sibling, 0 replies; 3+ messages in thread
From: I Viswanath @ 2025-11-11 16:22 UTC (permalink / raw)
To: Ilya Krutskih, sdl
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, tglx, mingo, netdev,
linux-kernel, stable, lvc-project
On 10/11/25 19:14, Ilya Krutskih wrote:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-11 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 13:44 [PATCH] net: fealnx: fixed possible out of band acces to an array Ilya Krutskih
2025-11-10 13:55 ` kernel test robot
2025-11-11 16:22 ` I Viswanath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox