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 v2 2/6] sysctl: add unsigned int limit constants
Date: Thu, 24 Sep 2026 17:08:16 +0200	[thread overview]
Message-ID: <arU84H_lA0V3lwgV@example.org> (raw)
In-Reply-To: <hc3jlqepedad5jbxz5rpskjktvbjcohorybc6kbtd7wtpajqi2@zftmndyhlw7a>

[-- Attachment #1: Type: text/plain, Size: 3697 bytes --]

On Thu, Sep 24, 2026 at 03:29:35PM +0200, Joel Granados wrote:
> On Mon, Sep 21, 2026 at 12:54:49PM +0200, Alexey Gladkov wrote:
> > Some sysctl handlers use unsigned int storage for their limit arguments.
> > In particular, proc_dou8vec_minmax() expects extra1 and extra2 to point
> > to unsigned int values even though the controlled data is an u8.
> 
> This one reads like a fix as opposed to part of your series. Is it
> strictly needed for what you are proposing here?

Yeah, it turned out a bit wonky. Sorry.

What I was trying to say is that we don't have shared constants for
`unsigned int`. It doesn't matter right now since the size is the same,
but if we check the type at compile time, then it becomes important.

> > 
> > Provide shared unsigned int constants so typed sysctl descriptors can
> > pass correctly typed min and max pointers without casting the existing
> > int constants.
> > 
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > ---
> >  include/linux/sysctl.h | 7 +++++++
> >  kernel/sysctl.c        | 3 +++
> >  2 files changed, 10 insertions(+)
> > 
> > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> > index e5d7226ab6f5..7139a4c72736 100644
> > --- a/include/linux/sysctl.h
> > +++ b/include/linux/sysctl.h
> > @@ -59,6 +59,12 @@ extern const int sysctl_vals[];
> >  #define SYSCTL_LONG_ONE		((void *)&sysctl_long_vals[1])
> >  #define SYSCTL_LONG_MAX		((void *)&sysctl_long_vals[2])
> >  
> > +#define SYSCTL_UINT_ZERO	((unsigned int *)&sysctl_uint_vals[0])
> > +#define SYSCTL_UINT_ONE		((unsigned int *)&sysctl_uint_vals[1])
> > +#define SYSCTL_UINT_TWO		((unsigned int *)&sysctl_uint_vals[2])
> > +#define SYSCTL_UINT_THREE	((unsigned int *)&sysctl_uint_vals[3])
> > +#define SYSCTL_UINT_FOUR	((unsigned int *)&sysctl_uint_vals[4])
> 
> I would really like to avoid that. Its one of the things that should
> probably go away in the future [1], [2], [3], [4]
> 
> [1] https://lore.kernel.org/all/875xyczpzm.fsf@email.froward.int.ebiederm.org/
> [2] https://lore.kernel.org/all/tencent_C5E6023F97E7CC2A046AAEA09BC9ACF43907@qq.com/
> [3] https://lore.kernel.org/all/cover.1739115369.git.wen.yang@linux.dev/
> [4] https://lore.kernel.org/all/qnrzl4tjlgw5rzlvxavr3pt7fhkslnm4dd62q7uqzb3mfoa2jg@fuayx77rfcs6/

I don't mind removing them and using constants in the relevant source
files. I added these constants because they are used in the net subsystem.

As example:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/mptcp/ctrl.c#n294
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/ipc/ipc_sysctl.c#n110

> 
> > +
> >  /*
> >   *
> >   * "dir" originates from read_iter (dir = 0) or write_iter (dir = 1)
> > @@ -73,6 +79,7 @@ extern const int sysctl_vals[];
> >  #define SYSCTL_KERN_TO_USER(dir) (!dir)
> >  
> >  extern const unsigned long sysctl_long_vals[];
> > +extern const unsigned int sysctl_uint_vals[];
> >  
> >  typedef int proc_handler(const struct ctl_table *ctl, int dir, void *buf,
> >  			 size_t *lenp, loff_t *ppos);
> > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > index f7b75985d542..54edaa2fd5d5 100644
> > --- a/kernel/sysctl.c
> > +++ b/kernel/sysctl.c
> > @@ -29,6 +29,9 @@ EXPORT_SYMBOL(sysctl_vals);
> >  const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
> >  EXPORT_SYMBOL_GPL(sysctl_long_vals);
> >  
> > +const unsigned int sysctl_uint_vals[] = { 0, 1, 2, 3, 4 };
> > +EXPORT_SYMBOL_GPL(sysctl_uint_vals);
> > +
> >  #if defined(CONFIG_SYSCTL)
> >  
> >  /* Constants used for minimum and maximum */
> > -- 
> > 2.55.0
> > 



-- 
Rgrds, legion


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-09-24 15:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 10:54 [PATCH v2 0/6] sysctl: add typed field descriptors 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 [this message]
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

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=arU84H_lA0V3lwgV@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®