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] [day] [month] [year] [list]
Date:	Thu, 20 Jan 2011 10:31:14 +0800
From:	Feng Tang <feng.tang@...el.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"gregkh@...e.de" <gregkh@...e.de>,
	"alan@...ux.intel.com" <alan@...ux.intel.com>
Subject: Re: [PATCH] console: prevent registered consoles from dumping old
 kernel message over again

On Thu, 20 Jan 2011 09:51:34 +0800
Andrew Morton <akpm@...ux-foundation.org> wrote:

> On Thu, 20 Jan 2011 09:44:58 +0800
> Feng Tang <feng.tang@...el.com> wrote:
> 
> > > How's about something like this?
> > 
> > Yes, it makes sense, I should add some check. And this new
> > "exclusive_console" should be better as its name shows what it is
> > for.
> 
> Is it racy, or does console_sem coverage save us?
> 
> Anyway.  If you think that the exclusive_console approach is suitable,
> please send a tested patch back at me sometime?
> 

Actually before my last email, I tested your patch which works fine which
I just forgot to mention :)

looks a little racy, so I move the "exclusive_console=NULL" to some place
protected by console_sem, and it works fine on my platform, pls review it

Thanks,
Feng


-----------------------------
rom cf1fcf9942f1ac067081572c8dc1e238674441fd Mon Sep 17 00:00:00 2001
From: Feng Tang <feng.tang@...el.com>
Date: Thu, 20 Jan 2011 10:26:21 +0800
Subject: [PATCH] console: prevent registered consoles from dumping old kernel message over again

For a platform with many consoles like:
 "console=tty1 console=ttyMFD2 console=ttyS0 earlyprintk=mrst"

Each time when the non "selected_console" (tty1 and ttyMFD2 here) get
registered, the existing kernel message will be printed out on registered
consoles again, the "mrst" early console will get some same message for
3 times, and "tty1" will get some for twice.

As suggested by Andrew Morton, everytime a new console is registered, it
will be set as the "exclusive" console which will dump the already existing
kernel message.

Signed-off-by: Feng Tang <feng.tang@...el.com>
---
 kernel/printk.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 53d9a9e..ee71cc4 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -113,6 +113,11 @@ static unsigned con_start;	/* Index into log_buf: next char to be sent to consol
 static unsigned log_end;	/* Index into log_buf: most-recently-written-char + 1 */
 
 /*
+ * If exclusive_console is non-NULL then only this console is to be printed to.
+ */
+static struct console *exclusive_console;
+
+/*
  *	Array of consoles built from command line options (console=)
  */
 struct console_cmdline
@@ -460,6 +465,8 @@ static void __call_console_drivers(unsigned start, unsigned end)
 	struct console *con;
 
 	for_each_console(con) {
+		if (exclusive_console && con != exclusive_console)
+			continue;
 		if ((con->flags & CON_ENABLED) && con->write &&
 				(cpu_online(smp_processor_id()) ||
 				(con->flags & CON_ANYTIME)))
@@ -1136,6 +1143,11 @@ void release_console_sem(void)
 		local_irq_restore(flags);
 	}
 	console_locked = 0;
+
+	/* Release the exclusive_console once it is used */
+	if (unlikely(exclusive_console))
+		exclusive_console = NULL;
+
 	up(&console_sem);
 	spin_unlock_irqrestore(&logbuf_lock, flags);
 	if (wake_klogd)
@@ -1358,6 +1370,12 @@ void register_console(struct console *newcon)
 		spin_lock_irqsave(&logbuf_lock, flags);
 		con_start = log_start;
 		spin_unlock_irqrestore(&logbuf_lock, flags);
+		/*
+		 * We're about to replay the log buffer.  Only do this to the
+		 * just-registered console to avoid excessive message spam to
+		 * the already-registered consoles.
+		 */
+		exclusive_console = newcon;
 	}
 	release_console_sem();
 	console_sysfs_notify();
-- 
--
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