Skip to content

Commit 7d34606

Browse files
kkdwvdAlexei Starovoitov
authored andcommitted
bpf: Fix bpf_throw warning on 32-bit arch
On 32-bit architectures, the pointer width is 32-bit, while we try to cast from a u64 down to it, the compiler complains on mismatch in integer size. Fix this by first casting to long which should match the pointer width on targets supported by Linux. Fixes: ec5290a ("bpf: Prevent KASAN false positive with bpf_throw") Reported-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Tested-by: Matthieu Baerts <matthieu.baerts@tessares.net> Link: https://lore.kernel.org/r/20230918155233.297024-3-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 4d84dcc commit 7d34606

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/bpf/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie)
24882488
* deeper stack depths than ctx.sp as we do not return from bpf_throw,
24892489
* which skips compiler generated instrumentation to do the same.
24902490
*/
2491-
kasan_unpoison_task_stack_below((void *)ctx.sp);
2491+
kasan_unpoison_task_stack_below((void *)(long)ctx.sp);
24922492
ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp);
24932493
WARN(1, "A call to BPF exception callback should never return\n");
24942494
}

0 commit comments

Comments
 (0)