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:	Thu,  6 Dec 2012 18:06:01 +0100
From:	Jan H. Schönherr <schnhrr@...tu-berlin.de>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Kay Sievers <kay@...y.org>
Cc:	linux-kernel@...r.kernel.org, Joe Perches <joe@...ches.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Stephen Rothwell <sfr@...b.auug.org.au>,
	Jan H. Schönherr <schnhrr@...tu-berlin.de>
Subject: [PATCH v2 04/14] printk: do not add unnecessary newlines to the continuation buffer

Do not add newlines to the continuation buffer just because we can.  (In
some cases, the newlines are even misplaced and prevent a correct syslog
output.) Instead, only if a newline was part of the input, store it
during cont_add().

This makes the previous patch a bit more efficient.

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

diff --git a/kernel/printk.c b/kernel/printk.c
index 13af61c..f6a91ec 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1392,15 +1392,13 @@ static struct cont {
 	bool flushed:1;			/* buffer sealed and committed */
 } cont;
 
-static void cont_flush(enum log_flags flags)
+static void cont_flush(void)
 {
 	if (cont.flushed)
 		return;
 	if (cont.len == 0)
 		return;
 
-	cont.flags |= flags;
-
 	/*
 	 * If a fragment of this line was directly flushed to the console, the
 	 * whole line is/was directly printed. Use LOG_NOCONS to suppress a
@@ -1431,7 +1429,7 @@ static bool cont_add(int facility, int level, enum log_flags flags,
 
 	if (cont.len + len > sizeof(cont.buf)) {
 		/* the line gets too long, split it up in separate records */
-		cont_flush(0);
+		cont_flush();
 		return false;
 	}
 
@@ -1440,16 +1438,18 @@ static bool cont_add(int facility, int level, enum log_flags flags,
 		cont.level = level;
 		cont.owner = current;
 		cont.ts_nsec = local_clock();
-		cont.flags = flags;
+		cont.flags = 0;
 		cont.cons = 0;
 		cont.flushed = false;
 	}
 
+	cont.flags |= flags;
+
 	memcpy(cont.buf + cont.len, text, len);
 	cont.len += len;
 
 	if (cont.len > (sizeof(cont.buf) * 80) / 100)
-		cont_flush(0);
+		cont_flush();
 
 	return true;
 }
@@ -1585,7 +1585,7 @@ asmlinkage int vprintk_emit(int facility, int level,
 			if (cont.owner != current)
 				lflags |= LOG_PREFIX;
 			if (lflags & LOG_PREFIX)
-				cont_flush(LOG_NEWLINE);
+				cont_flush();
 		}
 
 		/* buffer line if possible, otherwise store it right away */
@@ -1605,7 +1605,7 @@ asmlinkage int vprintk_emit(int facility, int level,
 			if (!(lflags & LOG_PREFIX))
 				stored = cont_add(facility, level, lflags,
 							text, text_len);
-			cont_flush(LOG_NEWLINE);
+			cont_flush();
 		}
 
 		if (!stored)
-- 
1.8.0.1.20.g7c65b2e.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