From: Heiko Carstens <hca@linux.ibm.com>
To: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com,
eddyz87@gmail.com, memxor@gmail.com,
Mykyta Yatsenko <yatsenko@meta.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Maxim Khmelevskii <max@linux.ibm.com>
Subject: Re: [PATCH bpf-next v8 7/9] bpf: task work scheduling kfuncs
Date: Fri, 24 Jul 2026 13:22:21 +0200 [thread overview]
Message-ID: <20260724112221.212464A3f-hca@linux.ibm.com> (raw)
In-Reply-To: <20250923112404.668720-8-mykyta.yatsenko5@gmail.com>
On Tue, Sep 23, 2025 at 12:24:02PM +0100, Mykyta Yatsenko wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
>
> Implementation of the new bpf_task_work_schedule kfuncs, that let a BPF
> program schedule task_work callbacks for a target task:
> * bpf_task_work_schedule_signal() - schedules with TWA_SIGNAL
> * bpf_task_work_schedule_resume() - schedules with TWA_RESUME
...
> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
> kernel/bpf/helpers.c | 292 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 290 insertions(+), 2 deletions(-)
...
> +static void bpf_task_work_callback(struct callback_head *cb)
> +{
...
> + migrate_disable();
> + ctx->callback_fn(ctx->map, key, ctx->map_val);
> + migrate_enable();
The above indirect call results in a CFI failure - while trying to make kCFI
work on s390, and running the bpf selftests I stumbled across this, which can
also be reproduced on x86:
[ 29.357395] CFI failure at bpf_task_work_callback+0x168/0x280 (target: bpf_prog_8ce783214b8218cc_task_work_callback+0x0/0x50f; expected type: 0x37c2b4a2)
[ 29.360146] Oops: invalid opcode: 0000 [#1] SMP NOPTI
[ 29.360960] CPU: 0 UID: 0 PID: 124 Comm: test_progs Tainted: G OE 7.2.0-rc4-00365-g48a5a7ab8d6a-dirty #1 PREEMPT(full)
[ 29.361698] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[ 29.362027] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-9.fc43 06/10/2025
[ 29.362625] RIP: 0010:bpf_task_work_callback+0x168/0x280
The problem is that above callback_fn is of type
typedef int (*bpf_task_work_callback_t)(struct bpf_map *map, void *key, void *value);
while in fact the indirectly called bpf subprogram has a function type of
typedef u64 (*bpf_callback_t)(u64, u64, u64, u64, u64);
which doesn't match and which subsequently leads to the above crash when called.
This can be reproduced with the following steps:
cd tools/testing/selftests/bpf/
Change vmtest.sh to make use of clang:
- local make_command="make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} \
+ local make_command="make LLVM=1 ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} \
Add CONFIG_CFI=y to config.x86_64 and then run
./vmtest.sh -- ./test_progs -t task_work
next prev parent reply other threads:[~2026-07-24 11:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 11:23 [PATCH bpf-next v8 0/9] bpf: Introduce deferred task context execution Mykyta Yatsenko
2025-09-23 11:23 ` [PATCH bpf-next v8 1/9] bpf: refactor special field-type detection Mykyta Yatsenko
2025-09-23 11:23 ` [PATCH bpf-next v8 2/9] bpf: extract generic helper from process_timer_func() Mykyta Yatsenko
2025-09-23 11:23 ` [PATCH bpf-next v8 3/9] bpf: htab: extract helper for freeing special structs Mykyta Yatsenko
2025-09-23 11:23 ` [PATCH bpf-next v8 4/9] bpf: verifier: permit non-zero returns from async callbacks Mykyta Yatsenko
2025-09-23 11:24 ` [PATCH bpf-next v8 5/9] bpf: bpf task work plumbing Mykyta Yatsenko
2025-09-23 11:24 ` [PATCH bpf-next v8 6/9] bpf: extract map key pointer calculation Mykyta Yatsenko
2025-09-23 11:24 ` [PATCH bpf-next v8 7/9] bpf: task work scheduling kfuncs Mykyta Yatsenko
2026-07-24 11:22 ` Heiko Carstens [this message]
2026-07-24 13:06 ` Mykyta Yatsenko
2026-07-24 15:29 ` Heiko Carstens
2025-09-23 11:24 ` [PATCH bpf-next v8 8/9] selftests/bpf: BPF task work scheduling tests Mykyta Yatsenko
2025-09-23 14:59 ` Alexei Starovoitov
2025-09-23 15:50 ` Ihor Solodrai
2025-09-23 11:24 ` [PATCH bpf-next v8 9/9] selftests/bpf: add bpf task work stress tests Mykyta Yatsenko
2025-09-23 15:20 ` [PATCH bpf-next v8 0/9] bpf: Introduce deferred task context execution patchwork-bot+netdevbpf
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=20260724112221.212464A3f-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=iii@linux.ibm.com \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=max@linux.ibm.com \
--cc=memxor@gmail.com \
--cc=mykyta.yatsenko5@gmail.com \
--cc=yatsenko@meta.com \
/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