Commit 7e2d1469 authored by Kees Cook's avatar Kees Cook Committed by Greg Kroah-Hartman

sysctl: fix write access to dmesg_restrict/kptr_restrict

commit 620f6e8e upstream.

Commit bfdc0b49 adds code to restrict access to dmesg_restrict,
however, it incorrectly alters kptr_restrict rather than
dmesg_restrict.

The original patch from Richard Weinberger
(https://lkml.org/lkml/2011/3/14/362) alters dmesg_restrict as
expected, and so the patch seems to have been misapplied.

This adds the CAP_SYS_ADMIN check to both dmesg_restrict and
kptr_restrict, since both are sensitive.
Reported-by: default avatarPhillip Lougher <plougher@redhat.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
Acked-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aba6427f
...@@ -166,7 +166,7 @@ static int proc_taint(struct ctl_table *table, int write, ...@@ -166,7 +166,7 @@ static int proc_taint(struct ctl_table *table, int write,
#endif #endif
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
static int proc_dmesg_restrict(struct ctl_table *table, int write, static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos); void __user *buffer, size_t *lenp, loff_t *ppos);
#endif #endif
...@@ -713,7 +713,7 @@ static struct ctl_table kern_table[] = { ...@@ -713,7 +713,7 @@ static struct ctl_table kern_table[] = {
.data = &dmesg_restrict, .data = &dmesg_restrict,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax_sysadmin,
.extra1 = &zero, .extra1 = &zero,
.extra2 = &one, .extra2 = &one,
}, },
...@@ -722,7 +722,7 @@ static struct ctl_table kern_table[] = { ...@@ -722,7 +722,7 @@ static struct ctl_table kern_table[] = {
.data = &kptr_restrict, .data = &kptr_restrict,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dmesg_restrict, .proc_handler = proc_dointvec_minmax_sysadmin,
.extra1 = &zero, .extra1 = &zero,
.extra2 = &two, .extra2 = &two,
}, },
...@@ -2422,7 +2422,7 @@ static int proc_taint(struct ctl_table *table, int write, ...@@ -2422,7 +2422,7 @@ static int proc_taint(struct ctl_table *table, int write,
} }
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
static int proc_dmesg_restrict(struct ctl_table *table, int write, static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos) void __user *buffer, size_t *lenp, loff_t *ppos)
{ {
if (write && !capable(CAP_SYS_ADMIN)) if (write && !capable(CAP_SYS_ADMIN))
......
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