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

Kees Cook kees at kernel.org
Mon Oct 5 11:22:15 UTC 2026


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



More information about the Linux-security-module-archive mailing list