* [PATCH bpf-next] bpf: Fix CFI mismatch in task work callback
@ 2026-07-24 15:52 Mykyta Yatsenko
2026-07-24 20:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Mykyta Yatsenko @ 2026-07-24 15:52 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
Ihor Solodrai, kernel-team, hca
Cc: bpf, linux-kernel, Mykyta Yatsenko
From: Mykyta Yatsenko <yatsenko@meta.com>
BPF subprograms use the bpf_callback_t ABI, but task work invokes the
callback through a three-argument function pointer. This trips kCFI.
Store and invoke the callback as bpf_callback_t.
Fixes: 38aa7003e369 ("bpf: task work scheduling kfuncs")
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
The unpatched task_work selftest triggers a kCFI failure and kernel panic.
With this patch, all task_work and task_work_stress subtests pass with
CONFIG_CFI=y.
---
kernel/bpf/helpers.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index c18f1e16edee..88b38db47de9 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -4388,7 +4388,7 @@ struct bpf_task_work_ctx {
struct bpf_map *map;
void *map_val;
enum task_work_notify_mode mode;
- bpf_task_work_callback_t callback_fn;
+ bpf_callback_t callback_fn;
struct rcu_head rcu;
} __aligned(8);
@@ -4471,7 +4471,8 @@ static void bpf_task_work_callback(struct callback_head *cb)
key = (void *)map_key_from_value(ctx->map, ctx->map_val, &idx);
migrate_disable();
- ctx->callback_fn(ctx->map, key, ctx->map_val);
+ ctx->callback_fn((u64)(long)ctx->map, (u64)(long)key,
+ (u64)(long)ctx->map_val, 0, 0);
migrate_enable();
bpf_task_work_ctx_reset(ctx);
@@ -4594,7 +4595,7 @@ static struct bpf_task_work_ctx *bpf_task_work_acquire_ctx(struct bpf_task_work
}
static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work *tw,
- struct bpf_map *map, bpf_task_work_callback_t callback_fn,
+ struct bpf_map *map, void *callback_fn,
struct bpf_prog_aux *aux, enum task_work_notify_mode mode)
{
struct bpf_prog *prog;
@@ -4619,7 +4620,7 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work
}
ctx->task = task;
- ctx->callback_fn = callback_fn;
+ ctx->callback_fn = (bpf_callback_t)callback_fn;
ctx->prog = prog;
ctx->mode = mode;
ctx->map = map;
---
base-commit: c21669db988c8f7cc525198dd33941eec7f092fa
change-id: 20260724-task_work_cfi-5bd42ea2f62a
Best regards,
--
Mykyta Yatsenko <yatsenko@meta.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next] bpf: Fix CFI mismatch in task work callback
2026-07-24 15:52 [PATCH bpf-next] bpf: Fix CFI mismatch in task work callback Mykyta Yatsenko
@ 2026-07-24 20:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-24 20:40 UTC (permalink / raw)
To: Mykyta Yatsenko
Cc: ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, kernel-team, hca, bpf,
linux-kernel, yatsenko
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Kumar Kartikeya Dwivedi <memxor@gmail.com>:
On Fri, 24 Jul 2026 08:52:06 -0700 you wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
>
> BPF subprograms use the bpf_callback_t ABI, but task work invokes the
> callback through a three-argument function pointer. This trips kCFI.
>
> Store and invoke the callback as bpf_callback_t.
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Fix CFI mismatch in task work callback
https://git.kernel.org/bpf/bpf-next/c/2805abd08957
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-24 20:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 15:52 [PATCH bpf-next] bpf: Fix CFI mismatch in task work callback Mykyta Yatsenko
2026-07-24 20:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).