From: Wen Yang <wenyang.linux@foxmail.com>
To: Joel Granados <j.granados@samsung.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>,
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>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] sysctl: introduce sysctl SYSCTL_U8_MAX and SYSCTL_LONG_S32_MAX
Date: Mon, 26 Feb 2024 22:59:11 +0800 [thread overview]
Message-ID: <tencent_3716CF645529D4674138937EE94FCC737E08@qq.com> (raw)
In-Reply-To: <20240225201658.h6nod4c4uxclq53a@joelS2.panther.com>
On 2024/2/26 04:16, Joel Granados wrote:
> On Sun, Feb 25, 2024 at 12:05:31PM +0800, wenyang.linux@foxmail.com wrote:
>> From: Wen Yang <wenyang.linux@foxmail.com>
>>
>> The boundary check of multiple modules uses these static variables (such as
>> two_five_five, n_65535, ue_int_max, etc), and they are also not changed.
>> Therefore, add them to the shared sysctl_vals and sysctl_long_vals to avoid
>> duplication.
>>
>> Also rearranged sysctl_vals and sysctl_long_vals in numerical order.
>>
>> 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: "David S. Miller" <davem@davemloft.net>
>> Cc: David Ahern <dsahern@kernel.org>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Cc: Jakub Kicinski <kuba@kernel.org>
>> Cc: Paolo Abeni <pabeni@redhat.com>
>> Cc: netdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>> include/linux/sysctl.h | 15 +++++++++------
>> kernel/sysctl.c | 4 ++--
>> 2 files changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
>> index ee7d33b89e9e..b7a13e4c411c 100644
>> --- a/include/linux/sysctl.h
>> +++ b/include/linux/sysctl.h
>> @@ -45,19 +45,22 @@ struct ctl_dir;
>> #define SYSCTL_FOUR ((void *)&sysctl_vals[4])
>> #define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[5])
>> #define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[6])
>> -#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[7])
>> -#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8])
>> -#define SYSCTL_INT_MAX ((void *)&sysctl_vals[9])
>> +#define SYSCTL_U8_MAX ((void *)&sysctl_vals[7])
>> +#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[8])
>> +#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[9])
>> +#define SYSCTL_U16_MAX ((void *)&sysctl_vals[10])
>> +#define SYSCTL_INT_MAX ((void *)&sysctl_vals[11])
>> +#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[12])
>>
>> /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
>> -#define SYSCTL_MAXOLDUID ((void *)&sysctl_vals[10])
>> -#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[11])
>> +#define SYSCTL_MAXOLDUID SYSCTL_U16_MAX
>>
>> extern const int sysctl_vals[];
>>
>> #define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0])
>> #define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1])
>> -#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2])
>> +#define SYSCTL_LONG_S32_MAX ((void *)&sysctl_long_vals[2])
>> +#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[3])
>>
>> extern const unsigned long sysctl_long_vals[];
>>
>> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>> index 157f7ce2942d..e1e00937cb29 100644
>> --- a/kernel/sysctl.c
>> +++ b/kernel/sysctl.c
>> @@ -82,10 +82,10 @@
>> #endif
>>
>> /* shared constants to be used in various sysctls */
>> -const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
>> +const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, U8_MAX, 1000, 3000, 65535, INT_MAX, -1, };
> Why do you insert the new values instead of just appending?
> I figure that the patch would be much smaller if you appended.
>
Thanks.
We originally intended to rearrange this array in numerical order, but
now it seems unnecessary.
We will follow your suggestions and send v2 later.
--
Best wishes,
Wen
>> EXPORT_SYMBOL(sysctl_vals);
>>
>> -const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
>> +const unsigned long sysctl_long_vals[] = { 0, 1, S32_MAX, LONG_MAX, };
> Same here. Why insert instead of append?
>> EXPORT_SYMBOL_GPL(sysctl_long_vals);
>>
>> #if defined(CONFIG_SYSCTL)
>> --
>> 2.25.1
>>
>
next prev parent reply other threads:[~2024-02-26 14:59 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 ` wenyang.linux
2024-02-25 20:16 ` Joel Granados
2024-02-26 14:59 ` Wen Yang [this message]
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
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=tencent_3716CF645529D4674138937EE94FCC737E08@qq.com \
--to=wenyang.linux@foxmail.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=netdev@vger.kernel.org \
--cc=pabeni@redhat.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®