linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] sysctl: prepare sysctl core for const struct ctl_table
@ 2024-08-05  9:39 Thomas Weißschuh
  2024-08-05  9:39 ` [PATCH v2 1/6] sysctl: avoid spurious permanent empty tables Thomas Weißschuh
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2024-08-05  9:39 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Luis Chamberlain, Kees Cook, Joel Granados
  Cc: bpf, linux-kernel, linux-fsdevel, Thomas Weißschuh, stable

Adapt the internal and external APIs of the sysctl core to handle
read-only instances of "struct ctl_table".

Patch 1: Bugfix for the sysctl core, the bug can be reliably triggered
         with the series applied
Patch 2: Trivial preparation commit for the sysctl BPF hook
Patch 3: Adapts the internal sysctl APIs
Patch 4: Adapts the external sysctl APIs
Patch 5: Constifies the sysctl internal tables as proof that it works
Patch 6: Updates scripts/const_structs.checkpatch for "struct ctl_table"

Motivation
==========

Moving structures containing function pointers into unmodifiable .rodata
prevents attackers or bugs from corrupting and diverting those pointers.

Also the "struct ctl_table" exposed by the sysctl core were never meant
to be mutated by users.

For this goal changes to both the sysctl core and "const" qualifiers for
various sysctl APIs are necessary.

Full Process
============

* Drop ctl_table modifications from the sysctl core ([0], in mainline)
* Constify arguments to ctl_table_root::{set_ownership,permissions}
  ([1], in mainline)
* Migrate users of "ctl_table_header::ctl_table_arg" to "const".
  (in mainline)
* Afterwards convert "ctl_table_header::ctl_table_arg" itself to const.
  (in mainline)
* Prepare helpers used to implement proc_handlers throughout the tree to
  use "const struct ctl_table *". ([2], in mainline)
* Afterwards switch over all proc_handlers callbacks to use
  "const struct ctl_table *" in one commit. (in mainline)
* Switch over the internals of the sysctl core to "const struct ctl_table *" (this series)
* Switch include/linux/sysctl.h to "const struct ctl_table *" (this series)
* Transition instances of "struct ctl_table" through the tree to const (to be done)

This series is meant to be applied through the sysctl tree.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Avoid spurious permanent empty tables (patch 1)
- Link to v1: https://lore.kernel.org/r/20240729-sysctl-const-api-v1-0-ca628c7a942c@weissschuh.net

---
Thomas Weißschuh (6):
      sysctl: avoid spurious permanent empty tables
      bpf: Constify ctl_table argument of filter function
      sysctl: move internal interfaces to const struct ctl_table
      sysctl: allow registration of const struct ctl_table
      sysctl: make internal ctl_tables const
      const_structs.checkpatch: add ctl_table

 fs/proc/internal.h               |   2 +-
 fs/proc/proc_sysctl.c            | 100 +++++++++++++++++++++------------------
 include/linux/bpf-cgroup.h       |   2 +-
 include/linux/sysctl.h           |  12 ++---
 kernel/bpf/cgroup.c              |   2 +-
 scripts/const_structs.checkpatch |   1 +
 6 files changed, 63 insertions(+), 56 deletions(-)
---
base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b
change-id: 20240729-sysctl-const-api-73954f3d62c1

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


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

end of thread, other threads:[~2024-10-09 11:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05  9:39 [PATCH v2 0/6] sysctl: prepare sysctl core for const struct ctl_table Thomas Weißschuh
2024-08-05  9:39 ` [PATCH v2 1/6] sysctl: avoid spurious permanent empty tables Thomas Weißschuh
2024-08-24 18:05   ` Thomas Weißschuh
2024-09-02  9:19     ` Joel Granados
2024-08-05  9:39 ` [PATCH v2 2/6] bpf: Constify ctl_table argument of filter function Thomas Weißschuh
2024-08-05  9:39 ` [PATCH v2 3/6] sysctl: move internal interfaces to const struct ctl_table Thomas Weißschuh
2024-08-05  9:39 ` [PATCH v2 4/6] sysctl: allow registration of " Thomas Weißschuh
2024-08-05  9:39 ` [PATCH v2 5/6] sysctl: make internal ctl_tables const Thomas Weißschuh
2024-08-05  9:39 ` [PATCH v2 6/6] const_structs.checkpatch: add ctl_table Thomas Weißschuh
2024-10-09 11:56 ` [PATCH v2 0/6] sysctl: prepare sysctl core for const struct ctl_table Joel Granados

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).