From: Leon Hwang <hffilwlqm@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Hengqi Chen <hengqi.chen@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Stanislav Fomichev" <sdf@google.com>,
"kbuild test robot" <lkp@intel.com>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
"Fijalkowski, Maciej" <maciej.fijalkowski@intel.com>,
kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf] bpf: Fix tr dereferencing
Date: Sun, 17 Sep 2023 22:29:44 +0800 [thread overview]
Message-ID: <3a354608-6685-ee51-6317-9bf127cfd7b8@gmail.com> (raw)
In-Reply-To: <CAADnVQ+FLBbvE=TPuNHs2ir3s+6kVOpZGQ4U_X3SuAaAAcdL-w@mail.gmail.com>
On 2023/9/16 01:38, Alexei Starovoitov wrote:
> On Thu, Sep 14, 2023 at 7:54 PM Hengqi Chen <hengqi.chen@gmail.com> wrote:
>>
>> On Fri, Sep 15, 2023 at 10:18 AM Leon Hwang <hffilwlqm@gmail.com> wrote:
>>>
>>>
>>>
>>> On 15/9/23 10:13, Hengqi Chen wrote:
>>>> On Thu, Sep 14, 2023 at 10:51 PM Leon Hwang <hffilwlqm@gmail.com> wrote:
>>>>>
>>>>> Fix 'tr' dereferencing bug when CONFIG_BPF_JIT is turned off.
>>>>>
>>>>> Like 'bpf_trampoline_get_progs()', return 'ERR_PTR()' and then check by
>>>>> 'IS_ERR()'. As a result, when CONFIG_BPF_JIT is turned off, it's able to
>>>>> handle the case that 'bpf_trampoline_get()' returns
>>>>> 'ERR_PTR(-EOPNOTSUPP)'.
>>>>>
>>>>> Fixes: 4a1e7c0c63e0 ("bpf: Support attaching freplace programs to multiple attach points")
>>>>> Fixes: f7b12b6fea00 ("bpf: verifier: refactor check_attach_btf_id()")
>>>>> Fixes: 69fd337a975c ("bpf: per-cgroup lsm flavor")
>>>>> Reported-by: kernel test robot <lkp@intel.com>
>>>>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
>>>>> Closes: https://lore.kernel.org/r/202309131936.5Nc8eUD0-lkp@intel.com/
>>>>> Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
>>>>> ---
>>>>> kernel/bpf/syscall.c | 4 ++--
>>>>> kernel/bpf/trampoline.c | 6 +++---
>>>>> kernel/bpf/verifier.c | 4 ++--
>>>>> 3 files changed, 7 insertions(+), 7 deletions(-)
>>>>>
>>>>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>>>>> index 6a692f3bea150..5748d01c99854 100644
>>>>> --- a/kernel/bpf/syscall.c
>>>>> +++ b/kernel/bpf/syscall.c
>>>>> @@ -3211,8 +3211,8 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog,
>>>>> }
>>>>>
>>>>> tr = bpf_trampoline_get(key, &tgt_info);
>>>>> - if (!tr) {
>>>>> - err = -ENOMEM;
>>>>> + if (IS_ERR(tr)) {
>>>>> + err = PTR_ERR(tr);
>>>>> goto out_unlock;
>>>>
>>>> IS_ERR does not check the null case, so this should be IS_ERR_OR_NULL instead.
>>>
>>> Actually, bpf_trampoline_get() would not return NULL. It returns ERR_PTR(-ENOMEM)
>>> or a valid ptr.
>>>
>>
>> OK, I missed the change in bpf_trampoline_get(). Anyway,
>>
>> Reviewed-by: Hengqi Chen <hengqi.chen@gmail.com>
>
> That's too much churn to address !JIT config.
> Just make it return NULL in that case,
> instead of hacking things all over the place.
OK, I'll do it in v2 patch.
Thanks,
Leon
prev parent reply other threads:[~2023-09-17 14:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 14:51 [PATCH bpf] bpf: Fix tr dereferencing Leon Hwang
2023-09-14 21:49 ` Jiri Olsa
2023-09-15 2:13 ` Hengqi Chen
2023-09-15 2:18 ` Leon Hwang
2023-09-15 2:54 ` Hengqi Chen
2023-09-15 17:38 ` Alexei Starovoitov
2023-09-17 14:29 ` Leon Hwang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a354608-6685-ee51-6317-9bf127cfd7b8@gmail.com \
--to=hffilwlqm@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=daniel@iogearbox.net \
--cc=hengqi.chen@gmail.com \
--cc=kernel-patches-bot@fb.com \
--cc=lkp@intel.com \
--cc=maciej.fijalkowski@intel.com \
--cc=sdf@google.com \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox