]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: allow UTF-8 literals in bpf_bprintf_prepare()
authorYihan Ding <dingyihan@uniontech.com>
Thu, 16 Apr 2026 12:01:41 +0000 (20:01 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 16 Apr 2026 22:53:32 +0000 (15:53 -0700)
commitb960430ea8862ef37ce53c8bf74a8dc79d3f2404
tree4a590bcf0ca967d54d750615f96f3f49f62aa846
parent766bf026d0da242a329b402c436c8e4cfa2008d8
bpf: allow UTF-8 literals in bpf_bprintf_prepare()

bpf_bprintf_prepare() only needs ASCII parsing for conversion
specifiers. Plain text can safely carry bytes >= 0x80, so allow
UTF-8 literals outside '%' sequences while keeping ASCII control
bytes rejected and format specifiers ASCII-only.

This keeps existing parsing rules for format directives unchanged,
while allowing helpers such as bpf_trace_printk() to emit UTF-8
literal text.

Update test_snprintf_negative() in the same commit so selftests keep
matching the new plain-text vs format-specifier split during bisection.

Fixes: 48cac3f4a96d ("bpf: Implement formatted output helpers with bstr_printf")
Signed-off-by: Yihan Ding <dingyihan@uniontech.com>
Acked-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/r/20260416120142.1420646-2-dingyihan@uniontech.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c
tools/testing/selftests/bpf/prog_tests/snprintf.c