Re: [PATCH v3 08/11] seq_buf: Add seq_buf_init_append()
From: Andy Shevchenko
Date: Fri Oct 02 2026 - 03:21:11 EST
On Wed, Sep 30, 2026 at 04:52:36PM -0700, Kees Cook wrote:
> Several strlcat() call sites being converted to seq_buf need behavior
> seq_buf doesn't currently provide. The normal seq_buf_init() always
> sets the new buffer size to 0 via seq_buf_clear(). Code migrating from
> strlcat(buf, ...), which appends to whatever buf already contains,
> can't use seq_buf_init() without discarding that existing content. Add
> seq_buf_init_append(), which preserves the existing contents and positions
> the seq_buf to append after it. Add KUnit tests for behavior coverage.
>
> Tests passed under qemu on ARCH=x86_64 with GCC 16.2.0 and CONFIG_KASAN=y,
> and on big-endian ARCH=s390 with GCC s390x-linux-gnu 16.1.0.
Yep, makes sense!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
But one Q below.
...
> +static inline void
> +seq_buf_init_append(struct seq_buf *s, char *buf, unsigned int size)
> +{
> + s->buffer = buf;
> + s->size = size;
> + s->len = strnlen(buf, size);
Hmm... And if this becomes a size? Shouldn't we set the overflow immediately
if the existing buffer contains a garbage or has non-NUL-terminated content?
> +}
--
With Best Regards,
Andy Shevchenko