From: Fedor Pchelkin <pchelkin@ispras.ru>
To: "Жамбакиев Радий Рикардинович" <r.zhambakiev@prosoftsystems.ru>,
"Andrew Lunn" <andrew+netdev@lunn.ch>
Cc: "Aleksandr Loktionov" <aleksandr.loktionov@intel.com>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
"Denis Benato" <benato.denis96@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"Jijie Shao" <shaojijie@huawei.com>,
"Eric Dumazet" <edumazet@google.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
"Michael Grzeschik" <mgr@kernel.org>
Subject: Re: [PATCH net v3 3/3] net: fealnx: bound card_idx to prevent out-of-bounds access
Date: Mon, 19 Oct 2026 17:46:23 +0300 [thread overview]
Message-ID: <atYrfvH_e1GLnfa9@fedora> (raw)
In-Reply-To: <20261019134136.104932-4-r.zhambakiev@prosoftsystems.ru>
On Mon, 19. Oct 13:43, Жамбакиев Радий Рикардинович wrote:
> 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);
There is a compiler warning with a W=1 build the testing bots will
soon complain about:
drivers/net/ethernet/fealnx.c:498:35: warning: '%d' directive writing between 1 and 11 bytes into a region of size 6 [-Wformat-overflow=]
498 | sprintf(boardname, "fealnx%d", card_idx);
| ^~
drivers/net/ethernet/fealnx.c:498:28: note: directive argument in the range [-2147483647, 99999]
498 | sprintf(boardname, "fealnx%d", card_idx);
| ^~~~~~~~~~
drivers/net/ethernet/fealnx.c:498:9: note: 'sprintf' output between 8 and 18 bytes into a destination of size 12
498 | sprintf(boardname, "fealnx%d", card_idx);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next prev parent reply other threads:[~2026-10-19 14:54 UTC|newest]
Thread overview: 7+ 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-19 13:43 ` [PATCH net v3 3/3] net: fealnx: bound card_idx to prevent out-of-bounds access Жамбакиев Радий Рикардинович
2026-10-19 14:46 ` Fedor Pchelkin [this message]
2026-10-19 15:47 ` 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=atYrfvH_e1GLnfa9@fedora \
--to=pchelkin@ispras.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=r.zhambakiev@prosoftsystems.ru \
--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