[PATCH 5.15,6.1] Fixup preempt imbalance with bpf_trace_printk

Thadeu Lima de Souza Cascardo
2024-02-17T12:13:39Z

When bpf_trace_printk is called without any args in a second depth level,
it will enable preemption without disabling it.

These patch series fix this for 5.15 and 6.1. The fix was introduced in
6.3, so later kernels already have it. And 5.10 and earlier did not have
the code that disabled preemption, so they are fine in that regard.

This was tested by attaching a bpf program doing a non-0 arguments
trace_printk at sys_enter and a 0 arguments snprintf at local_timer_entry.

Dave Marchevsky (1):
bpf: Merge printk and seq_printf VARARG max macros

Jiri Olsa (3):
bpf: Add struct for bin_args arg in bpf_bprintf_prepare
bpf: Do cleanup in bpf_bprintf_cleanup only when needed
bpf: Remove trace_printk_lock

include/linux/bpf.h | 14 ++++++--
kernel/bpf/helpers.c | 71 ++++++++++++++++++++++------------------
kernel/bpf/verifier.c | 3 +-
kernel/trace/bpf_trace.c | 39 ++++++++++------------
4 files changed, 72 insertions(+), 55 deletions(-)

--
2.34.1