All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 00/10] sysfs: constify struct bin_attribute (Part 1)
@ 2024-10-31  2:43 Thomas Weißschuh
  2024-10-31  2:43 ` [PATCH RFC 01/10] sysfs: explicitly pass size to sysfs_add_bin_file_mode_ns() Thomas Weißschuh
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Thomas Weißschuh @ 2024-10-31  2:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki
  Cc: Dan Williams, linux-kernel, Thomas Weißschuh

struct bin_attribute contains a bunch of pointer members, which when
overwritten by accident or malice can lead to system instability and
security problems.
Moving the definitions of struct bin_attribute to read-only memory
makes these modifications impossible.
The same change has been performed for many other structures in the
past. (struct class, struct ctl_table...)

For the structure definitions throughout the core to be moved to
read-only memory the following steps are necessary.

1) Change all callbacks invoked from the sysfs core to only pass const
   pointers
2) Adapt the sysfs core to only work in terms of const pointers
3) Adapt the sysfs core APIs to allow const pointers
4) Change all structure definitions through the core to const

This series provides the foundation for step 1) above.
It converts some callbacks in a single step to const and provides a
foundation for those callbacks where a single step is not possible.

This series is marked as RFC and only sent to the sysfs maintainers to
get some feedback on the general aproach.
The same techniques employed by this series can later be reused for the
same change for 'struct attribute'.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (10):
      sysfs: explicitly pass size to sysfs_add_bin_file_mode_ns()
      sysfs: introduce callback attribute_group::bin_size
      PCI/sysfs: Calculate bin_attribute size through bin_size()
      nvmem: core: calculate bin_attribute size through bin_size()
      sysfs: treewide: constify attribute callback of bin_is_visible()
      sysfs: treewide: constify attribute callback of bin_attribute::mmap()
      sysfs: drop callback bin_attribute::llseek
      sysfs: implement all BIN_ATTR_* macros in terms of __BIN_ATTR()
      sysfs: bin_attribute: add const read/write callback variants
      driver core: Constify attribute arguments of binary attributes

 drivers/base/node.c                     |   4 +-
 drivers/base/topology.c                 |   4 +-
 drivers/cxl/port.c                      |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |   2 +-
 drivers/infiniband/hw/qib/qib_sysfs.c   |   2 +-
 drivers/misc/ocxl/sysfs.c               |   2 +-
 drivers/mtd/spi-nor/sysfs.c             |   2 +-
 drivers/nvmem/core.c                    |  16 ++++-
 drivers/pci/p2pdma.c                    |   2 +-
 drivers/pci/pci-sysfs.c                 |  36 +++++++-----
 drivers/pci/vpd.c                       |   2 +-
 drivers/platform/x86/amd/hsmp.c         |   2 +-
 drivers/platform/x86/intel/pmt/class.c  |   2 +-
 drivers/platform/x86/intel/sdsi.c       |   2 +-
 drivers/scsi/scsi_sysfs.c               |   2 +-
 drivers/uio/uio_hv_generic.c            |   2 +-
 drivers/usb/core/sysfs.c                |   2 +-
 fs/sysfs/file.c                         |  32 +++++-----
 fs/sysfs/group.c                        |   5 +-
 fs/sysfs/sysfs.h                        |   2 +-
 include/linux/sysfs.h                   | 100 +++++++++++++++++++-------------
 21 files changed, 132 insertions(+), 93 deletions(-)
---
base-commit: e42b1a9a2557aa94fee47f078633677198386a52
change-id: 20241028-sysfs-const-bin_attr-a00896481d0b

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


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

end of thread, other threads:[~2024-11-01  5:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31  2:43 [PATCH RFC 00/10] sysfs: constify struct bin_attribute (Part 1) Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 01/10] sysfs: explicitly pass size to sysfs_add_bin_file_mode_ns() Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 02/10] sysfs: introduce callback attribute_group::bin_size Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 03/10] PCI/sysfs: Calculate bin_attribute size through bin_size() Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 04/10] nvmem: core: calculate " Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 05/10] sysfs: treewide: constify attribute callback of bin_is_visible() Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 06/10] sysfs: treewide: constify attribute callback of bin_attribute::mmap() Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 07/10] sysfs: drop callback bin_attribute::llseek Thomas Weißschuh
2024-11-01  5:17   ` kernel test robot
2024-11-01  5:27   ` kernel test robot
2024-10-31  2:43 ` [PATCH RFC 08/10] sysfs: implement all BIN_ATTR_* macros in terms of __BIN_ATTR() Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 09/10] sysfs: bin_attribute: add const read/write callback variants Thomas Weißschuh
2024-10-31  2:43 ` [PATCH RFC 10/10] driver core: Constify attribute arguments of binary attributes Thomas Weißschuh
2024-11-01  1:20 ` [PATCH RFC 00/10] sysfs: constify struct bin_attribute (Part 1) Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.