Re: [PATCH bpf-next 1/5] bpf: do not print a newline after disassembly in bpf_verbose_insn()

[email protected] Fri, 31 Jul 2026 20:24:43 +0000 (UTC)
Newsgroups org.kernel.vger.bpf
Message-ID <00c332237fb39899a63235c07cc1d51ab4df2bb5213a6ba93dd186250ccc54df@mail.kernel.org>
> diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
> index 5e7cb8b36fef2..7b33d847d800c 100644
> --- a/tools/bpf/bpftool/xlated_dumper.c
> +++ b/tools/bpf/bpftool/xlated_dumper.c

[ ... ]

> @@ -417,6 +412,7 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
>
>  		printf("%u: ", insn_off);
>  		print_bpf_insn(&cbs, cur, true);
> +		printf("\\l\\\n");
>
>  		if (opcodes) {
>  			printf("\\ \\ \\ \\ ");

This isn't a bug, but now that no disasm.c format string carries a
newline and dump_xlated_for_graph() emits "\\l\\\n" itself, is the
'\n' arm of print_insn_for_graph() still reachable?

Looking at print_insn_for_graph():

static void __printf(2, 3)
print_insn_for_graph(void *private_data, const char *fmt, ...)
{
	...
	p = buf;
	while (*p != '\0') {
		if (*p == '\n') {
			memmove(p + 3, p, strlen(buf) + 1 - (p - buf));
			/* Align each instruction dump row left. */
			*p++ = '\\';
			*p++ = 'l';
			/* Output multiline concatenation. */
			*p++ = '\\';
		} else if (*p == '<' || *p == '>' || *p == '|' || *p == '&') {
	...
}

It looks like the `if (*p == '\n')` arm no longer has any producer,
since this patch drops '\n' from all 34 verbose() format strings in
kernel/bpf/disasm.c and the interpolated values (symbol names parsed
with sscanf "%s") cannot contain whitespace either. Could this arm be
dropped so only the '<'/'>'/'|'/'&' escaping remains?

Note this would also retire the latent `memmove(p + 3, ...)` expansion
that had no headroom check against the 64-byte buf.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/30658911996