mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] sysctl: add a registration context to share ctl_table arrays
@ 2026-09-24 14:34 Joel Granados
  2026-09-24 14:34 ` [PATCH RFC 1/4] sysctl: add a registration context to ctl_table_header Joel Granados
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Joel Granados @ 2026-09-24 14:34 UTC (permalink / raw)
  To: Kees Cook
  Cc: linux-kernel, linux-fsdevel, Ondrej Mosnáček,
	Andrew Morton, Ryan Roberts, Serge Hallyn, Eric W . Biederman,
	Alexey Gladkov, Joel Granados

What
====
This series adds a context (containing a template and an instance
struct) to the ctl_table_header. When ctl_table entries are flagged, the
context is used to update .data against the instance given at
registration time. This is done on a stack copy just before proc_handler
and before ->permissions, so handlers keep using container_of() on .data
as they do today. The table stays const and shared, and the only change
to an entry is one .flags line.

The first two patches add the context and the resolution to the sysctl
core. The last two convert ipc and mqueue. They are an example of the
interface and show the kmemdup() going away.

Why
===
To avoid the duplication of ctl_table arrays for every namespace just to
change the ".data" member in ctl_table.

Comment on void* inside ctx
===========================
I use void pointers inside the context because I want to avoid having
non-sysctl types within sysctl. However, I do a compiler time check with
SYSCTL_CTX(_inst, _tmpl) to make sure that they are both the same time
(we can add further checks in that macro as we need them)

Comment on Alexey's series
==========================
Alexey posted a series for the same problem [1]. This RFC tries to do
the same, but with a smaller change. Both keep a struct sysctl_context
in the header. This RFC covers .data only, not the limits in
extra1/extra2, and it needs a template with a constant address, so
objects only reachable through a pointer would need an offset variant
that is not here.

Comments are greatly appreciated

Best

[1] https://lore.kernel.org/cover.1789987960.git.legion@kernel.org

PS : its always difficult for me to know who wants to be CCed in these
mails. please let me know if you want to be removed from the cc.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
Joel Granados (4):
      sysctl: add a registration context to ctl_table_header
      sysctl: Apply sysctl context when flag is active
      ipc: Use sysctl context to register ipc namespaces
      mqueue: Use sysctl context to register mq_sysctls

 fs/proc/proc_sysctl.c  | 56 +++++++++++++++++++++++++++++++++++++----
 include/linux/sysctl.h | 55 ++++++++++++++++++++++++++++++++++++++--
 ipc/ipc_sysctl.c       | 68 ++++++++++++--------------------------------------
 ipc/mq_sysctl.c        | 44 ++++++++------------------------
 4 files changed, 130 insertions(+), 93 deletions(-)
---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260924-lklm-sysctl-headerctx-template-f20eb4fcf44d

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>



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

end of thread, other threads:[~2026-09-24 18:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 14:34 [PATCH RFC 0/4] sysctl: add a registration context to share ctl_table arrays Joel Granados
2026-09-24 14:34 ` [PATCH RFC 1/4] sysctl: add a registration context to ctl_table_header Joel Granados
2026-09-24 14:34 ` [PATCH RFC 2/4] sysctl: Apply sysctl context when flag is active Joel Granados
2026-09-24 18:41   ` Alexey Gladkov
2026-09-24 14:34 ` [PATCH RFC 3/4] ipc: Use sysctl context to register ipc namespaces Joel Granados
2026-09-24 14:34 ` [PATCH RFC 4/4] mqueue: Use sysctl context to register mq_sysctls Joel Granados

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

all inboxes | Powered by JetHome®