Hi, While working on seq_buf conversions[1], we found there was a need for seq_buf_strlen() (since calling strlen(seq_buf_str()) would be a waste of time: seq_buf already knows the length), seq_buf_init_append() (to start a seq_buf from an existing string buffer), and seq_buf_terminate() (as there are many callers using seq_buf_str() just for its termination side-effect). And while implementing that, we found a bunch of other related things that needed fixing. This is that ever-growing series, with tests for each fix.
v1: https://lore.kernel.org/all/[email protected]/ v2: https://lore.kernel.org/all/[email protected]/ v3: - add trailers from v2 - add seq_buf_terminate() - drop redundant bpf termination Thanks! -Kees [1] https://lore.kernel.org/all/[email protected]/ Bill Wendling (1): seq_buf: Add seq_buf_init_append() Kees Cook (10): seq_buf: Do not print an empty line from an overflowed seq_buf_do_printk() seq_buf: Do not pop from an overflowed seq_buf seq_buf: Copy what fits when seq_buf_puts() and seq_buf_putmem() overflow seq_buf: Clear what a writer did not claim when a seq_buf overflows seq_buf: Add seq_buf_strlen() seq_buf: Add seq_buf_terminate() bpf: Remove dead newline stripping from format_disasm_line() powerpc/papr_scm: Return the string length from the sysfs show functions nvdimm: ndtest: Return the string length from flags_show() docs: core-api: Document the seq_buf API Documentation/core-api/kernel-api.rst | 9 + include/linux/seq_buf.h | 134 +++++- include/linux/trace_seq.h | 5 +- arch/powerpc/platforms/pseries/papr_scm.c | 4 +- kernel/bpf/diagnostics.c | 8 +- kernel/trace/trace_events.c | 4 +- kernel/trace/trace_events_hist.c | 6 +- lib/seq_buf.c | 35 +- lib/tests/seq_buf_kunit.c | 516 +++++++++++++++++++++- tools/testing/nvdimm/test/ndtest.c | 2 +- 10 files changed, 688 insertions(+), 35 deletions(-) -- 2.34.1

