Re: [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback()
"Kumar Kartikeya Dwivedi" <[email protected]> Sat, 01 Aug 2026 20:34:45 +0200
| Newsgroups | org.kernel.vger.bpf,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon Jul 27, 2026 at 4:13 PM CEST, Heiko Carstens wrote:
> On Mon, Jul 27, 2026 at 02:09:12PM +0100, Mykyta Yatsenko wrote:
>> On 7/27/26 10:38 AM, Heiko Carstens wrote:
>> > BPF kCFI support is optional for architectures which support kCFI.
>> > If an architecture provides bpf kCFI support it must override the
>> > default __bpfcall define (which translates to __nocfi).
>> >
>> > Add the missing __bpfcall attribute to bpf_task_work_callback() which
>> > calls bpf programs indirectly to avoid CFI checks for such cases.
>> >
>> > Fixes: 38aa7003e369 ("bpf: task work scheduling kfuncs")
>> > Signed-off-by: Heiko Carstens <[email protected]>
>> > ---
>> > kernel/bpf/helpers.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
>> > index 88b38db47de9..9bf82c9ea1da 100644
>> > --- a/kernel/bpf/helpers.c
>> > +++ b/kernel/bpf/helpers.c
>> > @@ -4447,7 +4447,7 @@ static void bpf_task_work_cancel(struct bpf_task_work_ctx *ctx)
>> > bpf_task_work_ctx_put(ctx);
>> > }
>> >
>> > -static void bpf_task_work_callback(struct callback_head *cb)
>> > +static __bpfcall void bpf_task_work_callback(struct callback_head *cb)
>>
>> Thanks for the patch, I've already sent another fix:
>> https://lore.kernel.org/all/[email protected]/
>> Is __bpfcall still needed?
>
> Yes, it is needed for architectures which select ARCH_SUPPORTS_CFI, and which
> in addition support bpf, but do not provide CFI support for bpf programs.
>
> As of now it looks like this is only the case for arm, at least as far as I
> understand the code. It might be easier to implement bpf/cfi support for arm,
> then drop the __bpfcall macro entirely, and require from future architectures
> to provde bpf/cfi support whenever they select ARCH_SUPPORTS_CFI.
>
> I'm writing the above, since due to AI feedback to this patch, there seem to
> be more bpf functions which call bpf programs indirectly and which miss the
> __bpfcall attribute.
I think letting arm JIT folks figure out CFI support is a better path.
pw-bot: cr