diff options
author | Michal Bloch <m.bloch@samsung.com> | 2016-09-20 16:05:51 +0200 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2016-09-21 17:13:47 -0700 |
commit | 7fef97bcc113485871077dd4356a96683d6bb7fe (patch) | |
tree | 7cddfee4eb385572982aa663991269ed2f1d4688 | |
parent | 3a54c89e9cfb5302362caa02f3f6a268c0eeaed6 (diff) | |
download | linux-exynos-7fef97bcc113485871077dd4356a96683d6bb7fe.tar.gz linux-exynos-7fef97bcc113485871077dd4356a96683d6bb7fe.tar.bz2 linux-exynos-7fef97bcc113485871077dd4356a96683d6bb7fe.zip |
kmsg: format back to previous for /dev/kmsg
* no binary characters and no \0 at the end
* done because the new format breaks various tools (such as sd-journal)
* only affects prime /dev/kmsg, the additional /dev/kmsg12 etc unaffected
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
Change-Id: Ideadbeef08f960fa7a2766b91ab2a72e8d2891b6
-rw-r--r-- | kernel/printk/printk.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 54e505f2321a..e5dec30340e7 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -922,6 +922,7 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file, char cont = '-'; size_t len; ssize_t ret; + const int prime = (log_b == &log_buf); p = user->buf; e = user->buf + sizeof(user->buf); @@ -929,6 +930,7 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file, ret = mutex_lock_interruptible(&user->lock); if (ret) return ret; + raw_spin_lock_irq(&log_b->lock); while (user->seq == log_b->next_seq) { if (file->f_flags & O_NONBLOCK) { @@ -991,7 +993,10 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file, for (i = 0; i < msg->text_len; i++) { unsigned char c = log_text(msg)[i]; - append_char(&p, e, c); + if (prime && (c < ' ' || c >= 127 || c == '\\')) + p += scnprintf(p, e - p, "\\x%02x", c); + else + append_char(&p, e, c); } /* @@ -1000,7 +1005,8 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file, * to security: else one could forge dictionary tags through the message * such as "text\n _PID=123" */ - append_char(&p, e, '\0'); + if (!prime) + append_char(&p, e, '\0'); append_char(&p, e, '\n'); if (msg->dict_len) { @@ -1020,6 +1026,11 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file, continue; } + if (prime && (c < ' ' || c >= 127 || c == '\\')) { + p += scnprintf(p, e - p, "\\x%02x", c); + continue; + } + append_char(&p, e, c); } append_char(&p, e, '\n'); |