mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 15:47:36 +00:00
selftests/bpf: Add assert for user stacks in test_task_stack
commit727a92d62f
upstream. This is a follow up to: commitb8e3a87a62
("bpf: Add crosstask check to __bpf_get_stack"). This test ensures that the task iterator only gets a single user stack (for the current task). Signed-off-by: Jordan Rome <linux@jordanrome.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/bpf/20231112023010.144675-1-linux@jordanrome.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
cc9c60b253
commit
10193a5001
2 changed files with 7 additions and 0 deletions
|
@ -150,6 +150,8 @@ static void test_task_stack(void)
|
|||
do_dummy_read(skel->progs.dump_task_stack);
|
||||
do_dummy_read(skel->progs.get_task_user_stacks);
|
||||
|
||||
ASSERT_EQ(skel->bss->num_user_stacks, 1, "num_user_stacks");
|
||||
|
||||
bpf_iter_task_stack__destroy(skel);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ int dump_task_stack(struct bpf_iter__task *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int num_user_stacks = 0;
|
||||
|
||||
SEC("iter/task")
|
||||
int get_task_user_stacks(struct bpf_iter__task *ctx)
|
||||
{
|
||||
|
@ -51,6 +53,9 @@ int get_task_user_stacks(struct bpf_iter__task *ctx)
|
|||
if (res <= 0)
|
||||
return 0;
|
||||
|
||||
/* Only one task, the current one, should succeed */
|
||||
++num_user_stacks;
|
||||
|
||||
buf_sz += res;
|
||||
|
||||
/* If the verifier doesn't refine bpf_get_task_stack res, and instead
|
||||
|
|
Loading…
Reference in a new issue