From: "Жамбакиев Радий Рикардинович" <r.zhambakiev@prosoftsystems.ru>
To: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: "Жамбакиев Радий Рикардинович" <r.zhambakiev@prosoftsystems.ru>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Michael Grzeschik" <mgr@kernel.org>,
"Jijie Shao" <shaojijie@huawei.com>,
"Aleksandr Loktionov" <aleksandr.loktionov@intel.com>,
"Denis Benato" <benato.denis96@gmail.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH net v3 3/3] net: fealnx: bound card_idx to prevent out-of-bounds access
Date: Mon, 19 Oct 2026 13:43:03 +0000 [thread overview]
Message-ID: <20261019134136.104932-4-r.zhambakiev@prosoftsystems.ru> (raw)
In-Reply-To: <20261019134136.104932-1-r.zhambakiev@prosoftsystems.ru>
From: Radiy Zhambakiev <r.zhambakiev@prosoftsystems.ru>
card_idx is a static counter that is incremented on every
probe. It can overflow and wrap to a negative value, which
then indexes options[] and full_duplex[] out of bounds.
Large values also no longer fit in the 12-byte boardname[]
buffer.
Bound card_idx to 99999, the largest value that still fits
into boardname, and fail the probe for any card beyond that.
fealnx is an old driver that cannot be tested properly on
real hardware, so a minimal best-effort guard was chosen
over a larger rework.
Found by Linux Verification Center (linuxtesting.org)
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Radiy Zhambakiev <r.zhambakiev@prosoftsystems.ru>
---
drivers/net/ethernet/fealnx.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index b5e96c7037f3..d5931c0314fc 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -41,6 +41,7 @@ static int rx_copybreak;
/* interoperability. */
/* The media type is usually passed in 'options[]'. */
#define MAX_UNITS 8 /* More are supported, limit only on options */
+#define MAX_CARD_IDX 99999
static int options[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
@@ -489,6 +490,10 @@ static int fealnx_init_one(struct pci_dev *pdev,
int bar = 1;
#endif
+ if (card_idx >= MAX_CARD_IDX) {
+ dev_err(&pdev->dev, "card_idx is too big %d, aborting", card_idx);
+ return -ENODEV;
+ }
card_idx++;
sprintf(boardname, "fealnx%d", card_idx);
--
2.53.0
next prev parent reply other threads:[~2026-10-19 13:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 13:42 [PATCH net v3 0/3] net: fealnx: fix card-index overflow and PCI device teardown Жамбакиев Радий Рикардинович
2026-10-19 13:42 ` [PATCH net v3 1/3] net: fealnx: fix teardown order in remove Жамбакиев Радий Рикардинович
2026-10-19 15:44 ` Andrew Lunn
2026-10-19 13:42 ` [PATCH net v3 2/3] net: fealnx: disable the PCI device on remove and probe failure Жамбакиев Радий Рикардинович
2026-10-21 10:41 ` Loktionov, Aleksandr
2026-10-19 13:43 ` Жамбакиев Радий Рикардинович [this message]
2026-10-19 14:46 ` [PATCH net v3 3/3] net: fealnx: bound card_idx to prevent out-of-bounds access Fedor Pchelkin
2026-10-19 15:47 ` Andrew Lunn
2026-10-21 11:10 ` Loktionov, Aleksandr
2026-10-21 17:26 ` Andrew Lunn
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=20261019134136.104932-4-r.zhambakiev@prosoftsystems.ru \
--to=r.zhambakiev@prosoftsystems.ru \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=benato.denis96@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mgr@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaojijie@huawei.com \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/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
all inboxes | Powered by JetHome®