sysctl: add unsigned int range support
To keep parity with regular int interfaces provide the an unsigned int proc_douintvec_minmax() which allows you to specify a range of allowed valid numbers. Adding proc_douintvec_minmax_sysadmin() is easy but we can wait for an actual user for that. Link: http://lkml.kernel.org/r/20170519033554.18592-6-mcgrof@kernel.org Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Acked-by: Kees Cook <keescook@chromium.org> Cc: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Kees Cook <keescook@chromium.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Ingo Molnar <mingo@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
4f2fec00af
commit
61d9b56a89
@@ -1065,7 +1065,8 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (table->proc_handler == proc_douintvec) {
|
||||
if ((table->proc_handler == proc_douintvec) ||
|
||||
(table->proc_handler == proc_douintvec_minmax)) {
|
||||
if (table->maxlen != sizeof(unsigned int))
|
||||
err |= sysctl_err(path, table, "array now allowed");
|
||||
}
|
||||
@@ -1083,6 +1084,7 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
|
||||
if ((table->proc_handler == proc_dostring) ||
|
||||
(table->proc_handler == proc_dointvec) ||
|
||||
(table->proc_handler == proc_douintvec) ||
|
||||
(table->proc_handler == proc_douintvec_minmax) ||
|
||||
(table->proc_handler == proc_dointvec_minmax) ||
|
||||
(table->proc_handler == proc_dointvec_jiffies) ||
|
||||
(table->proc_handler == proc_dointvec_userhz_jiffies) ||
|
||||
|
||||
Reference in New Issue
Block a user