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]
Message-ID: <20170828124634.GD492@amd>
Date:   Mon, 28 Aug 2017 14:46:34 +0200
From:   Pavel Machek <pavel@....cz>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>, Jan Kara <jack@...e.cz>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jiri Slaby <jslaby@...e.com>, Andreas Mohr <andi@...as.de>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        linux-kernel@...r.kernel.org
Subject: Re: printk: what is going on with additional newlines?

Hi!

On Mon 2017-08-28 21:21:09, Sergey Senozhatsky wrote:
> On (08/28/17 19:28), Sergey Senozhatsky wrote:
> > On (08/28/17 11:05), Pavel Machek wrote:
> > > Hi!
> > > 
> > > In 4.13-rc, printk("foo"); printk("bar"); seems to produce
> > > foo\nbar. That's... quite surprising/unwelcome. What is going on
> > > there? Are timestamps responsible?
> > 
> > well, one thing we know for sure it is not related to this patch set  ;)
> > 
> > 
> > does any of the below patches fix the problem for you?
> > 
> > basically it sets up the rule -- if we don't have LOG_NEWLINE lflags
> > then we enforce LOG_CONT.
> 
> [..]
> 
> > @@ -1670,7 +1670,9 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c
> >  	 * write from the same process, try to add it to the buffer.
> >  	 */
> >  	if (cont.len) {
> > 		if (cont.owner == current && (lflags & LOG_CONT)) {
> 
> 
> on the other hand... I don't think I like that check at all.
> so I *probably* want to change it to -- !LOG_NEWLINE messages of the
> same loglevel AND from the same task are getting concatenated.
> a message with LOG_NEWLINE flushes the cont buffer.

Looks good to me.

> for example:
> 
>        printk("foo"); printk("foo"); printk("bar\n");

This behaviour is important for me... and this sounds ok.

>        printk("buz"); printk("buz"); printk("buz"); pr_info("INFO msg\n");
>        printk("buz"); printk("buz"); printk("buz"); pr_err("ERR msg\n");
>        printk(KERN_CONT"foo"); printk(KERN_CONT"foo"); printk(KERN_CONT"bar\n");
>        printk(KERN_CONT"foo"); printk(KERN_CONT"foo"); printk(KERN_ERR"bar\n");
>        printk(KERN_CONT"foo"); printk(KERN_ERR"foo err"); printk(KERN_ERR"bar err\n");
>

> 
> for instance,
> 	printk(KERN_ERR"foo err"); printk(KERN_ERR"bar err\n");
> 
> should produce    "foo errbar err\n".    from the same task and of
> the same loglevel, no new line. must be cont messages with a missing
> KERN_CONT. right?

Not sure. Historically it produce foo err<9>bar err\n. Concatening is
probably okay.

> how about something like this?

Umm.. No?

printk(KERN_INFO "foo"); printk(KERN_CONT "bar\n");

should produce "foobar\n", right? Will not your patch insert newline
there?

								Pavel

> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index fc47863f629c..675febf84dc8 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1670,10 +1670,9 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c
>  	 * write from the same process, try to add it to the buffer.
>  	 */
>  	if (cont.len) {
> -		if (cont.owner == current && (lflags & LOG_CONT)) {
> +		if (cont.owner == current && cont.level == level)
>  			if (cont_add(facility, level, lflags, text, text_len))
>  				return text_len;
> -		}
>  		/* Otherwise, make sure it's flushed */
>  		cont_flush();
>  	}
>  

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ