mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel.org>
To: Joel Granados <joel.granados@kernel.org>
Cc: "Ondrej Mosnáček" <omosnacek@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Kees Cook" <kees@kernel.org>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Serge Hallyn" <serge@hallyn.com>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 0/5] sysctl: add typed field descriptors
Date: Fri, 23 Oct 2026 11:17:44 +0200	[thread overview]
Message-ID: <atsmOMeBfkMQgzQV@example.org> (raw)
In-Reply-To: <atoDngZsxy3TWmO_@hobbes>

On Thu, Oct 22, 2026 at 04:04:39PM +0200, Joel Granados wrote:
> On Mon, Oct 12, 2026 at 03:43:03PM +0200, Alexey Gladkov wrote:
> > On Sat, Sep 26, 2026 at 06:22:07PM +0200, Alexey Gladkov wrote:
> > > Hi,
> > > 
> > > Some sysctl users copy an otherwise static ctl_table for each namespace or
> > > device, then replace data and limit pointers before registration. Besides
> > > the per-instance allocation, these fixups often depend on table indices:
> > > reordering an entry without updating the fixup can silently bind it to the
> > > wrong data or limits.
> > > 
> > > This series lets such users describe a table once with static, read-only
> > > sysctl_field entries. Each field names a data type and an offset into an
> > > object selected by a sysctl_context at registration time. The offset
> > > helpers check the member type at build time. Limits and custom handlers
> > > remain optional properties of a field; the field type does not encode a
> > > choice of handler or whether limits are present. A subsystem that needs
> > > more than a namespace can embed sysctl_context in its own registration
> > > context.
> > > 
> > > The sysctl core keeps the context with the table header and materializes
> > > a ctl_table entry when an existing handler, permission check or BPF hook
> > > needs one. Legacy ctl_table registrations retain their own path, and
> > > subsystems can convert tables independently. The IPC, mqueue and ucount
> > > conversions here remove table copies without changing their backing data.
> > > 
> > > Changes since v2:
> > > 
> > > - Drop sysctl_uint_vals, as requested by Joel. Existing limit constants
> > >   suffice for these conversions.
> > > - Drop the *_MINMAX field types. A field's type now describes its data,
> > >   while optional min/max pointers supply bounds to the selected handler.
> > > - Keep __register_sysctl_table() and __register_sysctl_fields() as separate
> > >   registration paths, sharing only allocation and tree insertion helpers.
> > > - Address the sashiko findings: avoid calling mode_fn under sysctl_lock,
> > >   validate the effective maxlen against the context object, and reject
> > >   NO_DATA fields paired with standard handlers that require data.
> > > 
> > > This is the first part of the conversion. Network sysctls and other
> > > subsystem-specific users will follow in separate series for review by
> > > their maintainers.
> > > 
> > > 
> > > Alexey Gladkov (5):
> > >   proc: sysctl: address table entries by index
> > >   sysctl: add typed field descriptors
> > >   sysctl: ipc: use typed fields for IPC namespace sysctls
> > >   sysctl: mq: use typed fields for IPC namespace sysctls
> > >   sysctl: use typed fields for ucount limits
> > 
> > Gentle reminder about the patchset.
> Thx for persisting and sorry for the late reply.
> 
> The more I look at this, the more I am convinced that the first problem
> that we should address is having a .data, .extra1 and .extra2 as void
> pointers. Once that is out of the way, then we can focus on getting rid
> of the kmemdup of the ctl_tables.
> 
> Motivation
> ==========
> 
> Here are the motivational points for this series:
> 1. Remove the per-instance allocation thereby reducing the memory
>    footprint
>   * This one is relevant for instances with lots of NSs.
> 
> 2. Remove the possibility of mistakenly associating one variable with a
>    different sysctl name (because of un-synced changes)
>   * This one is the least important for me. Keeping it synced is a
>     little scary but something that I would be willing to live with.
> 
> 3. Type checking .data, .extra1 and .extra2. "unambiguous pointer" that
>    answers what it is.
>   * I think if we are serious about type checking, we need to fix the
>     existing (potentially uneeded) void pointers (.data, extra{1,2}).
>     Which is not an easy as there are callers that (mis)use these in
>     different ways. This has been discussed before (in [1,2,3] among
>     others)
> 
> 4. Don't bleed caller structs/types/logic into sysctl.
>   * This one is mine and is the reason I really don't want it done in
>     the manner that you propose. IMO, having network (or other callers
>     logic) inside sysctl makes no sense.
> 
> I'll come back to these series after having yet another look at the void
> pointers in ctl_table.

In that case, I'll step back with my patches for now.

Thanks for review.

> Best
> 
> [1] https://lore.kernel.org/all/87zgpte9o4.fsf@email.froward.int.ebiederm.org
> [2] https://lore.kernel.org/all/875xyczpzm.fsf@email.froward.int.ebiederm.org
> [3] https://lore.kernel.org/all/cover.1739115369.git.wen.yang@linux.dev
> 
> 



-- 
Rgrds, legion


      reply	other threads:[~2026-10-23  9:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 10:54 [PATCH v2 0/6] " Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 1/6] proc: sysctl: address table entries by index Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 2/6] sysctl: add unsigned int limit constants Alexey Gladkov
2026-09-24 13:29   ` Joel Granados
2026-09-24 15:08     ` Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 3/6] sysctl: add typed field descriptors Alexey Gladkov
2026-09-24 13:29   ` Joel Granados
2026-09-24 15:48     ` Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 4/6] sysctl: ipc: use typed fields for IPC namespace sysctls Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 5/6] sysctl: mq: " Alexey Gladkov
2026-09-21 10:54 ` [PATCH v2 6/6] sysctl: use typed fields for ucount limits Alexey Gladkov
2026-09-24 13:29 ` [PATCH v2 0/6] sysctl: add typed field descriptors Joel Granados
2026-09-24 14:46   ` Alexey Gladkov
2026-09-24 14:38 ` Joel Granados
2026-09-26 16:22 ` [PATCH v3 0/5] " Alexey Gladkov
2026-09-26 16:22   ` [PATCH v3 1/5] proc: sysctl: address table entries by index Alexey Gladkov
2026-09-26 16:22   ` [PATCH v3 2/5] sysctl: add typed field descriptors Alexey Gladkov
2026-09-26 16:22   ` [PATCH v3 3/5] sysctl: ipc: use typed fields for IPC namespace sysctls Alexey Gladkov
2026-09-26 16:22   ` [PATCH v3 4/5] sysctl: mq: " Alexey Gladkov
2026-09-26 16:22   ` [PATCH v3 5/5] sysctl: use typed fields for ucount limits Alexey Gladkov
2026-10-12 13:43   ` [PATCH v3 0/5] sysctl: add typed field descriptors Alexey Gladkov
2026-10-19 12:13     ` Joel Granados
2026-10-22 14:04     ` Joel Granados
2026-10-23  9:17       ` Alexey Gladkov [this message]

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=atsmOMeBfkMQgzQV@example.org \
    --to=legion@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=joel.granados@kernel.org \
    --cc=kees@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®