mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: wenyang.linux@foxmail.com
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	 Kees Cook <keescook@chromium.org>,
	 Joel Granados <j.granados@samsung.com>,
	Christian Brauner <brauner@kernel.org>,
	 davem@davemloft.net,  David Ahern <dsahern@kernel.org>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/8] ucounts: delete these duplicate static variables ue_zero and ue_int_max
Date: Sun, 25 Feb 2024 06:29:33 -0600	[thread overview]
Message-ID: <875xyczpzm.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <tencent_AA60553AD4DF41859328E9CACC367EFDCF08@qq.com> (wenyang linux's message of "Sun, 25 Feb 2024 12:05:38 +0800")

wenyang.linux@foxmail.com writes:

> From: Wen Yang <wenyang.linux@foxmail.com>
>
> Since these static variables (ue_zero and ue_int_max) are only used for
> boundary checks and will not be changed, remove it and use the ones in
> our shared const array.

What happened to the plans to kill the shared const array?

You can still save a lot more by turning .extra1 and .extra2
into longs instead of keeping them as pointers and needing
constants to be pointed at somewhere.

As I recall the last version of this actually broke the code,
(but not on little endian).

This one if the constants are properly named looks better
than that, but I don't see any reason why you want shared
constants for such a handful of things.  Especially when
it has proven to be error prone in the past.

The only people I can see who find a significant benefit by
consolidating all of the constants into one place are people who know
how to stomp kernel memory.

Eric


>
> Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Joel Granados <j.granados@samsung.com>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: Shuah Khan <skhan@linuxfoundation.org>
> Cc: linux-kernel@vger.kernel.org
> ---
>  kernel/ucount.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/ucount.c b/kernel/ucount.c
> index 4aa6166cb856..05bbba02ae4f 100644
> --- a/kernel/ucount.c
> +++ b/kernel/ucount.c
> @@ -58,17 +58,14 @@ static struct ctl_table_root set_root = {
>  	.permissions = set_permissions,
>  };
>  
> -static long ue_zero = 0;
> -static long ue_int_max = INT_MAX;
> -
>  #define UCOUNT_ENTRY(name)					\
>  	{							\
>  		.procname	= name,				\
>  		.maxlen		= sizeof(long),			\
>  		.mode		= 0644,				\
>  		.proc_handler	= proc_doulongvec_minmax,	\
> -		.extra1		= &ue_zero,			\
> -		.extra2		= &ue_int_max,			\
> +		.extra1		= SYSCTL_LONG_ZERO,		\
> +		.extra2		= SYSCTL_LONG_S32_MAX,		\
>  	}
>  static struct ctl_table user_table[] = {
>  	UCOUNT_ENTRY("max_user_namespaces"),

  reply	other threads:[~2024-02-25 13:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240225040538.845899-1-wenyang.linux@foxmail.com>
2024-02-25  4:05 ` [PATCH 1/8] sysctl: introduce sysctl SYSCTL_U8_MAX and SYSCTL_LONG_S32_MAX wenyang.linux
2024-02-25 20:16   ` Joel Granados
2024-02-26 14:59     ` Wen Yang
2024-02-25  4:05 ` [PATCH 2/8] rxrpc: delete these duplicate static variables n_65535 and four wenyang.linux
2024-02-25  4:05 ` [PATCH 3/8] net: ipv6: delete these duplicate static variables two_five_five and minus_one wenyang.linux
2024-02-25  4:05 ` [PATCH 4/8] svcrdma: delete the duplicate static variables zero wenyang.linux
2024-02-25  4:05 ` [PATCH 5/8] sysctl: delete these duplicate static variables i_zero and i_one_hundred wenyang.linux
2024-02-25  4:05 ` [PATCH 6/8] epoll: delete these duplicate static variables long_zero and long_max wenyang.linux
2024-02-25  4:05 ` [PATCH 7/8] fs: inotify: delete these duplicate static variables it_zero and it_int_max wenyang.linux
2024-02-25  4:05 ` [PATCH 8/8] ucounts: delete these duplicate static variables ue_zero and ue_int_max wenyang.linux
2024-02-25 12:29   ` Eric W. Biederman [this message]
2024-02-25 15:21     ` Wen Yang
2024-03-21 14:28     ` 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=875xyczpzm.fsf@email.froward.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=brauner@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=j.granados@samsung.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=skhan@linuxfoundation.org \
    --cc=wenyang.linux@foxmail.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®