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: <20141119144004.GB2332@dhcp128.suse.cz>
Date:	Wed, 19 Nov 2014 15:40:05 +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 08:48:00, Steven Rostedt wrote:
> On Wed, 19 Nov 2014 12:40:17 +0100
> Petr Mladek <pmladek@...e.cz> wrote:
> 
> > > > 
> > > > There is one more dangerous usage in trace_printk_seq(). It is on
> > > > three lines there.
> > > 
> > > You totally confused me. What usage in trace_printk_seq(), and what
> > > three lines?
> > > 
> > The confusion is caused by the 'k' ("print" vs. "printk") in the
> > function name. I was talking about the following function from
> > kernel/trace/trace.c:
> 
> Silly 'k', Trix are for kids!

:-)
 
> > 
> > void
> > trace_printk_seq(struct trace_seq *s)
> > {
> > 	/* Probably should print a warning here. */
> > 	if (s->seq.len >= TRACE_MAX_PRINT)
> > 		s->seq.len = TRACE_MAX_PRINT;
> > 
> > 	/* should be zero ended, but we are paranoid. */
> > 	s->buffer[s->seq.len] = 0;
> > 
> > 	printk(KERN_TRACE "%s", s->buffer);
> > 
> > 	trace_seq_init(s);
> > }
> > 
> > I found it when checking the applied patches in origin/rfc/seq-buf
> > branch. I hope that it was the correct place.
> 
> Yes, that's the working branch for this code.
> 
> Anyway, I saw this and thought about using trace_seq_used(), but then I
> realized that this is trace_seq code which has a hard coded buffer
> length of PAGE_SIZE which on all archs is more than 1000
> (TRACE_MAX_PRINT).
> 
> 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.

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

Best Regards,
Petr
--
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