]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf, arm64: Fix address emission with tag-based KASAN enabled
authorPeter Collingbourne <pcc@google.com>
Fri, 18 Oct 2024 22:16:43 +0000 (15:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 01:02:35 +0000 (02:02 +0100)
commit7db1a2121f3c7903b8e397392beec563c3d00950
treef11f4b00f4a21f7641deef96b5f0524c564bba58
parent3cd1610c6f1525a040c4fe1e3a894d8af6a201f2
bpf, arm64: Fix address emission with tag-based KASAN enabled

[ Upstream commit a552e2ef5fd1a6c78267cd4ec5a9b49aa11bbb1c ]

When BPF_TRAMP_F_CALL_ORIG is enabled, the address of a bpf_tramp_image
struct on the stack is passed during the size calculation pass and
an address on the heap is passed during code generation. This may
cause a heap buffer overflow if the heap address is tagged because
emit_a64_mov_i64() will emit longer code than it did during the size
calculation pass. The same problem could occur without tag-based
KASAN if one of the 16-bit words of the stack address happened to
be all-ones during the size calculation pass. Fix the problem by
assuming the worst case (4 instructions) when calculating the size
of the bpf_tramp_image address emission.

Fixes: 19d3c179a377 ("bpf, arm64: Fix trampoline for BPF_TRAMP_F_CALL_ORIG")
Signed-off-by: Peter Collingbourne <pcc@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://linux-review.googlesource.com/id/I1496f2bc24fba7a1d492e16e2b94cf43714f2d3c
Link: https://lore.kernel.org/bpf/20241018221644.3240898-1-pcc@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/net/bpf_jit_comp.c