[PATCH bpf-next v4 0/5] bpf: fix stream capacity, read, and oversize handling
From: Jianlin Shi
Date: Sun Aug 23 2026 - 10:17:57 EST
v3 addressed Kartikeya's review on v2 and the related Sashiko findings.
v4 fixes the stream_oversize selftest to verify capacity rollback on the
same BPF program stream, since streams live on prog->aux and are not
shared across programs.
Tested locally:
stream_oversize and stream_partial_read (equivalent to
./test_progs -t stream_oversize,stream_partial_read).
Changelog:
v3 -> v4:
- In stream_oversize, perform the oversized bpf_stream_printk() and a
subsequent successful "foo" push in the same program; read that
program's stream in userspace instead of switching to stream_syscall.
- Drop a redundant vscnprintf() comment in bpf_stream_stage_printk().
v2 -> v3:
- Refactor bpf_stream_release_capacity() to take a length.
- Fix staging-path capacity leak; use vscnprintf().
- Return partial bpf_stream_read() progress on copy_to_user() fault.
- Reject truncated bpf_stream_vprintk() output with -E2BIG.
- Add selftests for oversize and straddling-buffer partial read.
v1 -> v2:
- Retarget to bpf-next as suggested by Pu Lehui.
Links:
v3: https://lore.kernel.org/bpf/?q=%22PATCH+bpf-next+v3+0%2F5%22+fix+stream+capacity
v2: https://lore.kernel.org/bpf/tencent_C919BB32458A4DAD645A68F441345B971E05@xxxxxx/
v1: https://lore.kernel.org/bpf/tencent_E69EAE29327E25B3548A9AF3F4FA289A6806@xxxxxx/
Jianlin Shi (5):
bpf: roll back stream capacity when allocation fails
bpf: fix stream capacity leak in staging path
bpf: return partial progress from bpf_stream_read on fault
bpf: reject oversized bpf_stream_vprintk output with -E2BIG
selftests/bpf: cover stream capacity and partial read edge cases
kernel/bpf/stream.c | 53 +++++++++------
.../testing/selftests/bpf/prog_tests/stream.c | 65 +++++++++++++++++++
tools/testing/selftests/bpf/progs/stream.c | 18 +++++
3 files changed, 116 insertions(+), 20 deletions(-)
--
2.43.0