[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1520885744-1546-3-git-send-email-longman@redhat.com>
Date: Mon, 12 Mar 2018 16:15:40 -0400
From: Waiman Long <longman@...hat.com>
To: "Luis R. Rodriguez" <mcgrof@...nel.org>,
Kees Cook <keescook@...omium.org>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>,
Waiman Long <longman@...hat.com>
Subject: [PATCH v4 2/6] proc/sysctl: Check for invalid flags bits
Checking code is added to check for invalid flags in the ctl_table
and return error if an unknown flag is used.
Signed-off-by: Waiman Long <longman@...hat.com>
---
fs/proc/proc_sysctl.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 493c975..67c0c82 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1092,6 +1092,16 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
return err;
}
+static int sysctl_check_flags(const char *path, struct ctl_table *table)
+{
+ int err = 0;
+
+ if (table->flags & ~CTL_TABLE_FLAGS_ALL)
+ err = sysctl_err(path, table, "invalid flags");
+
+ return err;
+}
+
static int sysctl_check_table(const char *path, struct ctl_table *table)
{
int err = 0;
@@ -1111,6 +1121,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
(table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
if (!table->data)
err |= sysctl_err(path, table, "No data");
+ if (table->flags)
+ err |= sysctl_check_flags(path, table);
if (!table->maxlen)
err |= sysctl_err(path, table, "No maxlen");
else
--
1.8.3.1
Powered by blists - more mailing lists