summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJad Keskes <inasj268@gmail.com>2026-07-30 15:55:48 +0100
committerBorislav Petkov (AMD) <bp@alien8.de>2026-08-07 16:11:52 -0700
commit66cc9dec919dd63d8e4b3d386f7aed3ae684e645 (patch)
tree1afba7e6d3dac426d3c381bfa99346ddbc4743c9
parente09afa69e3f5d5a304940cf4c6ea17642a1e3993 (diff)
downloadlinux-66cc9dec919dd63d8e4b3d386f7aed3ae684e645.tar.gz
linux-66cc9dec919dd63d8e4b3d386f7aed3ae684e645.zip
EDAC/device_sysfs: Use kstrtouint() for poll_msec to prevent truncation
The poll_msec sysfs store file uses simple_strtoul() which accepts an unsigned long, but the target field (poll_msec) is unsigned int. On 64-bit systems, a value > UINT_MAX is silently truncated when stored. Fix the mismatch by using kstrtouint() instead. This rejects values larger than UINT_MAX at parse time, making truncation impossible. Also add a check for value < 1 to reject the 0-delay case, which would cause the poll work to spin without delay and consume 100% CPU. Fixes: e27e3dac6517 ("drivers/edac: add edac_device class") Signed-off-by: Jad Keskes <inasj268@gmail.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://patch.msgid.link/20260730145549.148229-1-inasj268@gmail.com
-rw-r--r--drivers/edac/edac_device_sysfs.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index b1c2717cd023..6995ce039db9 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -88,14 +88,21 @@ static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
*ctl_info, const char *data,
size_t count)
{
- unsigned long value;
+ unsigned int value;
+ int ret;
/* get the value and enforce that it is non-zero, must be at least
* one millisecond for the delay period, between scans
* Then cancel last outstanding delay for the work request
* and set a new one.
*/
- value = simple_strtoul(data, NULL, 0);
+ ret = kstrtouint(data, 0, &value);
+ if (ret < 0)
+ return ret;
+
+ if (value < 1)
+ return -EINVAL;
+
edac_device_reset_delay_period(ctl_info, value);
return count;