Re: [PATCH v5 01/12] seq_buf: Do not print an empty line from an overflowed seq_buf_do_printk()

From: Steven Rostedt

Date: Fri Oct 16 2026 - 14:36:18 EST


On Mon, 5 Oct 2026 08:56:51 -0700
Kees Cook <kees@xxxxxxxxxx> wrote:

> seq_buf_do_printk() prints a buffer line by line, then prints whatever
> follows the last newline. When a string has overflowed at exactly a
> newline, an empty line is printed since the pointer hasn't reached the
> overflow mark of the seq_buf. Switch to just check if the string is
> already empty and only print if not.
>
> The only caller is the memory cgroup OOM report, so this could only ever
> add a blank line to a report whose statistics already did not fit.
>
> Add a test that registers a console to count the records that
> seq_buf_do_printk() emits. It counts the records carrying the test's
> marker, and the records holding nothing but a line feed that arrive
> after one, so that unrelated kernel messages do not disturb it. Both
> states that reach the flaw are covered: exactly full, and overflowed.
>
> 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.2.0.
>
> Fixes: 96928d9032a7c ("seq_buf: Add seq_buf_do_printk() helper")
> Assisted-by: LLM
> Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
> ---

Reviewed-by: Steven Rostedt <rosted@xxxxxxxxxxx>

-- Steve