diff options
| author | Hao Luo <[email protected]> | 2022-01-06 20:55:25 +0000 |
|---|---|---|
| committer | Andrii Nakryiko <[email protected]> | 2022-01-06 23:20:49 +0000 |
| commit | 44bab87d8ca6f0544a9f8fc97bdf33aa5b3c899e (patch) | |
| tree | e88c204993400047827074a50eb71bf3e50319bc /tools/testing/selftests/bpf/prog_tests/d_path.c | |
| parent | libbpf: Add documentation for bpf_map batch operations (diff) | |
| download | kernel-44bab87d8ca6f0544a9f8fc97bdf33aa5b3c899e.tar.gz kernel-44bab87d8ca6f0544a9f8fc97bdf33aa5b3c899e.zip | |
bpf/selftests: Test bpf_d_path on rdonly_mem.
The second parameter of bpf_d_path() can only accept writable
memories. Rdonly_mem obtained from bpf_per_cpu_ptr() can not
be passed into bpf_d_path for modification. This patch adds
a selftest to verify this behavior.
Signed-off-by: Hao Luo <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: Yonghong Song <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/d_path.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/d_path.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c index 0a577a248d34..32fc5b3b5cf6 100644 --- a/tools/testing/selftests/bpf/prog_tests/d_path.c +++ b/tools/testing/selftests/bpf/prog_tests/d_path.c @@ -9,6 +9,7 @@ #define MAX_FILES 7 #include "test_d_path.skel.h" +#include "test_d_path_check_rdonly_mem.skel.h" static int duration; @@ -99,7 +100,7 @@ out_close: return ret; } -void test_d_path(void) +static void test_d_path_basic(void) { struct test_d_path__bss *bss; struct test_d_path *skel; @@ -155,3 +156,22 @@ void test_d_path(void) cleanup: test_d_path__destroy(skel); } + +static void test_d_path_check_rdonly_mem(void) +{ + struct test_d_path_check_rdonly_mem *skel; + + skel = test_d_path_check_rdonly_mem__open_and_load(); + ASSERT_ERR_PTR(skel, "unexpected_load_overwriting_rdonly_mem"); + + test_d_path_check_rdonly_mem__destroy(skel); +} + +void test_d_path(void) +{ + if (test__start_subtest("basic")) + test_d_path_basic(); + + if (test__start_subtest("check_rdonly_mem")) + test_d_path_check_rdonly_mem(); +} |
