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  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:   Tue, 28 Nov 2017 16:13:29 -0800
From:   Kevin Hilman <khilman@...libre.com>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     Fengguang Wu <fengguang.wu@...el.com>,
        Petr Mladek <pmladek@...e.com>,
        Mark Brown <broonie@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: kernel CI: printk loglevels in kernel boot logs?

Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> writes:

> On (11/22/17 20:52), Fengguang Wu wrote:
> [..]
>> > well, I think that that "consoles_format=syslog" command line parameter
>> > will be enabled only by those who actually want to have it - Fengguang's
>> > build robot and kernelCI (+ may be more setups).  so I'd probably assume
>> > there are low risks here. may be I'm wrong.
>> 
>> Yes, since it needs explicit enabling, local parsers should stay
>> working. Unless we send dmesg to other developers, but then they
>> might also receive $(dmesg --raw) outputs and need to handle <%u>
>> prefixes, too.
>> 
>> > I think it makes sense to have syslog's format "<%u>[timestamp] text\n"
>> > on serial consoles (time stamp when PRINTK_TIME set; <%u> when
>> > consoles_format=syslog set).
>> 
>> Thanks. Since the 0day scripts can already parse that format (code
>> is listed below), we should quickly benefit from that feature when
>> it's mainlined.
>
> okay... who's going to send the patch? kernelCI folks?
>
> I have some sort of a patch. added console_msg_format= with the only
> available option so far - "syslog". may be people would want to have
> boot time, etc. on their consoles. who knows. may be msg_format will
> be extended someday in the future or may be not, and we can do
> something like "console_format_syslog" (or any better name).
>
> Not-yet-signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>

For kernelCI (part of how this thread got started):

Acked-by: Kevin Hilman <khilman@...libre.com>
Reviewed-by: Kevin Hilman <khilman@...libre.com>

I also tested it on an arm64 platform with the new command-line arg:

Tested-by: Kevin Hilman <khilman@...libre.com>

Thanks,

Kevin

> ---
>  Documentation/admin-guide/kernel-parameters.txt | 11 +++++++++++
>  kernel/printk/printk.c                          | 21 ++++++++++++++++++++-
>  2 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 62436bd5f34a..42113e5181b2 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -640,6 +640,17 @@
>  			console=brl,ttyS0
>  		For now, only VisioBraille is supported.
>  
> +	console_msg_format=
> +			[KNL] Control message format
> +			By default we print messages in "[time stamp] text\n"
> +			format (time stamp may not be printed, depending on
> +			CONFIG_PRINTK_TIME or `printk_time' param).
> +		syslog
> +			Switch to syslog format (similar to "dmesg --raw" or
> +			reading from /proc/kmsg): "<%u>[time stamp] text\n"
> +			IOW, each message is getting prepended with the
> +			facility and loglevel prefix.
> +
>  	consoleblank=	[KNL] The console blank (screen saver) timeout in
>  			seconds. A value of 0 disables the blank timer.
>                         Defaults to 0.
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 5d81206a572d..034f3ad85f5b 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -277,6 +277,13 @@ EXPORT_SYMBOL(console_set_on_cmdline);
>  /* Flag: console code may call schedule() */
>  static int console_may_schedule;
>  
> +enum con_msg_format {
> +	MSG_FORMAT_DEFAULT = 1,
> +	MSG_FORMAT_SYSLOG = 2,
> +};
> +
> +static int console_msg_format = MSG_FORMAT_DEFAULT;
> +
>  /*
>   * The printk log buffer consists of a chain of concatenated variable
>   * length records. Every record starts with a record header, containing
> @@ -1913,6 +1920,15 @@ static int __add_preferred_console(char *name, int idx, char *options,
>  	c->index = idx;
>  	return 0;
>  }
> +
> +static int __init console_msg_format_setup(char *str)
> +{
> +	if (!strncmp(str, "syslog", 6))
> +		console_msg_format = MSG_FORMAT_SYSLOG;
> +	return 1;
> +}
> +__setup("console_msg_format=", console_msg_format_setup);
> +
>  /*
>   * Set up a console.  Called via do_early_param() in init/main.c
>   * for each "console=" parameter in the boot command line.
> @@ -2215,7 +2231,10 @@ void console_unlock(void)
>  			goto skip;
>  		}
>  
> -		len += msg_print_text(msg, false, text + len, sizeof(text) - len);
> +		len += msg_print_text(msg,
> +				console_msg_format & MSG_FORMAT_SYSLOG,
> +				text + len,
> +				sizeof(text) - len);
>  		if (nr_ext_console_drivers) {
>  			ext_len = msg_print_ext_header(ext_text,
>  						sizeof(ext_text),

Powered by blists - more mailing lists