aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index b2ebaee8c377..4642a5c439eb 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -43,12 +43,6 @@
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44 44
45/* 45/*
46 * for_each_console() allows you to iterate on each console
47 */
48#define for_each_console(con) \
49 for (con = console_drivers; con != NULL; con = con->next)
50
51/*
52 * Architectures can override it: 46 * Architectures can override it:
53 */ 47 */
54void asmlinkage __attribute__((weak)) early_printk(const char *fmt, ...) 48void asmlinkage __attribute__((weak)) early_printk(const char *fmt, ...)
@@ -261,6 +255,12 @@ static inline void boot_delay_msec(void)
261} 255}
262#endif 256#endif
263 257
258#ifdef CONFIG_SECURITY_DMESG_RESTRICT
259int dmesg_restrict = 1;
260#else
261int dmesg_restrict;
262#endif
263
264int do_syslog(int type, char __user *buf, int len, bool from_file) 264int do_syslog(int type, char __user *buf, int len, bool from_file)
265{ 265{
266 unsigned i, j, limit, count; 266 unsigned i, j, limit, count;
@@ -268,7 +268,20 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
268 char c; 268 char c;
269 int error = 0; 269 int error = 0;
270 270
271 error = security_syslog(type, from_file); 271 /*
272 * If this is from /proc/kmsg we only do the capabilities checks
273 * at open time.
274 */
275 if (type == SYSLOG_ACTION_OPEN || !from_file) {
276 if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
277 return -EPERM;
278 if ((type != SYSLOG_ACTION_READ_ALL &&
279 type != SYSLOG_ACTION_SIZE_BUFFER) &&
280 !capable(CAP_SYS_ADMIN))
281 return -EPERM;
282 }
283
284 error = security_syslog(type);
272 if (error) 285 if (error)
273 return error; 286 return error;
274 287
@@ -1055,21 +1068,23 @@ static DEFINE_PER_CPU(int, printk_pending);
1055 1068
1056void printk_tick(void) 1069void printk_tick(void)
1057{ 1070{
1058 if (__get_cpu_var(printk_pending)) { 1071 if (__this_cpu_read(printk_pending)) {
1059 __get_cpu_var(printk_pending) = 0; 1072 __this_cpu_write(printk_pending, 0);
1060 wake_up_interruptible(&log_wait); 1073 wake_up_interruptible(&log_wait);
1061 } 1074 }
1062} 1075}
1063 1076
1064int printk_needs_cpu(int cpu) 1077int printk_needs_cpu(int cpu)
1065{ 1078{
1066 return per_cpu(printk_pending, cpu); 1079 if (cpu_is_offline(cpu))
1080 printk_tick();
1081 return __this_cpu_read(printk_pending);
1067} 1082}
1068 1083
1069void wake_up_klogd(void) 1084void wake_up_klogd(void)
1070{ 1085{
1071 if (waitqueue_active(&log_wait)) 1086 if (waitqueue_active(&log_wait))
1072 __raw_get_cpu_var(printk_pending) = 1; 1087 this_cpu_write(printk_pending, 1);
1073} 1088}
1074 1089
1075/** 1090/**
@@ -1338,6 +1353,7 @@ void register_console(struct console *newcon)
1338 spin_unlock_irqrestore(&logbuf_lock, flags); 1353 spin_unlock_irqrestore(&logbuf_lock, flags);
1339 } 1354 }
1340 release_console_sem(); 1355 release_console_sem();
1356 console_sysfs_notify();
1341 1357
1342 /* 1358 /*
1343 * By unregistering the bootconsoles after we enable the real console 1359 * By unregistering the bootconsoles after we enable the real console
@@ -1396,6 +1412,7 @@ int unregister_console(struct console *console)
1396 console_drivers->flags |= CON_CONSDEV; 1412 console_drivers->flags |= CON_CONSDEV;
1397 1413
1398 release_console_sem(); 1414 release_console_sem();
1415 console_sysfs_notify();
1399 return res; 1416 return res;
1400} 1417}
1401EXPORT_SYMBOL(unregister_console); 1418EXPORT_SYMBOL(unregister_console);