[PATCH v2 02/10] PCI/AER: Clamp negative ratelimit burst to zero
From: Yazen Ghannam
Date: Fri Sep 18 2026 - 11:22:19 EST
The correctable and nonfatal "_ratelimit_burst" attributes store
whatever kstrtoint() parses, so a negative value lands directly in
ratelimit_state.burst.
___ratelimit() reads a negative burst as an uninitialized
ratelimit_state and splats a WARN_ONCE. A CAP_SYS_ADMIN write of "-1"
then warns on the next AER error and suppresses every later message,
with nothing in the attribute to show that logging is off.
Clamp negative values to zero, as the companion interval attribute
already does. Zero still suppresses everything, so a negative value
keeps its old meaning without the warning.
Document that in the ABI description of both burst attributes. Document
it for the interval attributes too, where clamping negatives is existing
behaviour that was never written down.
Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/linux-pci/20260714191826.BA81E1F000E9@xxxxxxxxxxxxxxx/
Assisted-by: LLM
Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
.../ABI/testing/sysfs-bus-pci-devices-aer | 21 ++++++++++++-------
drivers/pci/pcie/aer.c | 3 +++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
index 5ed284523956..215cf8bd4c30 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
@@ -130,9 +130,10 @@ What: /sys/bus/pci/devices/<dev>/aer/correctable_ratelimit_interval_ms
Date: May 2025
KernelVersion: 6.16.0
Contact: linux-pci@xxxxxxxxxxxxxxx
-Description: Writing 0 disables AER correctable error log ratelimiting.
- Writing a positive value sets the ratelimit interval in ms.
- Default is DEFAULT_RATELIMIT_INTERVAL (5000 ms).
+Description: Writing 0, or any negative value, disables AER correctable
+ error log ratelimiting. Writing a positive value sets the
+ ratelimit interval in ms. Default is
+ DEFAULT_RATELIMIT_INTERVAL (5000 ms).
What: /sys/bus/pci/devices/<dev>/aer/correctable_ratelimit_burst
Date: May 2025
@@ -143,14 +144,17 @@ Description: Ratelimit burst for correctable error logs. Writing a value
before ratelimiting. Reading gets the current ratelimit
burst. Default is DEFAULT_RATELIMIT_BURST (10).
+ Writing 0, or any negative value, suppresses all logs
+ unless the interval attribute is also 0.
+
What: /sys/bus/pci/devices/<dev>/aer/nonfatal_ratelimit_interval_ms
Date: May 2025
KernelVersion: 6.16.0
Contact: linux-pci@xxxxxxxxxxxxxxx
-Description: Writing 0 disables AER non-fatal uncorrectable error log
- ratelimiting. Writing a positive value sets the ratelimit
- interval in ms. Default is DEFAULT_RATELIMIT_INTERVAL
- (5000 ms).
+Description: Writing 0, or any negative value, disables AER non-fatal
+ uncorrectable error log ratelimiting. Writing a positive
+ value sets the ratelimit interval in ms. Default is
+ DEFAULT_RATELIMIT_INTERVAL (5000 ms).
What: /sys/bus/pci/devices/<dev>/aer/nonfatal_ratelimit_burst
Date: May 2025
@@ -161,3 +165,6 @@ Description: Ratelimit burst for non-fatal uncorrectable error logs.
allowed per interval before ratelimiting. Reading gets the
current ratelimit burst. Default is DEFAULT_RATELIMIT_BURST
(10).
+
+ Writing 0, or any negative value, suppresses all logs
+ unless the interval attribute is also 0.
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index d8dcd238fda1..350b57e5ccb1 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -751,6 +751,9 @@ const struct attribute_group aer_stats_attr_group = {
if (kstrtoint(buf, 0, &burst) < 0) \
return -EINVAL; \
\
+ if (burst < 0) \
+ burst = 0; \
+ \
pdev->aer_info->ratelimit.burst = burst; \
\
return count; \
--
2.43.0