On 2/4/24 4:02 AM, Kumar Kartikeya Dwivedi wrote:
Add selftests for static subprog calls within bpf_spin_lock critical
section, and ensure we still reject global subprog calls. Also test the
case where a subprog call will unlock the caller's held lock, or the
caller will unlock a lock taken by a subprog call, ensuring correct
transfer of lock state across frames on exit.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
LGTM with possible verifier message rewording from "function calls are
not allowed while holding a lock" to "global function calls are not
allowed ...".
Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
---
.../selftests/bpf/prog_tests/spin_lock.c | 2 +
.../selftests/bpf/progs/test_spin_lock.c | 65 +++++++++++++++++++
.../selftests/bpf/progs/test_spin_lock_fail.c | 44 +++++++++++++
3 files changed, 111 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/spin_lock.c b/tools/testing/selftests/bpf/prog_tests/spin_lock.c
index 18d451be57c8..6a4962ca0e5e 100644
--- a/tools/testing/selftests/bpf/prog_tests/spin_lock.c
+++ b/tools/testing/selftests/bpf/prog_tests/spin_lock.c
@@ -48,6 +48,8 @@ static struct {
{ "lock_id_mismatch_innermapval_kptr", "bpf_spin_unlock of different lock" },
{ "lock_id_mismatch_innermapval_global", "bpf_spin_unlock of different lock" },
{ "lock_id_mismatch_innermapval_mapval", "bpf_spin_unlock of different lock" },
+ { "lock_global_subprog_call1", "function calls are not allowed while holding a lock" },
+ { "lock_global_subprog_call2", "function calls are not allowed while holding a lock" },
};
static int match_regex(const char *pattern, const char *string)
[...]