Commit d73840ec authored by Xiaoming Ni's avatar Xiaoming Ni Committed by Linus Torvalds

sysctl: use const for typically used max/min proc sysctls

When proc_dointvec_minmax() or proc_doulongvec_minmax() are used we are
using the extra1 and extra2 parameters on the sysctl table only for a
min and max boundary, these extra1 and extra2 arguments are then used
for read-only operations.  So make them const to reflect this.

[mcgrof@kernel.org: commit log love]

Link: https://lkml.kernel.org/r/20211123202347.818157-7-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Kees Cook <keescook@chromium.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Qing Wang <wangqing@vivo.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Stephen Kitt <steve@sk2.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Julia Lawall <julia.lawall@inria.fr>
Cc: Lukas Middendorf <kernel@tuxforce.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Phillip Potter <phil@philpotter.co.uk>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f628867d
...@@ -108,27 +108,26 @@ ...@@ -108,27 +108,26 @@
/* Constants used for minimum and maximum */ /* Constants used for minimum and maximum */
static unsigned long zero_ul; static const unsigned long zero_ul;
static unsigned long one_ul = 1; static const unsigned long one_ul = 1;
static unsigned long long_max = LONG_MAX; static const unsigned long long_max = LONG_MAX;
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
static int ten_thousand = 10000; static const int ten_thousand = 10000;
#endif #endif
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
static int six_hundred_forty_kb = 640 * 1024; static const int six_hundred_forty_kb = 640 * 1024;
#endif #endif
/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535; static const int maxolduid = 65535;
static int minolduid; static const int minolduid;
static const int ngroups_max = NGROUPS_MAX; static const int ngroups_max = NGROUPS_MAX;
static const int cap_last_cap = CAP_LAST_CAP; static const int cap_last_cap = CAP_LAST_CAP;
#ifdef CONFIG_INOTIFY_USER #ifdef CONFIG_INOTIFY_USER
#include <linux/inotify.h> #include <linux/inotify.h>
#endif #endif
...@@ -172,8 +171,8 @@ int sysctl_legacy_va_layout; ...@@ -172,8 +171,8 @@ int sysctl_legacy_va_layout;
#endif #endif
#ifdef CONFIG_COMPACTION #ifdef CONFIG_COMPACTION
static int min_extfrag_threshold; static const int min_extfrag_threshold;
static int max_extfrag_threshold = 1000; static const int max_extfrag_threshold = 1000;
#endif #endif
#endif /* CONFIG_SYSCTL */ #endif /* CONFIG_SYSCTL */
...@@ -2177,8 +2176,8 @@ static struct ctl_table kern_table[] = { ...@@ -2177,8 +2176,8 @@ static struct ctl_table kern_table[] = {
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &minolduid, .extra1 = (void *)&minolduid,
.extra2 = &maxolduid, .extra2 = (void *)&maxolduid,
}, },
{ {
.procname = "overflowgid", .procname = "overflowgid",
...@@ -2186,8 +2185,8 @@ static struct ctl_table kern_table[] = { ...@@ -2186,8 +2185,8 @@ static struct ctl_table kern_table[] = {
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &minolduid, .extra1 = (void *)&minolduid,
.extra2 = &maxolduid, .extra2 = (void *)&maxolduid,
}, },
#ifdef CONFIG_S390 #ifdef CONFIG_S390
{ {
...@@ -2261,7 +2260,7 @@ static struct ctl_table kern_table[] = { ...@@ -2261,7 +2260,7 @@ static struct ctl_table kern_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO, .extra1 = SYSCTL_ZERO,
.extra2 = &ten_thousand, .extra2 = (void *)&ten_thousand,
}, },
{ {
.procname = "printk_devkmsg", .procname = "printk_devkmsg",
...@@ -2473,7 +2472,7 @@ static struct ctl_table kern_table[] = { ...@@ -2473,7 +2472,7 @@ static struct ctl_table kern_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = perf_event_max_stack_handler, .proc_handler = perf_event_max_stack_handler,
.extra1 = SYSCTL_ZERO, .extra1 = SYSCTL_ZERO,
.extra2 = &six_hundred_forty_kb, .extra2 = (void *)&six_hundred_forty_kb,
}, },
{ {
.procname = "perf_event_max_contexts_per_stack", .procname = "perf_event_max_contexts_per_stack",
...@@ -2629,7 +2628,7 @@ static struct ctl_table vm_table[] = { ...@@ -2629,7 +2628,7 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(dirty_background_bytes), .maxlen = sizeof(dirty_background_bytes),
.mode = 0644, .mode = 0644,
.proc_handler = dirty_background_bytes_handler, .proc_handler = dirty_background_bytes_handler,
.extra1 = &one_ul, .extra1 = (void *)&one_ul,
}, },
{ {
.procname = "dirty_ratio", .procname = "dirty_ratio",
...@@ -2646,7 +2645,7 @@ static struct ctl_table vm_table[] = { ...@@ -2646,7 +2645,7 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(vm_dirty_bytes), .maxlen = sizeof(vm_dirty_bytes),
.mode = 0644, .mode = 0644,
.proc_handler = dirty_bytes_handler, .proc_handler = dirty_bytes_handler,
.extra1 = &dirty_bytes_min, .extra1 = (void *)&dirty_bytes_min,
}, },
{ {
.procname = "dirty_writeback_centisecs", .procname = "dirty_writeback_centisecs",
...@@ -2760,8 +2759,8 @@ static struct ctl_table vm_table[] = { ...@@ -2760,8 +2759,8 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &min_extfrag_threshold, .extra1 = (void *)&min_extfrag_threshold,
.extra2 = &max_extfrag_threshold, .extra2 = (void *)&max_extfrag_threshold,
}, },
{ {
.procname = "compact_unevictable_allowed", .procname = "compact_unevictable_allowed",
...@@ -3047,8 +3046,8 @@ static struct ctl_table fs_table[] = { ...@@ -3047,8 +3046,8 @@ static struct ctl_table fs_table[] = {
.maxlen = sizeof(files_stat.max_files), .maxlen = sizeof(files_stat.max_files),
.mode = 0644, .mode = 0644,
.proc_handler = proc_doulongvec_minmax, .proc_handler = proc_doulongvec_minmax,
.extra1 = &zero_ul, .extra1 = (void *)&zero_ul,
.extra2 = &long_max, .extra2 = (void *)&long_max,
}, },
{ {
.procname = "nr_open", .procname = "nr_open",
...@@ -3072,8 +3071,8 @@ static struct ctl_table fs_table[] = { ...@@ -3072,8 +3071,8 @@ static struct ctl_table fs_table[] = {
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &minolduid, .extra1 = (void *)&minolduid,
.extra2 = &maxolduid, .extra2 = (void *)&maxolduid,
}, },
{ {
.procname = "overflowgid", .procname = "overflowgid",
...@@ -3081,8 +3080,8 @@ static struct ctl_table fs_table[] = { ...@@ -3081,8 +3080,8 @@ static struct ctl_table fs_table[] = {
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &minolduid, .extra1 = (void *)&minolduid,
.extra2 = &maxolduid, .extra2 = (void *)&maxolduid,
}, },
#ifdef CONFIG_FILE_LOCKING #ifdef CONFIG_FILE_LOCKING
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment