From: Yonghong Song <yonghong.song@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Dave Marchevsky <davemarchevsky@fb.com>,
bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>,
Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf 1/2] bpf: Fix a bpf_kptr_xchg() issue with local kptr
Date: Mon, 21 Aug 2023 15:13:23 -0700 [thread overview]
Message-ID: <9ae87beb-af3b-1b45-9027-e8a8e2399159@linux.dev> (raw)
In-Reply-To: <CAADnVQL-795Wzhy7E3N5XgVT0OgL0eFMwXxsD1myBGRbUVwaEg@mail.gmail.com>
On 8/21/23 12:44 PM, Alexei Starovoitov wrote:
> On Mon, Aug 21, 2023 at 9:03 AM Kumar Kartikeya Dwivedi
> <memxor@gmail.com> wrote:
>>>>
>>>> The fix on its own looks ok to me, but any reason you'd not like to
>>>> delegate to map_kptr_match_type?
>>>> Just to collect kptr related type matching logic in its own place. It
>>>> doesn't matter too much though.
>>>
>>> From comments from Alexei in
>>>
>>> https://lore.kernel.org/bpf/20230819002907.io3iphmnuk43xblu@macbook-pro-8.dhcp.thefacebook.com/#t
>>>
>>> =====
>>> The map_kptr_match_type() should have been used for kptrs pointing to
>>> kernel objects only.
>>> But you're calling it for MEM_ALLOC object with prog's BTF...
>>> =====
>>>
>>> So looks like map_kptr_match_type() is for kptrs pointing to
>>> kernel objects only. So that is why I didn't use it.
>>>
>>
>> That function was added by me. Back then I added this check as we were
>> discussing possibly supporting such local kptr and more thought would
>> be needed about the design before just doing type matching. Also it
>> was using kernel_type_name which was later renamed as btf_type_name,
>> so as a precaution I added the btf_is_kernel check. Apart from that I
>> remember no other reason, so I think it should be ok to drop it now
>> and use it.
>
> Agree with Kumar.
> When I said map_kptr_match_type() is only used with kernel BTF I meant
> that as code stands it was the intent of that helper.
> With MEM_ALLOC being kptr_xchg-ed it's better to share the code and
> map_kptr_match_type() should probably be adopted to work with both kernel
> and prog's BTFs.
Sounds good to me. Will use map_kptr_match_type() in v2.
>
> And as Kumar noticed __check_ptr_off_reg() part of it is necessary for
> MEM_ALLOC too.
next prev parent reply other threads:[~2023-08-21 22:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 0:02 [PATCH bpf 1/2] bpf: Fix a bpf_kptr_xchg() issue with local kptr Yonghong Song
2023-08-21 0:02 ` [PATCH bpf 2/2] selftests/bpf: Add a failure test for bpf_kptr_xchg() " Yonghong Song
2023-08-21 8:36 ` Kumar Kartikeya Dwivedi
2023-08-21 8:36 ` [PATCH bpf 1/2] bpf: Fix a bpf_kptr_xchg() issue " Kumar Kartikeya Dwivedi
2023-08-21 14:22 ` Yonghong Song
2023-08-21 16:03 ` Kumar Kartikeya Dwivedi
2023-08-21 18:23 ` Yonghong Song
2023-08-21 19:44 ` Alexei Starovoitov
2023-08-21 22:13 ` Yonghong Song [this message]
2023-08-21 22:35 ` Alexei Starovoitov
2023-08-22 5:15 ` David Marchevsky
2023-08-22 12:55 ` Kumar Kartikeya Dwivedi
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=9ae87beb-af3b-1b45-9027-e8a8e2399159@linux.dev \
--to=yonghong.song@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.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