Re: [PATCH 4/4] test: validate sysctl_writes_strict

From: Randy Dunlap
Date: Sat May 03 2014 - 10:43:40 EST


On 05/01/2014 02:26 PM, Kees Cook wrote:
This adds several behavioral tests to sysctl string and number writing
to detect unexpected cases that behaved differently when the sysctl
kernel.sysctl_writes_strict != 1.


Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
kernel/sysctl.c | 4 +-
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/sysctl/Makefile | 19 ++++
tools/testing/selftests/sysctl/common_tests | 109 +++++++++++++++++++++++
tools/testing/selftests/sysctl/run_numerictests | 10 +++
tools/testing/selftests/sysctl/run_stringtests | 77 ++++++++++++++++
6 files changed, 218 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/sysctl/Makefile
create mode 100644 tools/testing/selftests/sysctl/common_tests
create mode 100644 tools/testing/selftests/sysctl/run_numerictests
create mode 100644 tools/testing/selftests/sysctl/run_stringtests

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d5bee7949e4a..51bbf904d694 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1783,8 +1783,8 @@ static int _proc_do_string(char *data, int maxlen, int write,

static void warn_sysctl_write(struct ctl_table *table)
{
- pr_warn("%s wrote to %s when file position was not 0!\n",
- current->task_comm, table->procname);
+ pr_warn("write to %s by %s used a non-zero file position!\n",
+ table->procname, current->comm);
pr_warn("This will not be supported in the future.\n");
pr_warn("To silence warning, set kernel.sysctl_writes_strict = -1\n");
}

Why is this patch part of the test patch?

--
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/