mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
bpf: Fix CFI mismatch in task work callback
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: 38aa7003e3 ("bpf: task work scheduling kfuncs")
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Link: https://lore.kernel.org/bpf/20260724-task_work_cfi-v1-1-2616691781ed@meta.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
This commit is contained in:
parent
159d4fbb6c
commit
2805abd089
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user