Thread (15 messages) flat view 15 messages, 4 authors, 2025-02-08

Re: [PATCH v3 2/2] selftests/seccomp: validate uretprobe syscall passes through seccomp

From: Eyal Birger <hidden>
Date: 2025-02-02 21:13:41
Also in: bpf, linux-trace-kernel, lkml

On Sun, Feb 2, 2025 at 12:51 PM Jiri Olsa [off-list ref] wrote:
On Sun, Feb 02, 2025 at 08:29:21AM -0800, Eyal Birger wrote:

SNIP
quoted
+TEST_F(URETPROBE, uretprobe_default_block)
+{
+     struct sock_filter filter[] = {
+             BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
+                     offsetof(struct seccomp_data, nr)),
+             BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_exit_group, 1, 0),
+             BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
+             BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
+     };
+     struct sock_fprog prog = {
+             .len = (unsigned short)ARRAY_SIZE(filter),
+             .filter = filter,
+     };
+
+     ASSERT_EQ(0, run_probed_with_filter(&prog));
+}
+
+TEST_F(URETPROBE, uretprobe_block_uretprobe_syscall)
+{
+     struct sock_filter filter[] = {
+             BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
+                     offsetof(struct seccomp_data, nr)),
+#ifdef __NR_uretprobe
+             BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_uretprobe, 0, 1),
+#endif
does it make sense to run these tests on archs without __NR_uretprobe ?
I considered ifdefing them out, but then thought that given it's not
a lot of code it'd be better for the tests to be compiling and
ready in case support is added on a new platform than to have to
worry about that at that point.

Eyal.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help