aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/d_path.c
diff options
context:
space:
mode:
authorDaniel Borkmann <[email protected]>2022-01-12 12:39:48 +0000
committerDaniel Borkmann <[email protected]>2022-01-19 00:27:03 +0000
commit37c8d4807d1b8b521b30310dce97f6695dc2c2c6 (patch)
tree338441804d596c6fa819c214b8faa5046f74aaac /tools/testing/selftests/bpf/prog_tests/d_path.c
parentbpf, selftests: Add various ringbuf tests with invalid offset (diff)
downloadkernel-37c8d4807d1b8b521b30310dce97f6695dc2c2c6.tar.gz
kernel-37c8d4807d1b8b521b30310dce97f6695dc2c2c6.zip
bpf, selftests: Add ringbuf memory type confusion test
Add two tests, one which asserts that ring buffer memory can be passed to other helpers for populating its entry area, and another one where verifier rejects different type of memory passed to bpf_ringbuf_submit(). Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: John Fastabend <[email protected]> Acked-by: Alexei Starovoitov <[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.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c
index 32fc5b3b5cf6..911345c526e6 100644
--- a/tools/testing/selftests/bpf/prog_tests/d_path.c
+++ b/tools/testing/selftests/bpf/prog_tests/d_path.c
@@ -10,6 +10,7 @@
#include "test_d_path.skel.h"
#include "test_d_path_check_rdonly_mem.skel.h"
+#include "test_d_path_check_types.skel.h"
static int duration;
@@ -167,6 +168,16 @@ static void test_d_path_check_rdonly_mem(void)
test_d_path_check_rdonly_mem__destroy(skel);
}
+static void test_d_path_check_types(void)
+{
+ struct test_d_path_check_types *skel;
+
+ skel = test_d_path_check_types__open_and_load();
+ ASSERT_ERR_PTR(skel, "unexpected_load_passing_wrong_type");
+
+ test_d_path_check_types__destroy(skel);
+}
+
void test_d_path(void)
{
if (test__start_subtest("basic"))
@@ -174,4 +185,7 @@ void test_d_path(void)
if (test__start_subtest("check_rdonly_mem"))
test_d_path_check_rdonly_mem();
+
+ if (test__start_subtest("check_alloc_mem"))
+ test_d_path_check_types();
}