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:	Wed, 19 Nov 2014 17:44:40 +0100
From:	Petr Mladek <pmladek@...e.cz>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jiri Kosina <jkosina@...e.cz>
Subject: Re: [PATCH 2/2] tracing: Use trace_seq_used() and seq_buf_used()
 instead of len

On Wed 2014-11-19 11:00:37, Steven Rostedt wrote:
> On Wed, 19 Nov 2014 15:40:05 +0100
> Petr Mladek <pmladek@...e.cz> wrote:
> 
> > > Regardless of overflow or not (or even if trace_seq is full), that if
> > > statement will prevent this from doing any buffer overflows.
> > > 
> > > s->seq.len will never be more than s->seq.size after the test against
> > > TRACE_MAX_PRINT. So I see no harm here.
> > 
> > Ah, I see. Well, I would feel more comfortable if it uses
> > trace_seq_used() or if there is some explanation in a comment.
> > But you are right, it is safe as it is. Feel free to leave it.
> > 
> 
> OK, I added this just for you:
>
> BTW, using trace_seq_used() would not be good enough because it could
> return s->seq.size. Which would overflow the buffer on the
> 
> 	s->buffer[s->seq.len] = 0;

Great catch!

> -- Steve
> 
> From 1922acc9987d23d0b9c1ad28dc3eaafc1cf2d6b7 Mon Sep 17 00:00:00 2001
> From: "Steven Rostedt (Red Hat)" <rostedt@...dmis.org>
> Date: Wed, 19 Nov 2014 10:56:41 -0500
> Subject: [PATCH] tracing: Add paranoid size check in trace_printk_seq()
> 
> To be really paranoid about writing out of bound data in
> trace_printk_seq(), add another check of len compared to size.
> 
> Link: http://lkml.kernel.org/r/20141119144004.GB2332@dhcp128.suse.cz
> 
> Suggested-by: Petr Mladek <pmladek@...e.cz>
> Signed-off-by: Steven Rostedt <rostedt@...dmis.org>

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

Thanks a lot for the addition.

Best Regards,
Petr

> ---
>  kernel/trace/trace.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 9023446b2c2b..26facec4625e 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -6656,6 +6656,14 @@ trace_printk_seq(struct trace_seq *s)
>  	if (s->seq.len >= TRACE_MAX_PRINT)
>  		s->seq.len = TRACE_MAX_PRINT;
>  
> +	/*
> +	 * More paranoid code. Although the buffer size is set to
> +	 * PAGE_SIZE, and TRACE_MAX_PRINT is 1000, this is just
> +	 * an extra layer of protection.
> +	 */
> +	if (WARN_ON_ONCE(s->seq.len >= s->seq.size))
> +		s->seq.len = s->seq.size - 1;
> +
>  	/* should be zero ended, but we are paranoid. */
>  	s->buffer[s->seq.len] = 0;
>  
> -- 
> 1.8.1.4
> 
--
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