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:	Fri, 20 Feb 2015 09:40:16 -0800
From:	Joe Perches <joe@...ches.com>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	Alexander van Heukelum <heukelum@...tmail.fm>,
	tglx@...utronix.de, luto@...capital.net, fruggeri@...sta.com,
	a.ryabinin@...sung.com, akpm@...ux-foundation.org, hpa@...or.com,
	Adrien Schildknecht <adrien+dev@...ischi.me>,
	linux-kernel@...r.kernel.org, bp@...en8.de, adech.fo@...il.com,
	x86@...nel.org, mingo@...hat.com
Subject: Re: [PATCH v2] x86: fix output of show_stack_log_lvl()

On Fri, 2015-02-20 at 12:05 -0500, Steven Rostedt wrote:
> On Thu, 19 Feb 2015 21:13:29 -0800
> Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> 
> > On Feb 19, 2015 8:45 PM, "Steven Rostedt" <rostedt@...dmis.org> wrote:
> > >
> > > This looks like a bug in printk(). Why doesn't pr_cont() continue? It
> > > shouldn't care if there's a newline or not. pr_cont() is supposed to
> > > continue whatever the last printk log level was.
> > 
> > pr_cont() should continue the current line. If there was a behind, and it's
> > a new line, then pr_cont() is meaningless.
> 
> Ah, you are right. I got confused by the lack of comments around
> pr_cont. Now KERN_CONT is nicely commented, but unfortunately that
> comment exists in a different file.
> 
> How about adding the below patch so people like me wont get confused
> again.
> 
> -- Steve
> 
> printk: Comment pr_cont() stating it is only to continue a line
> 
> KERN_CONT is nicely commented in kern_levels.h, but pr_cont() is now
> used more often, and it lacks the comment stating what it is used for.
> It can be confused as continuing the log level, but that is not its
> purpose. It's purpose is to continue a line that had no newline
> enclosed. This should be documented by pr_cont() as well.
> 
> Signed-off-by: Steven Rostedt <rostedt@...dmis.org>
> ---
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 4d5bf57..937d2f3 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -255,6 +255,11 @@ extern asmlinkage void dump_stack(void) __cold;
>  	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
>  #define pr_info(fmt, ...) \
>  	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> +/*
> + * Like KERN_CONT, pr_cont() should only be used when continuing
> + * a line with no newline ('\n') enclosed. Otherwise it defaults
> + * back to KERN_DEFAULT.
> + */

The first sentence is basically true though the
"enclosed" use is at best awkward.
Maybe "closing" or "terminating" is better.

There are still a few dozen uses of this pattern:

	pr_info("Some message line 1\nNext line: ");
	for (...)
		pr_cont(" part %d", i);
	pr_cont('\n");

The second sentence is not true.

KERN_DEFAULT is an odd-ball variable level that likely
could be removed altogether.  It's like a naked printk,
but if the last emitted char is not a newline, one is
prepended.

How about something like:

Use pr_cont() when continuing a message that does
not end in a '\n'.  Do not use pr_cont when continuing
a dynamic_debug type message.

--
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