From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH RESEND v4 net-next 13/14] net: enetc: use alloc_etherdev_mqs() to create netdev for VF driver
Date: Tue, 21 Jul 2026 02:13:31 +0000 [thread overview]
Message-ID: <20260721021332.C1B431F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720014317.1059359-14-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Low] Passing 0 to alloc_etherdev_mqs() triggers a pr_err() inside the networking core if the hardware reports 0 rings.
Pre-existing issues:
- [Critical] Hardware-provided ring counts are not bounded against driver static array sizes, causing out-of-bounds writes.
--
--- Patch [13]: [PATCH RESEND v4 net-next 13/14] net: enetc: use alloc_etherdev_mqs() to create netdev for VF driver ---
commit 79eef0d032f82d691851f474deed33cca36dd548
Author: Wei Fang <wei.fang@nxp.com>
net: enetc: use alloc_etherdev_mqs() to create netdev for VF driver
This commit changes the VF driver to use alloc_etherdev_mqs() instead of
alloc_etherdev_mq(), allowing TX and RX queue counts to be set independently
based on the actual hardware capabilities up to ENETC_MAX_NUM_TXQS.
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> index 9cdb0a4d6bafb..7dcb4a0246f52 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> @@ -317,7 +317,14 @@ static int enetc_vf_probe(struct pci_dev *pdev,
>
> enetc_get_si_caps(si);
>
> - ndev = alloc_etherdev_mq(sizeof(*priv), ENETC_MAX_NUM_TXQS);
> + /* Currently, the supported SoCs have a max of 6 CPUs and the VFs
> + * have less than 6 RX/TX rings. So no issues for these supported
> + * SoCs, but for future SoCs which have more CPUs or more TX/RX
> + * rings, all the related logic needs to be improved.
> + */
> + ndev = alloc_etherdev_mqs(sizeof(*priv),
> + min(si->num_tx_rings, ENETC_MAX_NUM_TXQS),
> + min(si->num_rx_rings, ENETC_MAX_NUM_TXQS));
[Severity: Low]
Does this code handle the case where the hardware reports 0 rings?
If si->num_tx_rings or si->num_rx_rings is 0, this passes 0 to
alloc_etherdev_mqs(), which triggers a "Unable to allocate device with zero
queues" pr_err() in the network core and returns NULL. The previous hardcoded
ENETC_MAX_NUM_TXQS guaranteed a valid count.
Should there be a check to ensure the ring counts are at least 1?
[Severity: Critical]
This is a pre-existing issue, but is it possible for the hardware to report
ring counts that exceed the internal array sizes, causing an out-of-bounds
write?
Looking at enetc_init_si_rings_params(), the hardware-provided ring counts
are assigned without validating them against the internal array bounds:
drivers/net/ethernet/freescale/enetc/enetc.c:enetc_init_si_rings_params() {
...
priv->num_tx_rings = si->num_tx_rings;
priv->bdr_int_num = priv->num_rx_rings;
...
}
Subsequently, enetc_alloc_msix() loops over these values and writes to the
statically sized arrays in enetc_int_vector_init():
drivers/net/ethernet/freescale/enetc/enetc.c:enetc_int_vector_init() {
...
priv->tx_ring[idx] = bdr;
...
}
A malicious or misconfigured PCI hypervisor or Physical Function (PF) could
supply arbitrary values to the Virtual Function (VF) driver. If the hardware
reports huge ring counts, this causes a buffer overflow on the heap when
writing to priv->int_vector (size 6) and priv->tx_ring (size 16), which could
lead to a panic or arbitrary code execution.
Could these values be strictly bounded against the array sizes during probe?
> if (!ndev) {
> err = -ENOMEM;
> dev_err(&pdev->dev, "netdev creation failed\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720014317.1059359-1-wei.fang@oss.nxp.com?part=13
next prev parent reply other threads:[~2026-07-21 2:13 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 1:43 [PATCH RESEND v4 net-next 00/14] net: enetc: cleanups and improvements wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 01/14] net: enetc: extract common helpers for MAC promiscuous mode setting wei.fang
2026-07-20 14:02 ` Joe Damato
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 02/14] net: enetc: extract common helpers for MAC hash filter configuration wei.fang
2026-07-21 2:13 ` sashiko-bot
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 03/14] net: enetc: convert ndo_set_rx_mode() to ndo_set_rx_mode_async() wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 04/14] net: enetc: improve MAFT entry management with bitmap tracking wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 05/14] net: enetc: use PCI device name for debugfs directory wei.fang
2026-07-20 13:46 ` Joe Damato
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 06/14] net: enetc: simplify enetc4_set_port_speed() wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 07/14] net: enetc: differentiate phylink capabilities for pseudo-MAC and standalone MAC wei.fang
2026-07-21 2:13 ` sashiko-bot
2026-07-21 5:46 ` Wei Fang (OSS)
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 08/14] net: enetc: remove invalid code from enetc4_pl_mac_link_up() wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 09/14] net: enetc: open-code enetc4_set_default_si_vlan_promisc() wei.fang
2026-07-20 15:26 ` Joe Damato
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 10/14] net: enetc: refactor SI VLAN promiscuous mode configuration wei.fang
2026-07-22 13:25 ` Joe Damato
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 11/14] net: enetc: move enetc_set_si_vlan_promisc() to enetc_pf_common.c wei.fang
2026-07-20 15:28 ` Joe Damato
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 12/14] net: enetc: remove redundant num_vsi field from enetc_port_caps wei.fang
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 13/14] net: enetc: use alloc_etherdev_mqs() to create netdev for VF driver wei.fang
2026-07-20 17:36 ` Joe Damato
2026-07-21 2:01 ` Wei Fang (OSS)
2026-07-21 2:13 ` sashiko-bot [this message]
2026-07-21 5:54 ` Wei Fang (OSS)
2026-07-20 1:43 ` [PATCH RESEND v4 net-next 14/14] net: enetc: use kzalloc_flex() for enetc_psfp_gate allocation wei.fang
2026-07-20 13:48 ` Joe Damato
2026-07-21 2:13 ` sashiko-bot
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=20260721021332.C1B431F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@oss.nxp.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