The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ilya Krutskih <devsec@tpz.ru>
To: <sdl@secdev.space>
Cc: Ilya Krutskih <devsec@tpz.ru>, <andrew+netdev@lunn.ch>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <tglx@linutronix.de>, <mingo@kernel.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: [PATCH] net: fealnx: fixed possible out of band acces to an array
Date: Mon, 10 Nov 2025 13:44:22 +0000	[thread overview]
Message-ID: <20251110134423.432612-1-devsec@tpz.ru> (raw)

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


             reply	other threads:[~2025-11-10 13:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 13:44 Ilya Krutskih [this message]
2025-11-11 16:22 ` [PATCH] net: fealnx: fixed possible out of band acces to an array I Viswanath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251110134423.432612-1-devsec@tpz.ru \
    --to=devsec@tpz.ru \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdl@secdev.space \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox