From: David Marchevsky <david.marchevsky@linux.dev>
To: Yonghong Song <yonghong.song@linux.dev>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpf: Remove a WARN_ON_ONCE warning related to local kptr
Date: Thu, 24 Aug 2023 01:16:25 -0400 [thread overview]
Message-ID: <8c020115-399c-14de-0282-593f66e34c17@linux.dev> (raw)
In-Reply-To: <20230823225556.1292811-1-yonghong.song@linux.dev>
On 8/23/23 6:55 PM, Yonghong Song wrote:
> Currently, in function bpf_obj_free_fields(), for local kptr,
> a warning will be issued if the struct does not contain any
> special fields. But actually the kernel seems totally okay
> with a local kptr without any special fields. Permitting
> no special fields also aligns with future percpu kptr which
> also allows no special fields.
>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> ---
Weird. Looking at the WARN_ON_ONCE now, I can't understand why I added it,
and history of the series adding it doesn't have any clues. The same series
added pointee_struct_meta ? pointee_struct_meta->record : NULL two lines below,
so it's not clear what I was trying to protect against.
Anyways, I agree that:
* We can have a struct with a special __kptr field that points to some
local kptr type
* That local kptr 'pointee' type doesn't need to have any special fields, in
which case pointee_struct_meta will rightly be NULL, a NULL record will be
passed to __bpf_obj_drop_impl, which will handle it correctly.
* In fact this is the same logic that bpf_obj_drop_impl does before calling
its double-underscore cousin
LGTM
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
> kernel/bpf/syscall.c | 1 -
> 1 file changed, 1 deletion(-)
>
> NOTE: I didn't put a fix tag since except the warning
> there is no correctness issue here.
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 10666d17b9e3..ebeb0695305a 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -657,7 +657,6 @@ void bpf_obj_free_fields(const struct btf_record *rec, void *obj)
> if (!btf_is_kernel(field->kptr.btf)) {
> pointee_struct_meta = btf_find_struct_meta(field->kptr.btf,
> field->kptr.btf_id);
> - WARN_ON_ONCE(!pointee_struct_meta);
> migrate_disable();
> __bpf_obj_drop_impl(xchgd_field, pointee_struct_meta ?
> pointee_struct_meta->record :
prev parent reply other threads:[~2023-08-24 5:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 22:55 [PATCH bpf-next 1/2] bpf: Remove a WARN_ON_ONCE warning related to local kptr Yonghong Song
2023-08-23 22:56 ` [PATCH bpf-next 2/2] selftests/bpf: Add a local kptr test with no special fields Yonghong Song
2023-08-24 5:31 ` David Marchevsky
2023-08-24 5:56 ` Yonghong Song
2023-08-24 5:16 ` David Marchevsky [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=8c020115-399c-14de-0282-593f66e34c17@linux.dev \
--to=david.marchevsky@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.