Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH 0/3] hwmon: Handle const struct attributes
@ 2026-08-05 19:04 Thomas Weißschuh
  2026-08-05 19:04 ` [PATCH 1/3] hwmon: (core) Constify device attributes Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2026-08-05 19:04 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Thomas Weißschuh

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@weissschuh.net>
---
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@weissschuh.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-05 21:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 19:04 [PATCH 0/3] hwmon: Handle const struct attributes Thomas Weißschuh
2026-08-05 19:04 ` [PATCH 1/3] hwmon: (core) Constify device attributes Thomas Weißschuh
2026-08-05 20:08   ` sashiko-bot
2026-08-05 19:04 ` [PATCH 2/3] hwmon: (core) Use const APIs for the dynamically allocated sysfs attributes Thomas Weißschuh
2026-08-05 20:05   ` sashiko-bot
2026-08-05 19:04 ` [PATCH 3/3] hwmon: (sysfs) Allow drivers to register const attributes Thomas Weißschuh
2026-08-05 20:07   ` sashiko-bot
2026-08-05 21:20     ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox