BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Zahka" <daniel.zahka@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/8] eth: mpnic: add scaffolding for Meta Platforms NIC
Date: Thu, 24 Sep 2026 01:44:35 +0000	[thread overview]
Message-ID: <20260924014435.D31001F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922-linux-mpnic-v1-1-236844f53072@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mpnic: Missing PCI BAR size validation causing OOB MMIO access
--

commit 04a97e4905a47ed1a317515fbb919eef32a497b2
Author: Daniel Zahka <daniel.zahka@gmail.com>

eth: mpnic: add scaffolding for Meta Platforms NIC

This commit adds the initial bare PCI driver scaffolding for the Meta
Platforms Network Interface Controller. It introduces basic MMIO read/write
operations and PCI device registration.

> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_pci.c b/drivers/net/ethernet/meta/mpnic/mpnic_pci.c
> new file mode 100644
> index 0000000000000..96393e7812418
> --- /dev/null
> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_pci.c

[ ... ]

> +u64 mpnic_rd64(struct mpnic_dev *mpd, u32 reg)
> +{
> +	u32 __iomem *csr = READ_ONCE(mpd->uc_addr0);
> +	u64 value;
> +
> +	if (!csr)
> +		return ~0ULL;
> +
> +	value = readq(csr + reg);
> +
> +	/* If any bits are 0 value should be valid */
> +	if (~value)
> +		return value;
> +
> +	/* All ones can be a valid value, so confirm against a register
> +	 * which never reads that way on a live device.
> +	 */
> +	if (reg != MPNIC_BDQ_SPARE && ~readq(csr + MPNIC_BDQ_SPARE))

[Severity: High]
Could this unconditionally read at a large offset (~16.5MB) regardless of the
actual mapped BAR size? If a device (or an attacker via hotplug/virtualization)
presents a smaller BAR, wouldn't this cause an out-of-bounds MMIO access
and potentially a kernel page fault?

> +		return value;
> +
> +	mpnic_mmio_err(mpd, reg);
> +
> +	return ~0ULL;
> +}

[ ... ]

> +static int mpnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> +{
> +	void __iomem *uc_addr0;
> +	struct mpnic_dev *mpd;
> +	int err;

[ ... ]

> +	mpd = mpnic_alloc(pdev);
> +	if (!mpd)
> +		return -ENOMEM;
> +
> +	uc_addr0 = pcim_iomap_region(pdev, 0, MPNIC_DRV_NAME);

[Severity: High]
Does this code map the PCI BAR without first validating that the resource
length is large enough to cover the expected register offsets? Should this
validate pci_resource_len(pdev, 0) before mapping to ensure that accesses
like MPNIC_BDQ_SPARE remain within bounds?

> +	if (IS_ERR(uc_addr0)) {
> +		err = PTR_ERR(uc_addr0);
> +		dev_err(&pdev->dev, "Mapping the register file failed: %d\n",
> +			err);
> +		goto err_free_mpd;
> +	}
> +	mpd->uc_addr0 = uc_addr0;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922-linux-mpnic-v1-0-236844f53072@gmail.com?part=1

  reply	other threads:[~2026-09-24  1:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  1:43 [PATCH net-next 0/8] eth: mpnic: initial support for Meta Platforms NIC Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 1/8] eth: mpnic: add scaffolding " Daniel Zahka
2026-09-24  1:44   ` sashiko-bot [this message]
2026-09-23  1:43 ` [PATCH net-next 2/8] eth: mpnic: add register init for the device Daniel Zahka
2026-09-24  1:44   ` sashiko-bot
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 16:16     ` Daniel Zahka
2026-09-24 16:22       ` Jakub Kicinski
2026-09-23  1:43 ` [PATCH net-next 3/8] eth: mpnic: allocate MSI-X vectors Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 4/8] eth: mpnic: implement Tx queue allocation and cleanup Daniel Zahka
2026-09-24  1:44   ` sashiko-bot
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 16:39     ` Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 5/8] eth: mpnic: start and stop the Tx HW queues Daniel Zahka
2026-09-24  1:44   ` sashiko-bot
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 17:49     ` Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 6/8] eth: mpnic: add a netdevice and basic Tx handling Daniel Zahka
2026-09-24  1:44   ` sashiko-bot
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 18:08     ` Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 7/8] eth: mpnic: implement Rx queue allocation and cleanup Daniel Zahka
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 18:23     ` Daniel Zahka
2026-09-23  1:43 ` [PATCH net-next 8/8] eth: mpnic: add basic Rx handling Daniel Zahka
2026-09-24  1:44   ` sashiko-bot
2026-09-24  2:05   ` netdev-bot+sashiko
2026-09-24 18:38     ` Daniel Zahka

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=20260924014435.D31001F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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