|
Message-ID: <CAGXu5jJp2Nt47EDL=wvqUuk4kTcExBqm1KbQtFOL_BTE+rybjQ@mail.gmail.com> Date: Tue, 18 Apr 2017 16:59:03 -0700 From: Kees Cook <keescook@...omium.org> To: Mickaël Salaün <mic@...ikod.net> Cc: LKML <linux-kernel@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>, Andy Lutomirski <luto@...capital.net>, Arnaldo Carvalho de Melo <acme@...nel.org>, Casey Schaufler <casey@...aufler-ca.com>, Daniel Borkmann <daniel@...earbox.net>, David Drysdale <drysdale@...gle.com>, "David S . Miller" <davem@...emloft.net>, "Eric W . Biederman" <ebiederm@...ssion.com>, James Morris <james.l.morris@...cle.com>, Jann Horn <jann@...jh.net>, Jonathan Corbet <corbet@....net>, Matthew Garrett <mjg59@...f.ucam.org>, Michael Kerrisk <mtk.manpages@...il.com>, Paul Moore <paul@...l-moore.com>, Sargun Dhillon <sargun@...gun.me>, "Serge E . Hallyn" <serge@...lyn.com>, Shuah Khan <shuah@...nel.org>, Tejun Heo <tj@...nel.org>, Thomas Graf <tgraf@...g.ch>, Will Drewry <wad@...omium.org>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, Linux API <linux-api@...r.kernel.org>, linux-security-module <linux-security-module@...r.kernel.org>, Network Development <netdev@...r.kernel.org> Subject: Re: [PATCH net-next v6 10/11] bpf,landlock: Add tests for Landlock On Tue, Apr 18, 2017 at 4:53 PM, Mickaël Salaün <mic@...ikod.net> wrote: > On 19/04/2017 01:16, Kees Cook wrote: >> On Tue, Mar 28, 2017 at 4:46 PM, Mickaël Salaün <mic@...ikod.net> wrote: >>> --- /dev/null >>> +++ b/tools/testing/selftests/landlock/Makefile >>> @@ -0,0 +1,47 @@ >>> +LIBDIR := ../../../lib >>> +BPFOBJ := $(LIBDIR)/bpf/bpf.o >>> +LOADOBJ := ../../../../samples/bpf/bpf_load.o >> >> Is the selftest tarball creation tool okay with this? IIRC, it should >> be fine since it'll be a built object already, but it's a random >> thought I had while looking at this. > > Hum, I'll check since it's the same for BPF tests. Okay, cool. >>> +# asm/sysreg.h - inline assembly used by it is incompatible with llvm. >>> +# But, there is no easy way to fix it, so just exclude it since it is >>> +# useless for BPF samples. >>> +$(obj)/%.o: $(src)/%.c >>> + $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ >>> + -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ >>> + -Wno-compare-distinct-pointer-types \ >>> + -Wno-gnu-variable-sized-type-not-at-end \ >>> + -Wno-tautological-compare \ >>> + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ >> >> Is clang required for the samples and the selftests? That needs to be >> avoided... there needs to be a way to show people how to build a >> landlock rule without requiring clang. > > I can rewrite this tests without requiring clang but it is already > required for BPF tests… So, I guess it's not a big deal for selftests (but it'd be nice, even for BPF), but I think at least the samples/ should have examples on how to do it "by hand", etc. Not everyone will build stuff with clang, and it'd be good to make landlock as available as possible. >>> +#define ASSERT_STEP(cond) \ >>> + { \ >>> + step--; \ >>> + if (!(cond)) \ >>> + _exit(step); \ >>> + } >> >> Can you explain this in more detail? I'm assuming there is a problem >> with writing to the TH_LOG_STREAM fd or something? > > It's a trick to use the test framework without requiring to be allowed > to write to an FD (i.e. log stream), but only to exit a code. I use this > to test a Landlock rule which forbid access to any FS objects (including > open FD). This could be used for seccomp too. Okay. For seccomp, we just allow the fd. :P I'm not opposed to it; it just makes some debugging harder without text details, etc. -Kees -- Kees Cook Pixel Security
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.