summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@nvidia.com>2026-08-30 14:16:22 +0300
committerBjorn Helgaas <bhelgaas@google.com>2026-09-11 15:40:31 -0500
commit0bb005b72608c2201c7ecc677b7bbc74a6286bde (patch)
tree35d4d65972f96475d0ea0d8b58ea2e7bdafbc8e3
parente89c361b934226a1427b3ce6d0c45983b32ceb49 (diff)
downloadlinux-next-0bb005b72608c2201c7ecc677b7bbc74a6286bde.tar.gz
linux-next-0bb005b72608c2201c7ecc677b7bbc74a6286bde.zip
PCI/P2PDMA: Safely terminate ACS redirect lists
seq_buf marks an overflow by setting len to size + 1. The ACS diagnostic path unconditionally writes a terminator to buffer[len - 1], so a path with enough ACS ports to fill the 128-byte buffer writes one byte beyond the buffer when verbose diagnostics are requested. Use seq_buf_str() to terminate truncated output safely and remove the final semicolon only when the buffer did not overflow. Fixes: 52916982af48 ("PCI/P2PDMA: Support peer-to-peer memory") Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Tushar Dave <tdave@nvidia.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://patch.msgid.link/20260830-batch-p2p-fixes-v1-4-5044e8dfbe2e@nvidia.com
-rw-r--r--drivers/pci/p2pdma.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 509813d75467..bf5af4555f99 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -778,11 +778,13 @@ check_b_path_acs:
}
if (verbose) {
- acs_list.buffer[acs_list.len-1] = 0; /* drop final semicolon */
+ /* Drop the final semicolon; the list is not empty here */
+ if (!seq_buf_has_overflowed(&acs_list))
+ acs_list.buffer[acs_list.len - 1] = '\0';
pci_warn(client, "ACS redirect is set between the client and provider (%s)\n",
pci_name(provider));
pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n",
- acs_list.buffer);
+ seq_buf_str(&acs_list));
}
acs_redirects = true;