From 3a157ec9b274d3c55fed45d52c15531db4210904 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2024 07:03:51 -0800 Subject: [PATCH] 6.7-stable patches added patches: selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch --- ...t-for-user-stacks-in-test_task_stack.patch | 57 +++++++++++++++++++ queue-6.7/series | 1 + 2 files changed, 58 insertions(+) create mode 100644 queue-6.7/selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch diff --git a/queue-6.7/selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch b/queue-6.7/selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch new file mode 100644 index 00000000000..583678ef852 --- /dev/null +++ b/queue-6.7/selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch @@ -0,0 +1,57 @@ +From 727a92d62fd6a382b4c5972008e45667e707b0e4 Mon Sep 17 00:00:00 2001 +From: Jordan Rome +Date: Sat, 11 Nov 2023 18:30:10 -0800 +Subject: selftests/bpf: Add assert for user stacks in test_task_stack + +From: Jordan Rome + +commit 727a92d62fd6a382b4c5972008e45667e707b0e4 upstream. + +This is a follow up to: +commit b8e3a87a627b ("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 +Signed-off-by: Andrii Nakryiko +Acked-by: Stanislav Fomichev +Link: https://lore.kernel.org/bpf/20231112023010.144675-1-linux@jordanrome.com +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 2 ++ + tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c | 5 +++++ + 2 files changed, 7 insertions(+) + +--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c ++++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c +@@ -334,6 +334,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); + } + +--- a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c ++++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c +@@ -35,6 +35,8 @@ int dump_task_stack(struct bpf_iter__tas + 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 + 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 diff --git a/queue-6.7/series b/queue-6.7/series index a226d31e95f..056e4f6d7f0 100644 --- a/queue-6.7/series +++ b/queue-6.7/series @@ -377,3 +377,4 @@ of-unittest-fix-of_count_phandle_with_args-expected-.patch class-fix-use-after-free-in-class_register.patch kernfs-convert-kernfs_idr_lock-to-an-irq-safe-raw-spinlock.patch revert-kernfs-convert-kernfs_idr_lock-to-an-irq-safe-raw-spinlock.patch +selftests-bpf-add-assert-for-user-stacks-in-test_task_stack.patch -- 2.47.3