summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-07-03 17:57:58 +0200
committerKay Sievers <kay@vrfy.org>2012-07-03 17:57:58 +0200
commit4ffae93390088d98c9cb41619376aaae870317b0 (patch)
treee926444e56ab383908a60effaaa8b0d1d7f51e6b
parent5c6aabade287c2694c54becea61f18423cc90fff (diff)
downloadpatches-4ffae93390088d98c9cb41619376aaae870317b0.tar.gz
add kmsg fixes
-rw-r--r--kmsg-escape.patch24
-rw-r--r--kmsg-facility-len.patch26
-rw-r--r--kmsg-nonblock-race.patch33
-rw-r--r--series3
4 files changed, 86 insertions, 0 deletions
diff --git a/kmsg-escape.patch b/kmsg-escape.patch
new file mode 100644
index 0000000..15867fa
--- /dev/null
+++ b/kmsg-escape.patch
@@ -0,0 +1,24 @@
+---
+ kernel/printk.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/kernel/printk.c
++++ b/kernel/printk.c
+@@ -465,7 +465,7 @@ static ssize_t devkmsg_read(struct file
+ for (i = 0; i < msg->text_len; i++) {
+ unsigned char c = log_text(msg)[i];
+
+- if (c < ' ' || c >= 128)
++ if (c < ' ' || c >= 128 || c == '\\')
+ len += sprintf(user->buf + len, "\\x%02x", c);
+ else
+ user->buf[len++] = c;
+@@ -489,7 +489,7 @@ static ssize_t devkmsg_read(struct file
+ continue;
+ }
+
+- if (c < ' ' || c >= 128) {
++ if (c < ' ' || c >= 128 || c == '\\') {
+ len += sprintf(user->buf + len, "\\x%02x", c);
+ continue;
+ }
diff --git a/kmsg-facility-len.patch b/kmsg-facility-len.patch
new file mode 100644
index 0000000..ed9d8fc
--- /dev/null
+++ b/kmsg-facility-len.patch
@@ -0,0 +1,26 @@
+---
+ kernel/printk.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/kernel/printk.c
++++ b/kernel/printk.c
+@@ -818,15 +818,16 @@ static size_t print_time(u64 ts, char *b
+ static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
+ {
+ size_t len = 0;
++ unsigned int prefix = (msg->facility << 3) | msg->level;
+
+ if (syslog) {
+ if (buf) {
+- len += sprintf(buf, "<%u>", msg->level);
++ len += sprintf(buf, "<%u>", prefix);
+ } else {
+ len += 3;
+- if (msg->level > 9)
++ if (prefix > 9)
+ len++;
+- if (msg->level > 99)
++ if (prefix > 99)
+ len++;
+ }
+ }
diff --git a/kmsg-nonblock-race.patch b/kmsg-nonblock-race.patch
new file mode 100644
index 0000000..f7b7088
--- /dev/null
+++ b/kmsg-nonblock-race.patch
@@ -0,0 +1,33 @@
+---
+ kernel/printk.c | 9 +--------
+ 1 file changed, 1 insertion(+), 8 deletions(-)
+
+--- a/kernel/printk.c
++++ b/kernel/printk.c
+@@ -1019,7 +1019,6 @@ int do_syslog(int type, char __user *buf
+ {
+ bool clear = false;
+ static int saved_console_loglevel = -1;
+- static DEFINE_MUTEX(syslog_mutex);
+ int error;
+
+ error = check_syslog_permissions(type, from_file);
+@@ -1046,17 +1045,11 @@ int do_syslog(int type, char __user *buf
+ error = -EFAULT;
+ goto out;
+ }
+- error = mutex_lock_interruptible(&syslog_mutex);
+- if (error)
+- goto out;
+ error = wait_event_interruptible(log_wait,
+ syslog_seq != log_next_seq);
+- if (error) {
+- mutex_unlock(&syslog_mutex);
++ if (error)
+ goto out;
+- }
+ error = syslog_print(buf, len);
+- mutex_unlock(&syslog_mutex);
+ break;
+ /* Read/clear last kernel messages */
+ case SYSLOG_ACTION_READ_CLEAR:
diff --git a/series b/series
index a9dd8aa..6d3b1ec 100644
--- a/series
+++ b/series
@@ -1 +1,4 @@
+kmsg-escape.patch
+kmsg-facility-len.patch
+kmsg-nonblock-race.patch
test-modules.patch