* [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback()
@ 2026-07-27 9:38 Heiko Carstens
2026-07-27 13:09 ` Mykyta Yatsenko
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2026-07-27 9:38 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: Mykyta Yatsenko, bpf, linux-kernel
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 <hca@linux.ibm.com>
---
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)
{
struct bpf_task_work_ctx *ctx = container_of(cb, struct bpf_task_work_ctx, work);
enum bpf_task_work_state state;
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback()
2026-07-27 9:38 [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback() Heiko Carstens
@ 2026-07-27 13:09 ` Mykyta Yatsenko
2026-07-27 14:13 ` Heiko Carstens
0 siblings, 1 reply; 4+ messages in thread
From: Mykyta Yatsenko @ 2026-07-27 13:09 UTC (permalink / raw)
To: Heiko Carstens, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: Mykyta Yatsenko, bpf, linux-kernel
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 <hca@linux.ibm.com>
> ---
> 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/20260724-task_work_cfi-v1-1-2616691781ed@meta.com/
Is __bpfcall still needed?
> {
> struct bpf_task_work_ctx *ctx = container_of(cb, struct bpf_task_work_ctx, work);
> enum bpf_task_work_state state;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback()
2026-07-27 13:09 ` Mykyta Yatsenko
@ 2026-07-27 14:13 ` Heiko Carstens
2026-08-01 18:34 ` Kumar Kartikeya Dwivedi
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2026-07-27 14:13 UTC (permalink / raw)
To: Mykyta Yatsenko
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi, Mykyta Yatsenko, bpf,
linux-kernel, Russell King, Puranjay Mohan
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 <hca@linux.ibm.com>
> > ---
> > 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/20260724-task_work_cfi-v1-1-2616691781ed@meta.com/
> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback()
2026-07-27 14:13 ` Heiko Carstens
@ 2026-08-01 18:34 ` Kumar Kartikeya Dwivedi
0 siblings, 0 replies; 4+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-08-01 18:34 UTC (permalink / raw)
To: Heiko Carstens, Mykyta Yatsenko
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Mykyta Yatsenko, bpf, linux-kernel,
Russell King, Puranjay Mohan
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 <hca@linux.ibm.com>
>> > ---
>> > 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/20260724-task_work_cfi-v1-1-2616691781ed@meta.com/
>> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-01 18:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 9:38 [PATCH bpf-next] bpf: Add __bpfcall attribute to bpf_task_work_callback() Heiko Carstens
2026-07-27 13:09 ` Mykyta Yatsenko
2026-07-27 14:13 ` Heiko Carstens
2026-08-01 18:34 ` Kumar Kartikeya Dwivedi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome