[PATCH 0/3] hwmon: Handle const struct attributes
Thomas Weißschuh <[email protected]> Wed, 05 Aug 2026 21:04:18 +0200
| Newsgroups | org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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 <[email protected]>