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]
Date:   Thu, 3 Dec 2020 16:57:26 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH next v2 1/3] printk: inline log_output(),log_store() in
 vprintk_store()

On Tue 2020-12-01 21:59:39, John Ogness wrote:
> In preparation for removing logbuf_lock, inline log_output()
> and log_store() into vprintk_store(). This will simplify dealing
> with the various code branches and fallbacks that are possible.
> ---
>  kernel/printk/printk.c | 134 +++++++++++++++++------------------------
>  1 file changed, 56 insertions(+), 78 deletions(-)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index f279d4fbd9dd..fc5e3a7d6d89 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1983,7 +1915,53 @@ int vprintk_store(int facility, int level,
>  	if (dev_info)
>  		lflags |= LOG_NEWLINE;
>  
> -	return log_output(facility, level, lflags, dev_info, text, text_len);
> +	if (lflags & LOG_CONT) {
> +		prb_rec_init_wr(&r, text_len);
> +		if (prb_reserve_in_last(&e, prb, &r, caller_id, LOG_LINE_MAX)) {
> +			memcpy(&r.text_buf[r.info->text_len], text, text_len);
> +			r.info->text_len += text_len;
> +
> +			if (lflags & LOG_NEWLINE) {
> +				r.info->flags |= LOG_NEWLINE;
> +				prb_final_commit(&e);
> +			} else {
> +				prb_commit(&e);
> +			}
> +
> +			return text_len;
> +		}
> +	}
> +
> +	prb_rec_init_wr(&r, text_len);

This is called in both branches. I would do it just once at the
beginning.

> +	if (!prb_reserve(&e, prb, &r)) {
> +		/* truncate the message if it is too long for empty buffer */
> +		truncate_msg(&text_len, &trunc_msg_len);
> +
> +		prb_rec_init_wr(&r, text_len + trunc_msg_len);
> +		if (!prb_reserve(&e, prb, &r))
> +			return 0;
> +	}
> +
> +	/* fill message */
> +	memcpy(&r.text_buf[0], text, text_len);
> +	if (trunc_msg_len)
> +		memcpy(&r.text_buf[text_len], trunc_msg, trunc_msg_len);
> +	r.info->text_len = text_len + trunc_msg_len;
> +	r.info->facility = facility;
> +	r.info->level = level & 7;
> +	r.info->flags = lflags & 0x1f;
> +	r.info->ts_nsec = ts_nsec;

This is the only location where ts_nsec is used. I would remove the
variable and call:

	r.info->ts_nsec = local_clock();

> +	r.info->caller_id = caller_id;
> +	if (dev_info)
> +		memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));
> +
> +	/* A message without a trailing newline can be continued. */
> +	if (!(lflags & LOG_NEWLINE))
> +		prb_commit(&e);
> +	else
> +		prb_final_commit(&e);
> +
> +	return (text_len + trunc_msg_len);
>  }

Both changes are cosmetic and I do not resist on them. Please, do the changes
if v3 is needed and you agree with them.

Anyway, feel free to use:

Reviewed-by: Petr Mladek <pmladek@...e.com>

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ