public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/2] bpf: allow UTF-8 literals in bpf_bprintf_prepare()
@ 2026-04-15  3:21 Yihan Ding
  2026-04-15  3:21 ` [PATCH bpf v2 1/2] " Yihan Ding
  2026-04-15  3:21 ` [PATCH bpf v2 2/2] selftests/bpf: cover UTF-8 trace_printk output Yihan Ding
  0 siblings, 2 replies; 6+ messages in thread
From: Yihan Ding @ 2026-04-15  3:21 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, shuah, linux-kernel, paul.chaignon,
	alan.maguire, kernel, Yihan Ding

bpf_bprintf_prepare() currently rejects any non-ASCII byte in format
strings, so helpers such as bpf_trace_printk() fail to emit UTF-8
literal text even when those bytes are not part of a format specifier.

Keep plain text permissive while continuing to parse '%' sequences as
ASCII-only, then extend trace_printk selftests to cover both the valid
UTF-8 literal case and the invalid non-ASCII-after-'%' case.

Changes in v2:
- split the core change and selftest updates into two patches
- drop unnecessary isspace()/ispunct() casts
- add comments to clarify plain-text vs format-specifier handling
- add a negative selftest for non-ASCII bytes inside '%' sequences

Testing:
- Reproduced on x86_64 without the core fix: ASCII trace output works,
  while UTF-8 literal text in bpf_trace_printk() is rejected and
  produces no trace output
- Verified with tools/testing/selftests/bpf: ./test_progs -t trace_printk

Yihan Ding (2):
  bpf: allow UTF-8 literals in bpf_bprintf_prepare()
  selftests/bpf: cover UTF-8 trace_printk output

 kernel/bpf/helpers.c                          | 16 +++++++++++-
 .../selftests/bpf/prog_tests/trace_printk.c   | 26 +++++++++++++++----
 .../selftests/bpf/progs/trace_printk.c        |  9 +++++++
 3 files changed, 45 insertions(+), 6 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-15 10:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15  3:21 [PATCH bpf v2 0/2] bpf: allow UTF-8 literals in bpf_bprintf_prepare() Yihan Ding
2026-04-15  3:21 ` [PATCH bpf v2 1/2] " Yihan Ding
2026-04-15 10:44   ` Paul Chaignon
2026-04-15 10:49     ` Paul Chaignon
2026-04-15  3:21 ` [PATCH bpf v2 2/2] selftests/bpf: cover UTF-8 trace_printk output Yihan Ding
2026-04-15 10:46   ` Paul Chaignon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox