aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSong Liu <song@kernel.org>2023-09-19 20:41:08 -0700
committerSong Liu <song@kernel.org>2023-09-26 09:05:33 -0700
commit906af6bb9a6c954a8da8d45faa2416e2fdb14c48 (patch)
treec83c5242ca2732232dc87b0bcde26dace3ca037f
parent0d49d071fabafcc3896825416a6d96ec78793952 (diff)
downloadlinux-906af6bb9a6c954a8da8d45faa2416e2fdb14c48.tar.gz
bpf, x86: Adjust arch_prepare_bpf_trampoline return value
x86's implementation of arch_prepare_bpf_trampoline() requires BPF_INSN_SAFETY buffer space between end of program and image_end. OTOH, the return value does not include BPF_INSN_SAFETY. This doesn't cause any real issue at the moment. However, "image" of size retval is not enough for arch_prepare_bpf_trampoline(). This will cause confusion when we introduce a new helper arch_bpf_trampoline_size(). To avoid future confusion, adjust the return value to include BPF_INSN_SAFETY. Signed-off-by: Song Liu <song@kernel.org> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 8c10d9abc2394f..5f7528cac34471 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -2671,7 +2671,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i
ret = -EFAULT;
goto cleanup;
}
- ret = prog - (u8 *)image;
+ ret = prog - (u8 *)image + BPF_INSN_SAFETY;
cleanup:
kfree(branches);