From: Larysa Zaremba <larysa.zaremba@intel.com>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@google.com>, <andrew+netdev@lunn.ch>,
<netdev@vger.kernel.org>, Phani R Burra <phani.r.burra@intel.com>,
<przemyslaw.kitszel@intel.com>, <aleksander.lobakin@intel.com>,
<sridhar.samudrala@intel.com>, <anjali.singhai@intel.com>,
<michal.swiatkowski@linux.intel.com>,
<maciej.fijalkowski@intel.com>, <emil.s.tantilov@intel.com>,
<madhu.chittim@intel.com>, <joshua.a.hay@intel.com>,
<jacob.e.keller@intel.com>, <jayaprakash.shanmugam@intel.com>,
<jiri@resnulli.us>, <horms@kernel.org>, <corbet@lwn.net>,
<richardcochran@gmail.com>, <linux-doc@vger.kernel.org>,
Bharath R <bharath.r@intel.com>,
Samuel Salin <Samuel.salin@intel.com>
Subject: Re: [PATCH net-next v4 02/15] libie: add PCI device initialization helpers to libie
Date: Mon, 13 Jul 2026 16:55:49 +0200 [thread overview]
Message-ID: <alT8dYPTxD3rhqht@soc-5CG4396X81.clients.intel.com> (raw)
In-Reply-To: <20260710215313.1475803-3-anthony.l.nguyen@intel.com>
Sashiko has 1 concern about this patch, and I think it is not very relevant, as
this is a 32-bit issue on a 200G+ HW, which AI also mentions. Seems like
checking offsets under ifdefs would be unneccessarily defensive.
Sashiko says:
> commit 0540f7038f92c56e3d90344d11ab6f07b9f6b975
> Author: Phani R Burra <phani.r.burra@intel.com>
> libie: add PCI device initialization helpers to libie
> This patch introduces libie helpers for PCI init, MMIO mapping bookkeeping
> via a list of libie_pci_mmio_region entries, and a lookup helper to
> translate offsets to virtual addresses. The public map/get APIs accept
> resource_size_t offset and size arguments and are intended to be shared by
> idpf and ixd.
> > diff --git a/drivers/net/ethernet/intel/libie/pci.c b/drivers/net/ethernet/intel/libie/pci.c
> > new file mode 100644
> > index 000000000000..a0d3535d6529
> > --- /dev/null
> > +++ b/drivers/net/ethernet/intel/libie/pci.c
> [ ... ]
> > +bool __libie_pci_map_mmio_region(struct libie_mmio_info *mmio_info,
> > + resource_size_t offset,
> > + resource_size_t size, int num_args, ...)
> > +{
> > + struct pci_dev *pdev = mmio_info->pdev;
> > + struct libie_pci_mmio_region *mr;
> > + resource_size_t end_offset;
> > + void __iomem *va;
> > + int bar_idx = 0;
> > + va_list args;
> > +
> > + if (num_args) {
> > + va_start(args, num_args);
> > + bar_idx = va_arg(args, int);
> > + va_end(args);
> > + }
> > +
> > + /* pci_iomap_range() would silently map less in such case */
> > + if (!size || check_add_overflow(offset, size, &end_offset) ||
> > + end_offset > pci_resource_len(pdev, bar_idx))
> > + return false;
> Can this API silently truncate the mapping on 32-bit PAE builds?
> The parameters offset and size are resource_size_t, and the bounds check
> above is performed in resource_size_t arithmetic against
> pci_resource_len(), which is fine.
> However, pci_iomap_range() is declared as:
> void __iomem *pci_iomap_range(struct pci_dev *dev, int bar,
> unsigned long offset,
> unsigned long maxlen);
> On 32-bit configs with CONFIG_PHYS_ADDR_T_64BIT (for example PAE),
> resource_size_t is 64-bit while unsigned long is 32-bit.
> > + va = pci_iomap_range(mmio_info->pdev, bar_idx, offset, size);
> If a caller passes an offset or size >= 4 GiB that legitimately fits
> within a 64-bit BAR, the libie-level bounds check passes but the values
> are silently truncated when handed to pci_iomap_range(), so the wrong
> sub-range gets mapped and the mr->offset / mr->size stored in the list
> no longer describe the memory actually returned by pci_iomap_range().
> Would it make sense to either reject offset/size that exceed ULONG_MAX
> here, or narrow the map API to unsigned long so the truncation is
> visible at the type level? In-tree idpf and ixd likely never hit this
> today, but the public signature invites the mismatch.
> > + if (!va) {
> > + pci_err(pdev, "Failed to map BAR%u region\n", bar_idx);
> > + return false;
> > + }
> [ ... ]
next prev parent reply other threads:[~2026-07-13 14:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 21:52 [PATCH net-next v4 00/15][pull request] Introduce iXD driver Tony Nguyen
2026-07-10 21:52 ` [PATCH net-next v4 01/15] virtchnl: move virtchnl and virtchnl2 headers to 'include/linux/net/intel' Tony Nguyen
2026-07-10 21:52 ` [PATCH net-next v4 02/15] libie: add PCI device initialization helpers to libie Tony Nguyen
2026-07-13 14:55 ` Larysa Zaremba [this message]
2026-07-10 21:53 ` [PATCH net-next v4 03/15] libeth: allow to create fill queues without NAPI Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 04/15] libie: add control queue support Tony Nguyen
2026-07-13 17:10 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 05/15] libie: add bookkeeping support for control queue messages Tony Nguyen
2026-07-13 17:42 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 06/15] idpf: remove 'vport_params_reqd' field Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 07/15] idpf: remove unused code for getting RSS info from device Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 08/15] idpf: refactor idpf to use libie_pci APIs Tony Nguyen
2026-07-13 17:46 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 09/15] idpf: refactor idpf to use libie control queues Tony Nguyen
2026-07-13 17:55 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 10/15] idpf: make mbx_task queueing and cancelling more consistent Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 11/15] idpf: print a debug message and bail in case of non-event ctlq message Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 12/15] ixd: add basic driver framework for Intel(R) Control Plane Function Tony Nguyen
2026-07-10 21:53 ` [PATCH net-next v4 13/15] ixd: add reset checks and initialize the mailbox Tony Nguyen
2026-07-13 13:34 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 14/15] ixd: add the core initialization Tony Nguyen
2026-07-13 18:13 ` Larysa Zaremba
2026-07-10 21:53 ` [PATCH net-next v4 15/15] ixd: add devlink support Tony Nguyen
2026-07-13 13:29 ` Larysa Zaremba
2026-07-13 18:29 ` [PATCH net-next v4 00/15][pull request] Introduce iXD driver Larysa Zaremba
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=alT8dYPTxD3rhqht@soc-5CG4396X81.clients.intel.com \
--to=larysa.zaremba@intel.com \
--cc=Samuel.salin@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anjali.singhai@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=bharath.r@intel.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=emil.s.tantilov@intel.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jayaprakash.shanmugam@intel.com \
--cc=jiri@resnulli.us \
--cc=joshua.a.hay@intel.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=madhu.chittim@intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phani.r.burra@intel.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=sridhar.samudrala@intel.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