From: sashiko-bot@kernel.org
To: "Hans Zhang" <18255117159@163.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v5 3/3] PCI: cadence: Add LGA IP debugfs for LTSSM status
Date: Fri, 15 May 2026 15:57:27 +0000 [thread overview]
Message-ID: <20260515155728.63133C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515145747.129635-4-18255117159@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Out-of-bounds memory read in cdns_pcie_lga_ltssm_status_string due to incorrect prefix length subtraction.
--
commit f6b71b7c026fc3d8d383a59dcd6b10992b1a66e1
Author: Hans Zhang <18255117159@163.com>
PCI: cadence: Add LGA IP debugfs for LTSSM status
Extend debugfs support to LGA-based Cadence PCIe controllers. The
'ltssm_status' file now works for both HPA and LGA IP by selecting the
appropriate register access based on the 'is_hpa' flag.
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-debugfs.c b/drivers/pci/controller/cadence/pcie-cadence-debugfs.c
> --- a/drivers/pci/controller/cadence/pcie-cadence-debugfs.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-debugfs.c
> @@ -13,6 +13,58 @@
>
> #define CDNS_DEBUGFS_BUF_MAX 128
>
> +static const char *cdns_pcie_lga_ltssm_status_string(enum cdns_pcie_lga_ltssm ltssm)
> +{
> + const char *str;
> +
> + switch (ltssm) {
> +#define CDNS_PCIE_LGA_LTSSM_NAME(n) case n: str = #n; break
[ ... ]
> + CDNS_PCIE_LGA_LTSSM_NAME(CDNS_PCIE_LGA_RECOVERY_IDLE);
> + CDNS_PCIE_LGA_LTSSM_NAME(CDNS_PCIE_LGA_L0);
[ ... ]
> + default:
> + str = "CDNS_PCIE_LGA_LTSSM_UNKNOWN";
> + break;
> + }
> +
> + return str + strlen("CDNS_PCIE_LGA_LTSSM_");
Can this cause an out-of-bounds memory read?
The stringified enum values, such as "CDNS_PCIE_LGA_L0", do not contain the
"LTSSM_" portion in their names. For example, "CDNS_PCIE_LGA_L0" is 16
characters long.
However, the return statement advances the string pointer by
strlen("CDNS_PCIE_LGA_LTSSM_"), which is 20 bytes.
Since L0 is the normal operational state of the PCIe link, could reading the
debugfs file while in this state advance the pointer past the null
terminator and leak adjacent memory into the output?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260515145747.129635-1-18255117159@163.com?part=3
prev parent reply other threads:[~2026-05-15 15:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 14:57 [PATCH v5 0/3] PCI: cadence: Add LTSSM debugfs Hans Zhang
2026-05-15 14:57 ` [PATCH v5 1/3] PCI: cadence: Add HPA architecture flag Hans Zhang
2026-05-15 14:57 ` [PATCH v5 2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status Hans Zhang
2026-05-15 15:39 ` sashiko-bot
2026-05-15 14:57 ` [PATCH v5 3/3] PCI: cadence: Add LGA " Hans Zhang
2026-05-15 15:57 ` sashiko-bot [this message]
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=20260515155728.63133C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=18255117159@163.com \
--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