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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080414101200.GH29599@tull.net>
Date:	Mon, 14 Apr 2008 20:12:00 +1000
From:	Nick Andrew <nick@...k-andrew.net>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>, joe@...ches.com
Subject: Re: [PATCH 2/2] printk: Remember the message level for multi-line	output

On Mon, Apr 14, 2008 at 10:03:51AM +0200, Ingo Molnar wrote:
> 
> * Nick Andrew <nick@...k-andrew.net> wrote:
> 
> > printk: Remember the message level for multi-line output
> > 
> > printk(KERN_ALERT "Danger Will Robinson!\nAlien Approaching!\n");
> > 
> > At present this will result in one message at ALERT level and one at 
> > the current default message loglevel (e.g. WARNING). This is 
> > non-intuitive.
> > 
> > Modify vprintk() to remember the message loglevel each time it is 
> > specified and use it for subsequent lines of output which do not 
> > specify one, within the same call to printk.
> 
> i've applied this too for testing.
> 
> but multi-line strings are a bit unclean i think: each message line 
> should have its separate printk.

You'd think. But there are a lot of calls to printk() with multi-line
format strings; developers clearly expect it to "just work" and
that a message level set at the start will be retained across lines.

> will your patch leave the behavior of multiple calls to printk alone? 
> I.e. if i do:
> 
>   printk(KERN_ALERT "Danger Will Robinson!\n");
>   printk("Alien Approaching!\n");
> 
> then we'll still get a KERN_ALERT plus a default printk, right?

Yes, quite. The state of whether we're inside a line is retained
across calls to printk (from anywhere in the system) - this allows
code like this to usually do what you expect:

	printk(KERN_ERR "Error:");
	for (i = 0; i < 16; ++i) {
		printk("  %02x", i);
	}
	printk("\n");

But in your example the first printk call contains a \n at the
end of the line and so upon entry to the second printk call
the function knows a new line is beginning.

The message level is a local variable. It's set to the default
at function entry, and is recalculated at the beginning of each
new line. It's changed only if a new line begins with a token.
So subsequent new lines which don't contain a token reuse the
previous value ... only within a single call to printk().

Nick.
-- 
PGP Key ID = 0x418487E7                      http://www.nick-andrew.net/
PGP Key fingerprint = B3ED 6894 8E49 1770 C24A  67E3 6266 6EB9 4184 87E7
--
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