[PATCH v2 0/3] hwmon: Handle const struct attributes
From: Thomas Weißschuh
Date: Thu Aug 06 2026 - 02:12:00 EST
Statically allocated instance of 'struct attribute' and its derivates
like 'struct device_attribute' are never modified.
To avoid accidental or malicious modifications (to hijack control flow)
they should be marked as 'const' and moved into read-only memory.
Historically the sysfs APIs did not allow this, but today it is possible.
Change the attributes in the hwmon core and also lay the groundwork for
the drivers to be changed.
The drivers themselves will also need to
be adapted. Please tell me in which form you want this to happen.
One big patch or per-driver patches; in a big series or separate?
Cc all driver maintainers or just hwmon core ones?
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
Changes in v2:
- s/__DRIVER_ATTR/__DEVICE_ATTR/
- Link to v1: https://patch.msgid.link/20260805-sysfs-const-attr-hwmon-v1-0-4c0cb2b290a1@xxxxxxxxxxxxxx
---
Thomas Weißschuh (3):
hwmon: (core) Constify device attributes
hwmon: (core) Use const APIs for the dynamically allocated sysfs attributes
hwmon: (sysfs) Allow drivers to register const attributes
drivers/hwmon/hwmon.c | 70 ++++++++++++++++++++++-----------------------
include/linux/hwmon-sysfs.h | 14 ++++-----
2 files changed, 42 insertions(+), 42 deletions(-)
---
base-commit: ef9d75d6705d89d019d950262a11d55b19f5d9e3
change-id: 20260526-sysfs-const-attr-hwmon-f3b5692d2923
Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>