From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH bpf v2 1/2] bpf: Fix tracing of kfuncs with implicit args
Date: Mon, 13 Jul 2026 09:48:06 -0700 [thread overview]
Message-ID: <9b2196dd-443b-4632-ae11-030cdbdc59b4@linux.dev> (raw)
In-Reply-To: <55f4d7bba39f0fd1e85f436423a4b9a967470701.camel@gmail.com>
On 2026-07-11 4:51 p.m., Eduard Zingerman wrote:
> On Sat, 2026-07-11 at 10:57 -0700, Ihor Solodrai wrote:
>> On 2026-07-11 3:43 a.m., Eduard Zingerman wrote:
>>> On Fri, 2026-07-10 at 12:29 -0700, Ihor Solodrai wrote:
>>>
>>> [...]
>>>
>>> If I am not confused, I think that resolve_btfids() has to verify that
>>> kfunc flags are always the same across multiple sets.
>>
>> Some form of build-time enforcement will be implemented as part of
>> resolve_btfids() BTF handling, see the v1 here:
>> https://lore.kernel.org/bpf/20260601221805.821394-1-ihor.solodrai@linux.dev/
>>
>> *If* you're right about no valid use-case for incosistent kfunc flags,
>> then long-term I agree: build-time enforcement of consistency, and
>> then the acummulation can be replaced by a search (find first) here.
>>
>> But this has to be confirmed somehow (by thoroughly inspecting all
>> current inconsistencies and flags?..)
>>
>> However if there is even one valid use-case, then we are in trouble,
>> because then depending on the flag semantics it may or may not make
>> sense for it to be consistent accross kfunc sets. And it's not even
>> clear what a good solution to that might look like: separate groups of
>> flags? consistency enforcement for some flags, but not others (this is
>> literally what Andrii suggested in resolve_btfids thread)?
>>
>> Accumulating flags across the sets is an acceptable workaround for
>> this fix IMO. We can be more specific and *only* check for the
>> KF_IMPLICIT_ARGS for the purposes of this fix though, but we still
>> have to walk all hooks and OR.
>
> And what would that mean for the same function to have
> KF_IMPLICIT_ARGS in one set and not to have it in another?
That would mean a bug in a kfunc set declaration, yeah.
> Given that actual function address is resolved to the exact same
> function. Such accumulator would only proliferate already confusing
> behaviour.
>
> I don't think that the analysis of existing cases would take longer
> than 1-2h.
It was silly of me to mention the analysis as an obstacle (which I'm
not excited to do, sure). We are at -rc3, so there is a couple of
weeks still if we are targeting 7.2
But resolve_btfids series is certainly a merge-window thing, so the
fix shouldn't depend on it. And even carving out build-time KF_ flag
consistentcy enforcement from there is too potentially disruptive for
a "fix" IMO.
How about the following plan.
In the fix:
* delete btf_kfunc_accumulated_flags()
* expose (back) btf_kfunc_id_set_contains() from btf.c
* in btf_attach_func_proto() walk the hooks and specifically check
for *consistent* KF_IMPLICIT_ARGS
* -EINVAL on inconsistency
In the v2 of resolve_btfids series (targeting 7.3):
* implement kbuild/module-time enforcement of consistency
for *all* KF_ flags
* fix in-tree cases where that's not true
* if there is a valid use-case, it should show up as a blocker, but
I'll also eyeball all the kfunc set declarations
Does this make sense?
>
>> I don't think it's reasonable to wait for the comprehensive kfunc flags
>> analysis and resolve_btfids series landing before fixing the garbage
>> dereference bug.
>>
>>>
>>>> [...]
next prev parent reply other threads:[~2026-07-13 16:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 19:29 [PATCH bpf v2 0/2] bpf: Fix tracing of kfuncs with implicit args Ihor Solodrai
2026-07-10 19:29 ` [PATCH bpf v2 1/2] " Ihor Solodrai
2026-07-11 10:43 ` Eduard Zingerman
2026-07-11 17:57 ` Ihor Solodrai
2026-07-11 23:51 ` Eduard Zingerman
2026-07-13 16:48 ` Ihor Solodrai [this message]
2026-07-13 17:01 ` Eduard Zingerman
2026-07-13 12:51 ` Jiri Olsa
2026-07-10 19:29 ` [PATCH bpf v2 2/2] selftests/bpf: Cover tracing implicit kfunc args Ihor Solodrai
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=9b2196dd-443b-4632-ae11-030cdbdc59b4@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=tj@kernel.org \
/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