bpf: fix argument type in bpf_loop documentation
PATCH v2 1/1 bpf: fix argument type in bpf_loop documentation
From: Matteo Croce <[email protected]>
The index argument to bpf_loop() is threaded as an u64. This lead in a subtle verifier denial where clang cloned the argument in another register[1].
[1] https://github.com/systemd/systemd/pull/34650#issuecomment-2401092895
--- include/uapi/linux/bpf.h | 2 +- kernel/bpf/verifier.c | 2 +- tools/include/uapi/linux/bpf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/bpf.h +1 -1
@@ -5371,7 +5371,7 @@ union bpf_attr {* Currently, the **flags** must be 0. Currently, nr_loops is * limited to 1 << 23 (~8 million) loops. * -* long (\*callback_fn)(u32 index, void \*ctx); +* long (\*callback_fn)(u64 index, void \*ctx); * * where **index** is the current index in the loop. The index * is zero-indexed.
kernel/bpf/verifier.c +1 -1
@@ -9917,7 +9917,7 @@ static int set_loop_callback_state(struct bpf_verifier_env *env, {/* bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx, * u64 flags); -* callback_fn(u32 index, void *callback_ctx); +* callback_fn(u64 index, void *callback_ctx); */ callee->regs[BPF_REG_1 ].type =SCALAR_VALUE ; callee->regs[BPF_REG_2 ] = caller->regs[BPF_REG_3 ];
tools/include/uapi/linux/bpf.h +1 -1
@@ -5371,7 +5371,7 @@ union bpf_attr {* Currently, the **flags** must be 0. Currently, nr_loops is * limited to 1 << 23 (~8 million) loops. * -* long (\*callback_fn)(u32 index, void \*ctx); +* long (\*callback_fn)(u64 index, void \*ctx); * * where **index** is the current index in the loop. The index * is zero-indexed.
Signature · 1 line
2.46.0
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Thu, 10 Oct 2024 04:56:52 +0100 you wrote:
From: Matteo Croce <[email protected]>
The
indexargument tobpf_loop()is threaded as an u64. This lead in a subtle verifier denial where clang cloned the argument in another register[1].[1] https://github.com/systemd/systemd/pull/34650#issuecomment-2401092895
[...]
Here is the summary with links:
- [bpf,v2] bpf: fix argument type in bpf_loop documentation
https://git.kernel.org/bpf/bpf-next/c/5bd48a3a14df
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html