diff options
author | Vasily Averin <vvs@virtuozzo.com> | 2015-06-25 18:01:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 20:00:39 -0400 |
commit | 3ea4331c60be3eee4c97e5ddabad95399f879b76 (patch) | |
tree | 6977f3c7a8a72003f3b324de5ce4bb490274ff53 | |
parent | d194e5d666225b04c7754471df0948f645b6ab3a (diff) |
check_syslog_permissions() cleanup
Patch fixes drawbacks in heck_syslog_permissions() noticed by AKPM:
"from_file handling makes me cry.
That's not a boolean - it's an enumerated value with two values
currently defined.
But the code in check_syslog_permissions() treats it as a boolean and
also hardwires the knowledge that SYSLOG_FROM_PROC == 1 (or == `true`).
And the name is wrong: it should be called from_proc to match
SYSLOG_FROM_PROC."
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Josh Boyer <jwboyer@redhat.com>
Cc: Eric Paris <eparis@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/syslog.h | 6 | ||||
-rw-r--r-- | kernel/printk/printk.c | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/syslog.h b/include/linux/syslog.h index 4b7b875a7ce1..c3a7f0cc3a27 100644 --- a/include/linux/syslog.h +++ b/include/linux/syslog.h | |||
@@ -47,12 +47,12 @@ | |||
47 | #define SYSLOG_FROM_READER 0 | 47 | #define SYSLOG_FROM_READER 0 |
48 | #define SYSLOG_FROM_PROC 1 | 48 | #define SYSLOG_FROM_PROC 1 |
49 | 49 | ||
50 | int do_syslog(int type, char __user *buf, int count, bool from_file); | 50 | int do_syslog(int type, char __user *buf, int count, int source); |
51 | 51 | ||
52 | #ifdef CONFIG_PRINTK | 52 | #ifdef CONFIG_PRINTK |
53 | int check_syslog_permissions(int type, bool from_file); | 53 | int check_syslog_permissions(int type, int source); |
54 | #else | 54 | #else |
55 | static inline int check_syslog_permissions(int type, bool from_file) | 55 | static inline int check_syslog_permissions(int type, int source) |
56 | { | 56 | { |
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 45fa8c88ac47..de553849f3ac 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
@@ -489,13 +489,13 @@ static int syslog_action_restricted(int type) | |||
489 | type != SYSLOG_ACTION_SIZE_BUFFER; | 489 | type != SYSLOG_ACTION_SIZE_BUFFER; |
490 | } | 490 | } |
491 | 491 | ||
492 | int check_syslog_permissions(int type, bool from_file) | 492 | int check_syslog_permissions(int type, int source) |
493 | { | 493 | { |
494 | /* | 494 | /* |
495 | * If this is from /proc/kmsg and we've already opened it, then we've | 495 | * If this is from /proc/kmsg and we've already opened it, then we've |
496 | * already done the capabilities checks at open time. | 496 | * already done the capabilities checks at open time. |
497 | */ | 497 | */ |
498 | if (from_file && type != SYSLOG_ACTION_OPEN) | 498 | if (source == SYSLOG_FROM_PROC && type != SYSLOG_ACTION_OPEN) |
499 | goto ok; | 499 | goto ok; |
500 | 500 | ||
501 | if (syslog_action_restricted(type)) { | 501 | if (syslog_action_restricted(type)) { |
@@ -1290,13 +1290,13 @@ static int syslog_print_all(char __user *buf, int size, bool clear) | |||
1290 | return len; | 1290 | return len; |
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | int do_syslog(int type, char __user *buf, int len, bool from_file) | 1293 | int do_syslog(int type, char __user *buf, int len, int source) |
1294 | { | 1294 | { |
1295 | bool clear = false; | 1295 | bool clear = false; |
1296 | static int saved_console_loglevel = LOGLEVEL_DEFAULT; | 1296 | static int saved_console_loglevel = LOGLEVEL_DEFAULT; |
1297 | int error; | 1297 | int error; |
1298 | 1298 | ||
1299 | error = check_syslog_permissions(type, from_file); | 1299 | error = check_syslog_permissions(type, source); |
1300 | if (error) | 1300 | if (error) |
1301 | goto out; | 1301 | goto out; |
1302 | 1302 | ||
@@ -1379,7 +1379,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file) | |||
1379 | syslog_prev = 0; | 1379 | syslog_prev = 0; |
1380 | syslog_partial = 0; | 1380 | syslog_partial = 0; |
1381 | } | 1381 | } |
1382 | if (from_file) { | 1382 | if (source == SYSLOG_FROM_PROC) { |
1383 | /* | 1383 | /* |
1384 | * Short-cut for poll(/"proc/kmsg") which simply checks | 1384 | * Short-cut for poll(/"proc/kmsg") which simply checks |
1385 | * for pending data, not the size; return the count of | 1385 | * for pending data, not the size; return the count of |