[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABCJKueLLs7nUFnQ-BHWE3cPJncWACy2tG196n01QPpShUwKEg@mail.gmail.com>
Date: Wed, 11 Sep 2019 13:29:56 -0700
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Yonghong Song <yhs@...com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Kees Cook <keescook@...omium.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Björn Töpel <bjorn.topel@...el.com>
Subject: Re: [PATCH] bpf: validate bpf_func when BPF_JIT is enabled
On Wed, Sep 11, 2019 at 12:43 AM Yonghong Song <yhs@...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
Powered by blists - more mailing lists