From: Kees Cook <kees@kernel.org>
To: Eyal Birger <eyal.birger@gmail.com>
Cc: Jiri Olsa <olsajiri@gmail.com>,
luto@amacapital.net, wad@chromium.org, oleg@redhat.com,
mhiramat@kernel.org, andrii@kernel.org,
alexei.starovoitov@gmail.com, cyphar@cyphar.com,
songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com,
peterz@infradead.org, tglx@linutronix.de, bp@alien8.de,
daniel@iogearbox.net, ast@kernel.org, andrii.nakryiko@gmail.com,
rostedt@goodmis.org, rafi@rbk.io, shmulik.ladkani@gmail.com,
bpf@vger.kernel.org, linux-api@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] selftests/seccomp: validate uretprobe syscall passes through seccomp
Date: Thu, 6 Feb 2025 13:18:51 -0800 [thread overview]
Message-ID: <202502061317.3B1F3D834@keescook> (raw)
In-Reply-To: <CAHsH6GtpzR5_X4e0KphnyNSkKqBdgivfvyGQ1mbtA8fpnuu5sg@mail.gmail.com>
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@gmail.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
next prev parent reply other threads:[~2025-02-06 21:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-02 16:29 [PATCH v3 0/2] seccomp: pass uretprobe system call through seccomp Eyal Birger
2025-02-02 16:29 ` [PATCH v3 1/2] seccomp: passthrough uretprobe systemcall without filtering Eyal Birger
2025-02-06 21:20 ` Kees Cook
2025-02-02 16:29 ` [PATCH v3 2/2] selftests/seccomp: validate uretprobe syscall passes through seccomp Eyal Birger
2025-02-02 20:51 ` Jiri Olsa
2025-02-02 21:13 ` Eyal Birger
2025-02-06 21:18 ` Kees Cook [this message]
2025-02-06 21:21 ` [PATCH v3 0/2] seccomp: pass uretprobe system call " Kees Cook
2025-02-07 1:06 ` Eyal Birger
2025-02-07 13:24 ` Jiri Olsa
2025-02-07 15:27 ` Jann Horn
2025-02-07 16:20 ` Eyal Birger
2025-02-07 16:50 ` Jann Horn
2025-02-08 0:03 ` Jiri Olsa
2025-02-08 20:35 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202502061317.3B1F3D834@keescook \
--to=kees@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=cyphar@cyphar.com \
--cc=daniel@iogearbox.net \
--cc=eyal.birger@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mhiramat@kernel.org \
--cc=oleg@redhat.com \
--cc=olsajiri@gmail.com \
--cc=peterz@infradead.org \
--cc=rafi@rbk.io \
--cc=rostedt@goodmis.org \
--cc=shmulik.ladkani@gmail.com \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--cc=wad@chromium.org \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox