diff options
author | Peter Zijlstra <peterz@infradead.org> | 2023-12-15 12:12:18 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-12-16 03:25:55 +0300 |
commit | 4f9087f16651aca4a5f32da840a53f6660f0579a (patch) | |
tree | 4aae945ff81a7447ed40741a7fc3fce4fbf6fc65 /include/linux/cfi.h | |
parent | 4382159696c9af67ee047ed55f2dbf05480f52f6 (diff) | |
download | linux-4f9087f16651aca4a5f32da840a53f6660f0579a.tar.xz |
x86/cfi,bpf: Fix BPF JIT call
The current BPF call convention is __nocfi, except when it calls !JIT things,
then it calls regular C functions.
It so happens that with FineIBT the __nocfi and C calling conventions are
incompatible. Specifically __nocfi will call at func+0, while FineIBT will have
endbr-poison there, which is not a valid indirect target. Causing #CP.
Notably this only triggers on IBT enabled hardware, which is probably why this
hasn't been reported (also, most people will have JIT on anyway).
Implement proper CFI prologues for the BPF JIT codegen and drop __nocfi for
x86.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231215092707.345270396@infradead.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/cfi.h')
-rw-r--r-- | include/linux/cfi.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/cfi.h b/include/linux/cfi.h index 2309d74e77e6..1ed2d96c0cfc 100644 --- a/include/linux/cfi.h +++ b/include/linux/cfi.h @@ -11,6 +11,13 @@ #include <linux/module.h> #include <asm/cfi.h> +#ifndef cfi_get_offset +static inline int cfi_get_offset(void) +{ + return 0; +} +#endif + #ifdef CONFIG_CFI_CLANG enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr, unsigned long *target, u32 type); |