-
Notifications
You must be signed in to change notification settings - Fork 5
bpf: use preempt_disable/enable() to protect bpf_bprintf_buffers nesting #6333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpf: use preempt_disable/enable() to protect bpf_bprintf_buffers nesting #6333
Conversation
|
Upstream branch: 026bcf9 |
|
Upstream branch: 026bcf9 |
4c93fc6 to
f5fb66b
Compare
|
Upstream branch: 026bcf9 |
f5fb66b to
7599e49
Compare
4eb9670 to
e1b05fd
Compare
|
Upstream branch: f1d8c65 |
7599e49 to
77fec86
Compare
e1b05fd to
b1af442
Compare
|
Upstream branch: 93ce3be |
77fec86 to
fc73211
Compare
b1af442 to
67d3dd3
Compare
|
Upstream branch: 93ce3be |
The bpf_bprintf_prepare() and related helpers (bpf_try_get_buffers() / bpf_put_buffers()) rely on a per-CPU counter bpf_bprintf_nest_level to manage nested buffer usage. However, when invoked from different contexts (process, softirq, NMI), the nesting counter can become inconsistent if task migration occurs between CPUs during these operations. This can result in warnings such as: WARNING: CPU: 1 PID: 6145 at kernel/bpf/helpers.c:781 bpf_try_get_buffers kernel/bpf/helpers.c:781 [inline] WARNING: CPU: 1 PID: 6145 at kernel/bpf/helpers.c:781 bpf_bprintf_prepare+0x12cf/0x13a0 kernel/bpf/helpers.c:834 Having only migrate_disable is insufficient here to prevent nesting, hence add preempt_disable()/enable() around buffer acquisition and release. Reported-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 4223bf8 ("bpf: Remove preempt_disable in bpf_try_get_buffers") Suggested-by: Yonghong Song <[email protected]> Signed-off-by: Sahil Chandna <[email protected]> Acked-by: Yonghong Song <[email protected]> Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
fc73211 to
ab3fc16
Compare
67d3dd3 to
488318d
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1022157 irrelevant now. Closing PR. |
Pull request for series with
subject: bpf: use preempt_disable/enable() to protect bpf_bprintf_buffers nesting
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1022157