[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202502061317.3B1F3D834@keescook>
Date: Thu, 6 Feb 2025 13:18:51 -0800
From: Kees Cook <kees@...nel.org>
To: Eyal Birger <eyal.birger@...il.com>
Cc: Jiri Olsa <olsajiri@...il.com>, luto@...capital.net, wad@...omium.org,
oleg@...hat.com, mhiramat@...nel.org, andrii@...nel.org,
alexei.starovoitov@...il.com, cyphar@...har.com,
songliubraving@...com, yhs@...com, john.fastabend@...il.com,
peterz@...radead.org, tglx@...utronix.de, bp@...en8.de,
daniel@...earbox.net, ast@...nel.org, andrii.nakryiko@...il.com,
rostedt@...dmis.org, rafi@....io, shmulik.ladkani@...il.com,
bpf@...r.kernel.org, linux-api@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] selftests/seccomp: validate uretprobe syscall
passes through seccomp
On Sun, Feb 02, 2025 at 01:13:28PM -0800, Eyal Birger wrote:
> On Sun, Feb 2, 2025 at 12:51 PM Jiri Olsa <olsajiri@...il.com> wrote:
> >
> > On Sun, Feb 02, 2025 at 08:29:21AM -0800, Eyal Birger wrote:
> >
> > SNIP
> >
> > > +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.
The trouble I had is that on other archs, the tests fail. I've added
this, which retains build coverage, but doesn't trigger failures without
__NR_uretprobe:
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index bee4f424c5c3..14ba51b52095 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -4973,6 +4973,10 @@ FIXTURE_SETUP(URETPROBE)
ssize_t offset;
int type, bit;
+#ifndef __NR_uretprobe
+ SKIP(return, "__NR_uretprobe syscall not defined");
+#endif
+
if (!variant->attach)
return;
--
Kees Cook
Powered by blists - more mailing lists