net: fealnx: fixed possible out of band acces to an array
Subsystems (3)
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
@@ -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
kernel test robot
build botFYI: 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
Quoted 3 lines · Ilya Krutskih
fixed possible out of band access to an array
If thefealnx_init_one()function is called more thanMAX_UNITStimes orcard_idxis 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