]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Add tests for async cb context
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Tue, 7 Oct 2025 22:03:49 +0000 (22:03 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 10 Oct 2025 17:04:51 +0000 (10:04 -0700)
commit5b1b5d380ac7de39e9cb9de4209719b3949ebd3c
treed06ab313435df1dd7fa7e4ad36bf57815e7a06e3
parentf233d4855918547f19c5bff95223706d1c836b7c
selftests/bpf: Add tests for async cb context

Add tests to verify that async callback's sleepable attribute is
correctly determined by the callback type, not the arming program's
context, reflecting its true execution context.

Introduce verifier_async_cb_context.c with tests for all three async
callback primitives: bpf_timer, bpf_wq, and bpf_task_work. Each
primitive is tested when armed from both sleepable (lsm.s/file_open) and
non-sleepable (fentry) programs.

Test coverage:
- bpf_timer callbacks: Verify they are never sleepable, even when armed
  from sleepable programs. Both tests should fail when attempting to use
  sleepable helper bpf_copy_from_user() in the callback.

- bpf_wq callbacks: Verify they are always sleepable, even when armed
  from non-sleepable programs. Both tests should succeed when using
  sleepable helpers in the callback.

- bpf_task_work callbacks: Verify they are always sleepable, even when
  armed from non-sleepable programs. Both tests should succeed when
  using sleepable helpers in the callback.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20251007220349.3852807-4-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/verifier.c
tools/testing/selftests/bpf/progs/verifier_async_cb_context.c [new file with mode: 0644]