From: Joel Granados <joel.granados@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Ondrej Mosnáček" <omosnacek@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"Serge Hallyn" <serge@hallyn.com>,
"Eric W . Biederman" <ebiederm@xmission.com>,
"Alexey Gladkov" <legion@kernel.org>,
"Joel Granados" <joel.granados@kernel.org>
Subject: [PATCH RFC 0/4] sysctl: add a registration context to share ctl_table arrays
Date: Thu, 24 Sep 2026 16:34:08 +0200 [thread overview]
Message-ID: <20260924-lklm-sysctl-headerctx-template-v1-0-b25e51c66ba7@kernel.org> (raw)
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>
next reply other threads:[~2026-09-24 14:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 14:34 Joel Granados [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924-lklm-sysctl-headerctx-template-v1-0-b25e51c66ba7@kernel.org \
--to=joel.granados@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=kees@kernel.org \
--cc=legion@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnacek@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®