diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index cdc79de0c794..0aa97d634866 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -976,3 +976,14 @@ void bpf_jit_free_exec(void *addr) { return vfree(addr); } + +#ifdef CONFIG_CFI_CLANG +bool arch_bpf_jit_check_func(const struct bpf_prog *prog) +{ + const uintptr_t func = (const uintptr_t)prog->bpf_func; + + /* bpf_func must be correctly aligned and within the BPF JIT region */ + return (func >= BPF_JIT_REGION_START && func < BPF_JIT_REGION_END && + IS_ALIGNED(func, sizeof(u32))); +} +#endif