aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/filter.h
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2021-09-28 16:27:18 -0700
committerAlexei Starovoitov <ast@kernel.org>2021-09-28 16:27:19 -0700
commit72e1781a5de9e3ee804e24f7ce9a7dd85596fc51 (patch)
tree18cfa723e40dbe24928faf0299bf0b90e8df9f43 /include/linux/filter.h
parentbpftool: Avoid using "?: " in generated code (diff)
parentbpf: Replace callers of BPF_CAST_CALL with proper function typedef (diff)
downloadlinux-dev-72e1781a5de9e3ee804e24f7ce9a7dd85596fc51.tar.xz
linux-dev-72e1781a5de9e3ee804e24f7ce9a7dd85596fc51.zip
Merge branch 'bpf: Build with -Wcast-function-type'
Kees Cook says: ==================== Hi, In order to keep ahead of cases in the kernel where Control Flow Integrity (CFI) may trip over function call casts, enabling -Wcast-function-type is helpful. To that end, replace BPF_CAST_CALL() as it triggers warnings with this option and is now one of the last places in the kernel in need of fixing. Thanks, -Kees v2: - rebase to bpf-next - add acks v1: https://lore.kernel.org/lkml/20210927182700.2980499-1-keescook@chromium.org ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/filter.h')
-rw-r--r--include/linux/filter.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 4a93c12543ee..47f80adbe744 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -360,10 +360,9 @@ static inline bool insn_is_zext(const struct bpf_insn *insn)
.off = 0, \
.imm = TGT })
-/* Function call */
+/* Convert function address to BPF immediate */
-#define BPF_CAST_CALL(x) \
- ((u64 (*)(u64, u64, u64, u64, u64))(x))
+#define BPF_CALL_IMM(x) ((void *)(x) - (void *)__bpf_call_base)
#define BPF_EMIT_CALL(FUNC) \
((struct bpf_insn) { \
@@ -371,7 +370,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn)
.dst_reg = 0, \
.src_reg = 0, \
.off = 0, \
- .imm = ((FUNC) - __bpf_call_base) })
+ .imm = BPF_CALL_IMM(FUNC) })
/* Raw code statement block */