lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 14 Nov 2012 00:13:04 +0100
From:	Jan H. Schönherr <schnhrr@...tu-berlin.de>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	linux-kernel@...r.kernel.org, Kay Sievers <kay@...y.org>,
	Jan H. Schönherr <schnhrr@...tu-berlin.de>
Subject: [PATCH 07/12] printk: let cont_print_text() reuse existing code

The functionality of cont_print_text() also exists within
msg_print_text(). The only difference is that cont_print_text()
currently fails to print timestamps for multi-line strings from the
second line on.

In order to be able to use msg_print_text() from cont_print_text(),
create a more general version msg_print_text_from() with the ability to
start at a specific position within the message and to track the
position.

Signed-off-by: Jan H. Schönherr <schnhrr@...tu-berlin.de>
---
 kernel/printk.c | 54 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 988a8f5..7a961d4 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -876,8 +876,9 @@ static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
 	return len;
 }
 
-static size_t msg_print_text(const struct log *msg, enum log_flags prev,
-			     bool syslog, char *buf, size_t size)
+static size_t msg_print_text_from(const struct log *msg, size_t *from,
+				  enum log_flags prev,
+				  bool syslog, char *buf, size_t size)
 {
 	const char *text = log_text(msg);
 	size_t text_size = msg->text_len;
@@ -891,6 +892,13 @@ static size_t msg_print_text(const struct log *msg, enum log_flags prev,
 	if (!(msg->flags & LOG_NEWLINE))
 		newline = false;
 
+	if (from) {
+		text += *from;
+		text_size -= *from;
+		if (*from)
+			prefix = false;
+	}
+
 	if (!(prev & LOG_NEWLINE) && prefix) {
 		if (buf)
 			buf[len] = '\n';
@@ -933,9 +941,23 @@ static size_t msg_print_text(const struct log *msg, enum log_flags prev,
 		text = next;
 	} while (text);
 
+	if (from) {
+		if (text)
+			*from = text - log_text(msg);
+		else
+			*from = msg->text_len;
+	}
+
 	return len;
 }
 
+static size_t msg_print_text(const struct log *msg,
+			     enum log_flags prev,
+			     bool syslog, char *buf, size_t size)
+{
+	return msg_print_text_from(msg, NULL, prev, syslog, buf, size);
+}
+
 static int syslog_print(char __user *buf, int size)
 {
 	char *text;
@@ -1452,32 +1474,12 @@ static bool cont_add(int facility, int level, enum log_flags flags,
 
 static size_t cont_print_text(char *text, size_t size)
 {
-	size_t textlen = 0;
-	size_t len;
+	size_t textlen = msg_print_text_from(&cont.msg, &cont.cons,
+					     console_prev, false, text, size);
 
-	if (cont.cons == 0 && (console_prev & LOG_NEWLINE ||
-			       cont.msg.flags & LOG_PREFIX)) {
-		if (!(console_prev & LOG_NEWLINE))
-			text[textlen++] = '\n';
-		textlen += print_time(cont.msg.ts_nsec, text + textlen);
-		size -= textlen;
-	}
-
-	len = cont.msg.text_len - cont.cons;
-	if (len > 0) {
-		if (len+1 > size)
-			len = size-1;
-		memcpy(text + textlen, cont.buf + cont.cons, len);
-		textlen += len;
-		cont.cons = cont.msg.text_len;
-	}
-
-	if (cont.flushed) {
-		if (cont.msg.flags & LOG_NEWLINE)
-			text[textlen++] = '\n';
-		/* got everything, release buffer */
+	if (cont.flushed)
 		cont.msg.text_len = 0;
-	}
+
 	return textlen;
 }
 
-- 
1.8.0.316.g291341c.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ