diff options
author | Kees Cook <kees.cook@canonical.com> | 2010-02-03 18:36:43 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-02-03 22:20:12 -0500 |
commit | 002345925e6c45861f60db6f4fc6236713fd8847 (patch) | |
tree | d7849eafe1755116597166bbebf43e2bee86cb76 /kernel | |
parent | 0719aaf5ead7555b7b7a4a080ebf2826a871384e (diff) |
syslog: distinguish between /proc/kmsg and syscalls
This allows the LSM to distinguish between syslog functions originating
from /proc/kmsg access and direct syscalls. By default, the commoncaps
will now no longer require CAP_SYS_ADMIN to read an opened /proc/kmsg
file descriptor. For example the kernel syslog reader can now drop
privileges after opening /proc/kmsg, instead of staying privileged with
CAP_SYS_ADMIN. MAC systems that implement security_syslog have unchanged
behavior.
Signed-off-by: Kees Cook <kees.cook@canonical.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/printk.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 17463ca2e229..809cf9a258a0 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/kexec.h> | 35 | #include <linux/kexec.h> |
36 | #include <linux/ratelimit.h> | 36 | #include <linux/ratelimit.h> |
37 | #include <linux/kmsg_dump.h> | 37 | #include <linux/kmsg_dump.h> |
38 | #include <linux/syslog.h> | ||
38 | 39 | ||
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
40 | 41 | ||
@@ -273,14 +274,14 @@ static inline void boot_delay_msec(void) | |||
273 | * 9 -- Return number of unread characters in the log buffer | 274 | * 9 -- Return number of unread characters in the log buffer |
274 | * 10 -- Return size of the log buffer | 275 | * 10 -- Return size of the log buffer |
275 | */ | 276 | */ |
276 | int do_syslog(int type, char __user *buf, int len) | 277 | int do_syslog(int type, char __user *buf, int len, bool from_file) |
277 | { | 278 | { |
278 | unsigned i, j, limit, count; | 279 | unsigned i, j, limit, count; |
279 | int do_clear = 0; | 280 | int do_clear = 0; |
280 | char c; | 281 | char c; |
281 | int error = 0; | 282 | int error = 0; |
282 | 283 | ||
283 | error = security_syslog(type); | 284 | error = security_syslog(type, from_file); |
284 | if (error) | 285 | if (error) |
285 | return error; | 286 | return error; |
286 | 287 | ||
@@ -417,7 +418,7 @@ out: | |||
417 | 418 | ||
418 | SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) | 419 | SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) |
419 | { | 420 | { |
420 | return do_syslog(type, buf, len); | 421 | return do_syslog(type, buf, len, SYSLOG_FROM_CALL); |
421 | } | 422 | } |
422 | 423 | ||
423 | /* | 424 | /* |