diff options
| author | Kees Cook <kees@kernel.org> | 2026-10-05 08:56:51 -0700 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-10-11 21:57:29 -0700 |
| commit | a09fb764832dd7dbb9ccc38a9830f7294889c8ae (patch) | |
| tree | 0344619528a7e10cb266208050ef06d6c6c6dde0 /tools/perf/scripts/python/stackcollapse.py | |
| parent | e160c4481f60a032e0af813ea7925dbb78ad8a08 (diff) | |
| download | linux-next-a09fb764832dd7dbb9ccc38a9830f7294889c8ae.tar.gz linux-next-a09fb764832dd7dbb9ccc38a9830f7294889c8ae.zip | |
seq_buf: Do not print an empty line from an overflowed seq_buf_do_printk()
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
Link: https://patch.msgid.link/20261005155708.1471260-1-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
