Re: [RFC][PATCH 07/12 v3] tracing: Have seq_buf use full buffer

From: Steven Rostedt
Date: Wed Nov 05 2014 - 15:21:49 EST


On Wed, 5 Nov 2014 17:31:50 +0100
Petr Mladek <pmladek@xxxxxxx> wrote:


> > /**
> > * seq_buf_print_seq - move the contents of seq_buf into a seq_file
> > @@ -55,7 +55,7 @@ int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args)
> >
> > if (s->len < s->size) {
> > len = vsnprintf(s->buffer + s->len, s->size - s->len, fmt, args);
> > - if (s->len + len < s->size) {
> > + if (s->len + len <= s->size) {
>
> This is always true because we limit vsnprintf() to write (s->size -
> s->len) bytes. Similar problem is also in the other parts of this
> patch.

No, len is the length of bytes that should have been written, not the
amount that has been written.

>
> I wonder if we want this change at all. It means that we are not able to
> detect overflow in some functions. It is pity because the users
> might want to increase the buffer size and try again if the print
> was incomplete.

What do you mean we can't detect overflow? That's what
seq_buf_has_overflowed() does.

>
> I think that we need to leave the one byte for the overflow detection
> if we want to detect it properly.

I don't.

-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/