From: sashiko-bot@kernel.org
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v3 3/8] PCI: Honor alignment overrides
Date: Tue, 13 Oct 2026 13:24:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-169802@kernel.org> (raw)
In-Reply-To: <20261013130948.6231-4-ilpo.jarvinen@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: uninitialized variable `user_aligned` causes random bypass of resource alignment
--
commit dc4a5f31af386d2a1de50debe4823977860a1cb9
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Subject: PCI: Honor alignment overrides
This commit introduces struct pci_resreq_data to hold device and user-given
alignment. It allows pci_align_resource() to honor user-given alignment by
skipping remainder movement when a user alignment is provided.
Link: https://lore.kernel.org/linux-pci/20260923133202.07DF61F000FF@smtp.kernel.org/
[ ... ]
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d31a8d107b1ef..ea7d758712691 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
[ ... ]
> @@ -1217,12 +1217,40 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask);
> /* Architecture-specific versions may override this (weak) */
> char *pcibios_setup(char *str);
>
> -/* Used only when drivers/pci/setup.c is used */
> +/* Resource assignment request handling */
> +/**
> + * struct pci_resreq_data - Data passed to pcibios_align_resource()
> + * @dev: PCI device
> + * @user_align: User provided alignment override (pci=resource_alignment param)
> + */
> +struct pci_resreq_data {
> + struct pci_dev *dev;
> + resource_size_t user_align;
> +};
> +
> +resource_size_t pci_specified_resource_alignment(struct pci_dev *dev,
> + bool *resize);
> +/*
> + * TODO: Improve PCI resource assignment interface so that callers outside PCI
> + * core do not need to know about this detail.
> + */
> +static inline void pci_init_pci_resreq_data(struct pci_resreq_data *rr,
> + struct pci_dev *dev)
> +{
> + bool user_aligned;
> +
> + memset(rr, 0, sizeof(*rr));
> + rr->dev = dev;
> + rr->user_align = pci_specified_resource_alignment(dev, &user_aligned);
[Severity: High]
Does this leave user_aligned uninitialized on the default execution path?
When pci_init_pci_resreq_data() calls pci_specified_resource_alignment(),
the output parameter is not always written to. For instance, if there
are no boot parameters, pci_specified_resource_alignment() exits early:
drivers/pci/pci.c:pci_specified_resource_alignment() {
...
p = resource_alignment_param;
if (!p || !*p)
goto out;
...
out:
spin_unlock(&resource_alignment_lock);
return align;
}
This leaves user_aligned with uninitialized stack memory. If this memory
happens to be non-zero, it can cause the resource alignment logic to be
randomly bypassed later in pci_align_resource(), leading to potential PCI
resource exhaustion or allocation failures on architectures with a non-zero
default alignment.
Could user_aligned be initialized to false before being passed?
> + if (!user_aligned)
> + rr->user_align = 0;
> +}
> +
> resource_size_t pcibios_align_resource(void *data, const struct resource *res,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013130948.6231-1-ilpo.jarvinen@linux.intel.com?part=3
next prev parent reply other threads:[~2026-10-13 13:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 13:09 [PATCH v3 0/8] PCI: Resource placement algorithm fixes Ilpo Järvinen
2026-10-13 13:09 ` [PATCH v3 1/8] resource: Mark free space assigned Ilpo Järvinen
2026-10-13 13:28 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 2/8] PCI/parisc: Clean up resource debug print & use dynamic debug Ilpo Järvinen
2026-10-13 13:19 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 3/8] PCI: Honor alignment overrides Ilpo Järvinen
2026-10-13 13:24 ` sashiko-bot [this message]
2026-10-13 14:08 ` Rodrigo Vivi
2026-10-13 13:09 ` [PATCH v3 4/8] PCI: Fix nesting windows with remainder at the left edge Ilpo Järvinen
2026-10-13 13:25 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 5/8] linux/log2.h: Add 64-bit roundup/down_pow_of_two64() variants Ilpo Järvinen
2026-10-13 13:16 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 6/8] PCI: Place resources to either edge of the window Ilpo Järvinen
2026-10-13 13:19 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 7/8] PCI: Fix composite resource sizing Ilpo Järvinen
2026-10-13 13:26 ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 8/8] PCI/quirks: Avoid certain address on Genoa systems Ilpo Järvinen
2026-10-13 13:24 ` sashiko-bot
2026-10-13 17:00 ` Mario Limonciello
2026-10-13 17:03 ` Mario Limonciello
2026-10-13 17:26 ` Ilpo Järvinen
2026-10-13 18:59 ` Mario Limonciello
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=sashiko-outbox-169802@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-pci@vger.kernel.org \
--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