summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMichal Bloch <m.bloch@samsung.com>2016-07-19 17:58:54 +0200
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:52:17 +0900
commitbae6b52d8704da7e487c26c8f0e40491fe7792da (patch)
tree6220b59dd3c2a71b4de7202f16a8ce8758792820 /kernel
parent5ee70434996f7a649d14cdb5db9a69402207194e (diff)
kmsg: allow binary characters
* do not touch unprintable characters. This is so that logs can have formatting such as newlines, tabulation, or colours. * the textual part is now delimited by \0. This is because \n which used to be the delimiter is now available for logs. * NOTE: requires corresponding changes in dlogutil. Signed-off-by: Michal Bloch <m.bloch@samsung.com> Change-Id: Ib7a83241e7a72b2ba527f52801a8bae0698d18f4
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk/printk.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index d6b96136deb4..20ebf827e858 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -989,15 +989,19 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file,
user->seq, ts_usec, cont);
user->prev = msg->flags;
- /* escape non-printable characters */
for (i = 0; i < msg->text_len; i++) {
unsigned char c = log_text(msg)[i];
- if (c < ' ' || c >= 127 || c == '\\')
- p += scnprintf(p, e - p, "\\x%02x", c);
- else
- append_char(&p, e, c);
+ append_char(&p, e, c);
}
+
+ /*
+ * The \0 is delimits the text part, while the newline is for formatting
+ * when catting the device directly. We cannot use \n for delimiting due
+ * to security: else one could forge dictionary tags through the message
+ * such as "text\n _PID=123"
+ */
+ append_char(&p, e, '\0');
append_char(&p, e, '\n');
if (msg->dict_len) {
@@ -1017,11 +1021,6 @@ static ssize_t kmsg_read(struct log_buffer *log_b, struct file *file,
continue;
}
- if (c < ' ' || c >= 127 || c == '\\') {
- p += scnprintf(p, e - p, "\\x%02x", c);
- continue;
- }
-
append_char(&p, e, c);
}
append_char(&p, e, '\n');