Messages in this thread | | | From | Sami Tolvanen <> | Date | Wed, 11 Sep 2019 13:29:56 -0700 | Subject | Re: [PATCH] bpf: validate bpf_func when BPF_JIT is enabled |
| |
On Wed, Sep 11, 2019 at 12:43 AM Yonghong Song <yhs@fb.com> wrote: > How about this: > > if (!IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) && !prog->jited) > goto out; > > if (unlikely(hdr->magic != BPF_BINARY_HEADER_MAGIC || > !arch_bpf_jit_check_func(prog))) { > WARN(1, "attempt to jump to an invalid address"); > return 0; > } > out: > return prog->bpf_func(ctx, prog->insnsi);
Sure, that does look cleaner. I'll use this in the next version. Thanks.
Sami
| |