Skip to content

Commit

Permalink
selftests/bpf: Expand coverage of preempt tests to sleepable kfunc
Browse files Browse the repository at this point in the history
For preemption-related kfuncs, we don't test their interaction with
sleepable kfuncs (we do test helpers) even though the verifier has
code to protect against such a pattern. Expand coverage of the selftest
to include this case.

Acked-by: Eduard Zingerman <[email protected]>
Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>
  • Loading branch information
kkdwivedi authored and intel-lab-lkp committed Nov 28, 2024
1 parent 0513bd6 commit 6b3f546
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/testing/selftests/bpf/progs/preempt_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ int preempt_sleepable_helper(void *ctx)
return 0;
}

SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
__failure __msg("kernel func bpf_copy_from_user_str is sleepable within non-preemptible region")
int preempt_sleepable_kfunc(void *ctx)
{
u32 data;

bpf_preempt_disable();
bpf_copy_from_user_str(&data, sizeof(data), NULL, 0);
bpf_preempt_enable();
return 0;
}

int __noinline preempt_global_subprog(void)
{
preempt_balance_subprog();
Expand Down

0 comments on commit 6b3f546

Please sign in to comment.