From: sashiko-bot@kernel.org
To: "Wei Wang" <wei.w.wang@hotmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v7 4/6] PCI: Refactor disable_acs_redir and config_acs param handling
Date: Wed, 06 May 2026 21:07:24 +0000 [thread overview]
Message-ID: <20260506210725.49C3CC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <SI2PR01MB43933B1790A24957EB7DB79ADC3F2@SI2PR01MB4393.apcprd01.prod.exchangelabs.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Bounds checking in pci_param_config_acs() breaks backwards compatibility for padded parameters and contains an integer underflow that leads to Undefined Behavior.
- [Medium] Silenced logging for disable_acs_redir reduces configuration observability.
--
commit 2b4c7af1c4a60302203ef348c929aa8cf673e3ac
Author: Wei Wang <wei.w.wang@hotmail.com>
PCI: Refactor disable_acs_redir and config_acs param handling
This commit refactors the ACS parameter handling by splitting the old
__pci_config_acs function into dedicated functions for disable_acs_redir
and config_acs parameters.
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
[ ... ]
> +static void pci_param_disable_acs_redir(struct pci_dev *dev,
> + struct pci_acs *caps)
> +{
> + u16 acs_redir_mask = PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC;
> +
> + if (!disable_acs_redir_param ||
> + !pci_dev_match_disable_acs_redir(dev, disable_acs_redir_param) ||
> + !pci_dev_specific_disable_acs_redir(dev))
> + return;
> +
> + caps->ctrl = caps->fw_ctrl & ~acs_redir_mask;
> +}
The previous implementation printed a pci_info message when ACS control was
modified. Is it intentional that pci_param_disable_acs_redir no longer logs
confirmation that the redirect was disabled?
This might make debugging device isolation issues more difficult without the
dmesg confirmation.
[ ... ]
> +static void pci_param_config_acs(struct pci_dev *dev, struct pci_acs *caps)
> +{
> + u16 shift = 0, max_shift = fls(dev->acs_capabilities) - 1;
If dev->acs_capabilities is 0, fls(0) evaluates to 0. Will 0 - 1 underflow
the u16 max_shift variable to 65535, effectively bypassing the bounds check
below?
> + u16 enabled_bits = 0, disabled_bits = 0;
> + const char *p, *seg;
[ ... ]
> + p = strchr(seg, '@');
> + /* Parse bitstring backwards from '@' */
> + while (p > seg) {
> + if (shift > max_shift) {
> + pci_err(dev, "ACS flag bit %d exceed range %d\n",
> + shift, max_shift);
> + return;
> + }
The previous implementation gracefully allowed parameter padding that exceeded
the capability mask, only erroring if unsupported bits were actively enabled.
Does aborting here when shift exceeds max_shift break backwards compatibility
for existing working kernel boot parameters (like config_acs=00000000@...)
on devices with fewer capabilities?
> +
> + switch (*--p) {
> + case '1':
> + enabled_bits |= BIT(shift);
> + break;
If the bounds check is bypassed due to the max_shift underflow mentioned
above, could shift increment without bounds for long user strings?
If shift exceeds the width of an unsigned long, BIT(shift) could trigger
undefined behavior. Additionally, since enabled_bits is a u16, shift amounts
of 16 or greater will silently truncate.
--
Sashiko AI review · https://sashiko.dev/#/patchset/SI2PR01MB439385689A32A1DDA9CEABE1DC3F2@SI2PR01MB4393.apcprd01.prod.exchangelabs.com?part=4
next prev parent reply other threads:[~2026-05-06 21:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 14:10 [PATCH v7 0/6] PCI: Add support for ACS Enhanced Capability Wei Wang
2026-05-06 14:10 ` [PATCH v7 1/6] PCI: Validate ACS enable flags against device-specific ACS capabilities Wei Wang
2026-05-06 20:01 ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 2/6] Documentation/kernel-parameters: Add multi-device config_acs example Wei Wang
2026-05-06 20:12 ` sashiko-bot
2026-05-06 22:06 ` Randy Dunlap
2026-05-07 13:45 ` Wei Wang
2026-05-06 14:10 ` [PATCH v7 3/6] PCI: Consolidate delimiter handling into pci_dev_str_match() Wei Wang
2026-05-06 16:13 ` Wei Wang
2026-05-06 20:37 ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 4/6] PCI: Refactor disable_acs_redir and config_acs param handling Wei Wang
2026-05-06 21:07 ` sashiko-bot [this message]
2026-05-06 14:10 ` [PATCH v7 5/6] PCI: Enable the enhanced ACS controls introduced by PCI_ACS_ECAP Wei Wang
2026-05-06 21:32 ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 6/6] PCI: Add the enhanced ACS controls check to pci_acs_flags_enabled() Wei Wang
2026-05-06 21:57 ` 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=20260506210725.49C3CC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=wei.w.wang@hotmail.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