Re: [PATCH 2/2] tracing: Use trace_seq_used() and seq_buf_used() instead of len

From: Steven Rostedt
Date: Wed Nov 19 2014 - 11:00:46 EST


On Wed, 19 Nov 2014 15:40:05 +0100
Petr Mladek <pmladek@xxxxxxx> 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;

-- Steve