Re: [PATCH v4 05/11] seq_buf: Add seq_buf_strlen()

From: Kees Cook

Date: Mon Oct 05 2026 - 07:26:06 EST


On Sun, Oct 04, 2026 at 11:34:30AM +0300, Andy Shevchenko wrote:
> On Sun, Oct 04, 2026 at 12:26:39AM -0700, Kees Cook wrote:
> > I'd rather not make all 0-len strings return the .data segment's const
> > "" string...
>
> Good point. Perhaps then to add a short note to the kernel doc,
> so we won't see patches based on the suggestion like I gave?

Yeah, reasonable. :) For v5 I've added this to seq_buf_str()'s kernel-doc:

* A zero-sized seq_buf has nowhere to put a NUL, so the empty string
* is returned instead of writing to @s->buffer. Any other seq_buf
* returns @s->buffer, even when it holds an empty string, so callers
* always get their own buffer back.

-Kees

--
Kees Cook