[RFC v4 00/18] Landlock LSM: Unprivileged sandboxing

2016-10-25 Thread Mickaël Salaün
55/papers/traps.pdf [3] https://lkml.kernel.org/r/1477390454-12553-1-git-send-email-dan...@zonque.org [4] https://lkml.kernel.org/r/20160829114542.GA20836@ircssh.c.rugged-nimbus-611.internal Regards, Mickaël Salaün (18): landlock: Add Kconfig bpf: Move u64_to_ptr() to BPF headers and inline it bpf,landl

[RFC v4 01/18] landlock: Add Kconfig

2016-10-25 Thread Mickaël Salaün
Initial Landlock Kconfig needed to split the Landlock eBPF and seccomp parts to ease the review. Changes from v2: * add seccomp filter or cgroups (with eBPF programs attached support) dependencies Signed-off-by: Mickaël Salaün Cc: James Morris Cc: Kees Cook Cc: Serge E. Hallyn

[RFC v4 11/18] seccomp,landlock: Handle Landlock hooks per process hierarchy

2016-10-25 Thread Mickaël Salaün
e the understanding * fix some ifdef Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry Cc: Andrew Morton Link: https://lkml.kernel.org/r/cagxu5j+qowiyquhifobtupfpxp6xevdgf08bw4yzkvdtcha...@mail.gmail.com --- include/linux/landlock.h | 5 + include/linux/secc

Re: [RFC v3 06/22] landlock: Add LSM hooks

2016-10-19 Thread Mickaël Salaün
On 19/10/2016 17:19, Thomas Graf wrote: > On 09/14/16 at 09:23am, Mickaël Salaün wrote: >> diff --git a/include/linux/bpf.h b/include/linux/bpf.h >> index 9aa01d9d3d80..36c3e482239c 100644 >> --- a/include/linux/bpf.h >> +++ b/include/linux/bpf.h >> @@

Re: [PATCH v1] seccomp: Fix documentation

2016-10-15 Thread Mickaël Salaün
Could someone push this please? On 20/09/2016 19:39, Mickaël Salaün wrote: > Fix struct seccomp_filter and seccomp_run_filters() signatures. > > Signed-off-by: Mickaël Salaün > Cc: Andy Lutomirski > Cc: James Morris > Cc: Kees Cook > Cc: Will Drewry > ---

Re: [RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-10-05 Thread Mickaël Salaün
On 04/10/2016 01:53, Kees Cook wrote: > On Wed, Sep 14, 2016 at 12:23 AM, Mickaël Salaün wrote: >> This new arraymap looks like a set and brings new properties: >> * strong typing of entries: the eBPF functions get the array type of >> elements instead of

Re: [RFC v3 11/22] seccomp,landlock: Handle Landlock hooks per process hierarchy

2016-10-05 Thread Mickaël Salaün
On 04/10/2016 01:52, Kees Cook wrote: > On Wed, Sep 14, 2016 at 3:34 PM, Mickaël Salaün wrote: >> >> On 14/09/2016 20:43, Andy Lutomirski wrote: >>> On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >>>> A Landlock program will be triggered according

Re: [RFC v3 19/22] landlock: Add interrupted origin

2016-10-05 Thread Mickaël Salaün
On 04/10/2016 01:46, Kees Cook wrote: > On Wed, Sep 14, 2016 at 6:19 PM, Andy Lutomirski wrote: >> On Wed, Sep 14, 2016 at 3:14 PM, Mickaël Salaün wrote: >>> >>> On 14/09/2016 20:29, Andy Lutomirski wrote: >>>> On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Sa

Re: [RFC v3 16/22] bpf/cgroup,landlock: Handle Landlock hooks per cgroup

2016-10-05 Thread Mickaël Salaün
On 04/10/2016 01:43, Kees Cook wrote: > On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >> This allows to add new eBPF programs to Landlock hooks dedicated to a >> cgroup thanks to the BPF_PROG_ATTACH command. Like for socket eBPF >> programs, the Landlock hooks att

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-10-05 Thread Mickaël Salaün
On 04/10/2016 00:56, Kees Cook wrote: > On Tue, Sep 20, 2016 at 10:08 AM, Mickaël Salaün wrote: >> >> On 15/09/2016 11:19, Pavel Machek wrote: >>> Hi! >>> >>>> This series is a proof of concept to fill some missing part of seccomp as >>>&g

[PATCH v3] bpf: Set register type according to is_valid_access()

2016-09-24 Thread Mickaël Salaün
allowed is for socket filtering and all the types from its context are UNKNOWN_VALUE. However, this fix is important for future unprivileged eBPF programs which could use pointers in their context. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Daniel Borkmann --- kernel/bpf

[PATCH v2] bpf: Set register type according to is_valid_access()

2016-09-22 Thread Mickaël Salaün
unprivileged eBPF program types which could use pointers in their context. Signed-off-by: Mickaël Salaün Fixes: 969bf05eb3ce ("bpf: direct packet access") Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Kees Cook Acked-by: Sargun Dhillon --- kernel/bpf/verifier.c | 5 ++-

Re: [PATCH v1] bpf: Set register type according to is_valid_access()

2016-09-22 Thread Mickaël Salaün
On 22/09/2016 21:41, Daniel Borkmann wrote: > On 09/22/2016 08:35 PM, Mickaël Salaün wrote: >> This fix a pointer leak when an unprivileged eBPF program read a pointer >> value from the context. Even if is_valid_access() returns a pointer >> type, the eBPF verifier replace

[PATCH v1] bpf: Set register type according to is_valid_access()

2016-09-22 Thread Mickaël Salaün
unprivileged eBPF program types which could use pointers in their context. Signed-off-by: Mickaël Salaün Fixes: 969bf05eb3ce ("bpf: direct packet access") Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Kees Cook Acked-by: Sargun Dhillon --- kernel/bpf/verifier.c | 6 ++--

[PATCH v1] seccomp: Fix documentation

2016-09-20 Thread Mickaël Salaün
Fix struct seccomp_filter and seccomp_run_filters() signatures. Signed-off-by: Mickaël Salaün Cc: Andy Lutomirski Cc: James Morris Cc: Kees Cook Cc: Will Drewry --- kernel/seccomp.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/seccomp.c b/kernel

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-09-20 Thread Mickaël Salaün
On 15/09/2016 11:19, Pavel Machek wrote: > Hi! > >> This series is a proof of concept to fill some missing part of seccomp as the >> ability to check syscall argument pointers or creating more dynamic security >> policies. The goal of this new stackable Linux Security Module (LSM) called >> Landl

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-20 Thread Mickaël Salaün
On 20/09/2016 06:37, Sargun Dhillon wrote: > On Thu, Sep 15, 2016 at 09:41:33PM +0200, Mickaël Salaün wrote: >> >> On 15/09/2016 06:48, Alexei Starovoitov wrote: >>> On Wed, Sep 14, 2016 at 09:38:16PM -0700, Andy Lutomirski wrote: >>>> On Wed, Sep 14,

Re: lsm naming dilemma. Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-20 Thread Mickaël Salaün
forward for your review. > > On Mon, Sep 19, 2016 at 5:12 PM, Alexei Starovoitov > wrote: >> On Thu, Sep 15, 2016 at 11:25:10PM +0200, Mickaël Salaün wrote: >>>>> Agreed. With this RFC, the Checmate features (i.e. network helpers) >>>>> should be able t

Re: [PATCH v1] cgroup,bpf: Add access check for cgroup_get_from_fd()

2016-09-20 Thread Mickaël Salaün
On 20/09/2016 02:30, Alexei Starovoitov wrote: > On Tue, Sep 20, 2016 at 12:49:13AM +0200, Mickaël Salaün wrote: >> Add security access check for cgroup backed FD. The "cgroup.procs" file >> of the corresponding cgroup should be readable to identify the cgroup, >>

[PATCH v1] cgroup,bpf: Add access check for cgroup_get_from_fd()

2016-09-19 Thread Mickaël Salaün
ck done by cgroup_procs_write_permission(). Fixes: 4ed8ec521ed5 ("cgroup: bpf: Add BPF_MAP_TYPE_CGROUP_ARRAY") Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Daniel Mack Cc: David S. Miller Cc: James Morris Cc: Kees Cook Cc: Martin KaFai Lau Cc: Tej

Re: [RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-09-15 Thread Mickaël Salaün
On 15/09/2016 01:28, Alexei Starovoitov wrote: > On Thu, Sep 15, 2016 at 01:22:49AM +0200, Mickaël Salaün wrote: >> >> On 14/09/2016 20:51, Alexei Starovoitov wrote: >>> On Wed, Sep 14, 2016 at 09:23:56AM +0200, Mickaël Salaün wrote: >>>> This new arra

Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-15 Thread Mickaël Salaün
On 15/09/2016 01:24, Alexei Starovoitov wrote: > On Thu, Sep 15, 2016 at 01:02:22AM +0200, Mickaël Salaün wrote: >>> >>> I would suggest for the next RFC to do minimal 7 patches up to this point >>> with simple example that demonstrates the use case. >>> I

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-15 Thread Mickaël Salaün
On 15/09/2016 06:48, Alexei Starovoitov wrote: > On Wed, Sep 14, 2016 at 09:38:16PM -0700, Andy Lutomirski wrote: >> On Wed, Sep 14, 2016 at 9:31 PM, Alexei Starovoitov >> wrote: >>> On Wed, Sep 14, 2016 at 09:08:57PM -0700, Andy Lutomirski wrote: On Wed, Sep 14, 2016 at 9:00 PM, Alexei Star

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-15 Thread Mickaël Salaün
On 15/09/2016 03:25, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 3:11 PM, Mickaël Salaün wrote: >> >> On 14/09/2016 20:27, Andy Lutomirski wrote: >>> On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >>>> Add a new flag CGRP_NO_NEW_PRIVS for

Re: [RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 20:51, Alexei Starovoitov wrote: > On Wed, Sep 14, 2016 at 09:23:56AM +0200, Mickaël Salaün wrote: >> This new arraymap looks like a set and brings new properties: >> * strong typing of entries: the eBPF functions get the array type of >> elements instead of

Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 23:06, Alexei Starovoitov wrote: > On Wed, Sep 14, 2016 at 09:24:00AM +0200, Mickaël Salaün wrote: >> Add eBPF functions to compare file system access with a Landlock file >> system handle: >> * bpf_landlock_cmp_fs_prop_with_struct_file(prop, map, map_op, fil

Re: [RFC v3 21/22] bpf,landlock: Add optional skb pointer in the Landlock context

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 23:20, Alexei Starovoitov wrote: > On Wed, Sep 14, 2016 at 09:24:14AM +0200, Mickaël Salaün wrote: >> This is a proof of concept to expose optional values that could depend >> of the process access rights. >> >> There is two dedicated flags: LANDLO

Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 21:07, Jann Horn wrote: > On Wed, Sep 14, 2016 at 09:24:00AM +0200, Mickaël Salaün wrote: >> Add eBPF functions to compare file system access with a Landlock file >> system handle: >> * bpf_landlock_cmp_fs_prop_with_struct_file(prop, map, map_op, file) >>

Re: [RFC v3 11/22] seccomp,landlock: Handle Landlock hooks per process hierarchy

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 20:43, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >> A Landlock program will be triggered according to its subtype/origin >> bitfield. The LANDLOCK_FLAG_ORIGIN_SECCOMP value will trigger the >> Landlock program when a secco

Re: [RFC v3 19/22] landlock: Add interrupted origin

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 20:29, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >> This third origin of hook call should cover all possible trigger paths >> (e.g. page fault). Landlock eBPF programs can then take decisions >> accordingly. >> >&

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 20:27, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: >> Add a new flag CGRP_NO_NEW_PRIVS for each cgroup. This flag is initially >> set for all cgroup except the root. The flag is clear when a new process >> without the

Re: [RFC v3 17/22] cgroup: Add access check for cgroup_get_from_fd()

2016-09-14 Thread Mickaël Salaün
On 14/09/2016 09:24, Mickaël Salaün wrote: > Add security access check for cgroup backed FD. The "cgroup.procs" file > of the corresponding cgroup must be readable to identify the cgroup, and > writable to prove that the current process can manage this cgroup (e.g. > throug

[RFC v3 14/22] bpf/cgroup: Make cgroup_bpf_update() return an error code

2016-09-14 Thread Mickaël Salaün
This will be useful to support Landlock for the next commits. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Daniel Mack Cc: David S. Miller Cc: Tejun Heo --- include/linux/bpf-cgroup.h | 4 ++-- kernel/bpf/cgroup.c| 3 ++- kernel/bpf/syscall.c

[RFC v3 05/22] bpf,landlock: Add eBPF program subtype and is_valid_subtype() verifier

2016-09-14 Thread Mickaël Salaün
(optional) program subtype is valid. For now, only Landlock eBPF programs are using a program subtype but this could be used by other program types in the future. Cf. the next commit to see how the subtype is used by Landlock LSM. Signed-off-by: Mickaël Salaün Link: https://lkml.kernel.org/r

[RFC v3 13/22] bpf/cgroup: Replace struct bpf_prog with union bpf_object

2016-09-14 Thread Mickaël Salaün
This allows CONFIG_CGROUP_BPF to manage different type of pointers instead of only eBPF programs. This will be useful for the next commits to support Landlock with cgroups. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Daniel Mack Cc: David S. Miller Cc: Tejun

[RFC v3 11/22] seccomp,landlock: Handle Landlock hooks per process hierarchy

2016-09-14 Thread Mickaël Salaün
Landlock programs for each of their legitimate seccomp filter * properly clean up all seccomp results * cosmetic changes to ease the understanding * fix some ifdef Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry Cc: Andrew Morton --- include/linux/landlock.h

[RFC v3 10/22] seccomp: Split put_seccomp_filter() with put_seccomp()

2016-09-14 Thread Mickaël Salaün
The semantic is unchanged. This will be useful for the Landlock integration with seccomp (next commit). Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry --- include/linux/seccomp.h | 5 +++-- kernel/fork.c | 2 +- kernel/seccomp.c| 18

[RFC v3 01/22] landlock: Add Kconfig

2016-09-14 Thread Mickaël Salaün
Initial Landlock Kconfig needed to split the Landlock eBPF and seccomp parts to ease the review. Changes from v2: * add seccomp filter or cgroups (with eBPF programs attached support) dependencies Signed-off-by: Mickaël Salaün Cc: James Morris Cc: Kees Cook Cc: Serge E. Hallyn

[RFC v3 21/22] bpf,landlock: Add optional skb pointer in the Landlock context

2016-09-14 Thread Mickaël Salaün
. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: David S. Miller Cc: Kees Cook Cc: Sargun Dhillon --- include/linux/bpf.h | 2 ++ include/uapi/linux/bpf.h | 7 ++- kernel/bpf/verifier.c| 6 ++ security/landlock/lsm.c | 26

[RFC v3 00/22] Landlock LSM: Unprivileged sandboxing

2016-09-14 Thread Mickaël Salaün
ck LSM. [1] https://lkml.kernel.org/r/1472121165-29071-1-git-send-email-...@digikod.net [2] https://crypto.stanford.edu/cs155/papers/traps.pdf [3] https://lkml.kernel.org/r/1473696735-11269-1-git-send-email-dan...@zonque.org Regards, Mickaël Salaün (22): landlock: Add Kconfig bpf: Move u64_to

[RFC v3 07/22] landlock: Handle file comparisons

2016-09-14 Thread Mickaël Salaün
y/landlock/checker_fs.c b/security/landlock/checker_fs.c new file mode 100644 index ..39eb85dc7d18 --- /dev/null +++ b/security/landlock/checker_fs.c @@ -0,0 +1,179 @@ +/* + * Landlock LSM - File System Checkers + * + * Copyright (C) 2016 Mickaël Salaün + * + * This program is free so

[RFC v3 12/22] bpf: Cosmetic change for bpf_prog_attach()

2016-09-14 Thread Mickaël Salaün
Move code outside a switch/case to ease code factoring (cf. next commit). This apply on Daniel Mack's "Add eBPF hooks for cgroups": https://lkml.kernel.org/r/1473696735-11269-1-git-send-email-dan...@zonque.org Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Daniel Borkm

[RFC v3 15/22] bpf/cgroup: Move capability check

2016-09-14 Thread Mickaël Salaün
This will be useful to be able to add more BPF attach type with different capability checks. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Daniel Mack --- kernel/bpf/syscall.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a

[RFC v3 19/22] landlock: Add interrupted origin

2016-09-14 Thread Mickaël Salaün
This third origin of hook call should cover all possible trigger paths (e.g. page fault). Landlock eBPF programs can then take decisions accordingly. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Kees Cook --- include/uapi/linux/bpf.h | 3

[RFC v3 02/22] bpf: Move u64_to_ptr() to BPF headers and inline it

2016-09-14 Thread Mickaël Salaün
This helper will be useful for arraymap (next commit). Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: David S. Miller Cc: Daniel Borkmann --- include/linux/bpf.h | 6 ++ kernel/bpf/syscall.c | 6 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include

[RFC v3 06/22] landlock: Add LSM hooks

2016-09-14 Thread Mickaël Salaün
ed by Daniel Borkmann) * new BPF context Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: David S. Miller Cc: James Morris Cc: Kees Cook Cc: Serge E. Hallyn Cc: Will Drewry Link: https://lkml.kernel.org/r/20160827205559.ga43...@ast-mbp.theface

[RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-09-14 Thread Mickaël Salaün
(suggested by Andy Lutomirski) * remove useless checks Changes since v1: * arraymap of handles replace custom checker groups * simpler userland API Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: David S. Miller Cc: Kees Cook Link: https

[RFC v3 22/22] samples/landlock: Add sandbox example

2016-09-14 Thread Mickaël Salaün
$$PWD clean diff --git a/samples/landlock/sandbox.c b/samples/landlock/sandbox.c new file mode 100644 index ..9d6ac00cdd23 --- /dev/null +++ b/samples/landlock/sandbox.c @@ -0,0 +1,307 @@ +/* + * Landlock LSM - Sandbox example + * + * Copyright (C) 2016 Mickaël Salaün + * + * This pro

[RFC v3 16/22] bpf/cgroup,landlock: Handle Landlock hooks per cgroup

2016-09-14 Thread Mickaël Salaün
hooks attached to a cgroup in more complicated ways (e.g. continuous inheritance), but care should be taken to properly handle error cases (e.g. memory allocation errors). Changes since v2: * new design based on BPF_PROG_ATTACH (suggested by Alexei Starovoitov) Signed-off-by: Mickaël Salaün Cc

[RFC v3 17/22] cgroup: Add access check for cgroup_get_from_fd()

2016-09-14 Thread Mickaël Salaün
ck done by cgroup_procs_write_permission(). Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Daniel Mack Cc: David S. Miller Cc: Kees Cook Cc: Tejun Heo --- include/linux/cgroup.h | 2 +- kernel/bpf/arraymap.c | 2 +- kernel/bpf/syscall.c | 6 +++--- kerne

[RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Mickaël Salaün
process without no_new_privs to this cgroup will be denied. This allows to safely manage Landlock rules with cgroup delegation as with seccomp. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: Daniel Mack Cc: David S. Miller Cc: Kees Cook Cc

[RFC v3 20/22] landlock: Add update and debug access flags

2016-09-14 Thread Mickaël Salaün
* bpf_get_prandom_u32 * bpf_get_current_pid_tgid * bpf_get_current_uid_gid * bpf_get_current_comm Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: Andy Lutomirski Cc: Daniel Borkmann Cc: David S. Miller Cc: Kees Cook Cc: Sargun Dhillon --- include/uapi/linux/bpf.h | 4 +++- security/landlock

[RFC v3 04/22] bpf: Set register type according to is_valid_access()

2016-09-14 Thread Mickaël Salaün
unprivileged eBPF programs to use functions with (legitimate) pointer arguments. This bug was not a problem until now because the only unprivileged eBPF program allowed is of type BPF_PROG_TYPE_SOCKET_FILTER and all the types from its context are UNKNOWN_VALUE. Signed-off-by: Mickaël Salaün Fixes

[RFC v3 08/22] seccomp: Fix documentation for struct seccomp_filter

2016-09-14 Thread Mickaël Salaün
Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry --- kernel/seccomp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 0db7c8a2afe2..dccfc05cb3ec 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c

[RFC v3 09/22] seccomp: Move struct seccomp_filter in seccomp.h

2016-09-14 Thread Mickaël Salaün
Set struct seccomp_filter public because of the next use of the new field thread_prev added for Landlock LSM. Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry --- include/linux/seccomp.h | 27 ++- kernel/seccomp.c| 26

Re: [PATCH v2 0/3] Fix seccomp for UM

2016-09-06 Thread Mickaël Salaün
09/08/2016 02:35, James Morris wrote: > On Mon, 1 Aug 2016, Mickaël Salaün wrote: > >> Hi, >> >> This series fix the recent seccomp update for the User-mode Linux >> architecture >> (32-bit and 64-bit) since commit 26703c636c1f ("um/ptrace: run seccomp after

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-30 Thread Mickaël Salaün
On 30/08/2016 22:23, Andy Lutomirski wrote: > On Tue, Aug 30, 2016 at 1:20 PM, Mickaël Salaün wrote: >> >> On 30/08/2016 20:55, Andy Lutomirski wrote: >>> On Sun, Aug 28, 2016 at 2:42 AM, Mickaël Salaün wrote: >>>> >>>> >>>> On 28/08

Re: [RFC v2 06/10] landlock: Add LSM hooks

2016-08-30 Thread Mickaël Salaün
On 30/08/2016 22:18, Andy Lutomirski wrote: > On Tue, Aug 30, 2016 at 1:10 PM, Mickaël Salaün wrote: >> >> On 30/08/2016 20:56, Andy Lutomirski wrote: >>> On Aug 25, 2016 12:34 PM, "Mickaël Salaün" wrote: >>>> >>>> Add LSM

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-30 Thread Mickaël Salaün
On 30/08/2016 20:55, Andy Lutomirski wrote: > On Sun, Aug 28, 2016 at 2:42 AM, Mickaël Salaün wrote: >> >> >> On 28/08/2016 10:13, Andy Lutomirski wrote: >>> On Aug 27, 2016 11:14 PM, "Mickaël Salaün" wrote: >>>> >>>> >>

Re: [RFC v2 06/10] landlock: Add LSM hooks

2016-08-30 Thread Mickaël Salaün
On 30/08/2016 20:56, Andy Lutomirski wrote: > On Aug 25, 2016 12:34 PM, "Mickaël Salaün" wrote: >> >> Add LSM hooks which can be used by userland through Landlock (eBPF) >> programs. This programs are limited to a whitelist of functions (cf. >> next commit).

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-08-30 Thread Mickaël Salaün
On 30/08/2016 18:06, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >> Hi, >> >> This series is a proof of concept to fill some missing part of seccomp as the >> ability to check syscall argument pointers or creating more dynamic securi

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-28 Thread Mickaël Salaün
On 28/08/2016 10:13, Andy Lutomirski wrote: > On Aug 27, 2016 11:14 PM, "Mickaël Salaün" wrote: >> >> >> On 27/08/2016 22:43, Alexei Starovoitov wrote: >>> On Sat, Aug 27, 2016 at 09:35:14PM +0200, Mickaël Salaün wrote: >>>> On 27/08/2016 2

Re: [RFC v2 09/10] landlock: Handle cgroups (program types)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 22:56, Alexei Starovoitov wrote: > On Sat, Aug 27, 2016 at 09:55:01PM +0200, Mickaël Salaün wrote: >> >> On 27/08/2016 20:19, Alexei Starovoitov wrote: >>> On Sat, Aug 27, 2016 at 04:34:55PM +0200, Mickaël Salaün wrote: >>>> >>>&g

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 22:43, Alexei Starovoitov wrote: > On Sat, Aug 27, 2016 at 09:35:14PM +0200, Mickaël Salaün wrote: >> On 27/08/2016 20:06, Alexei Starovoitov wrote: >>> On Sat, Aug 27, 2016 at 04:06:38PM +0200, Mickaël Salaün wrote: >>>> As said above, Landlock will

Re: [RFC v2 09/10] landlock: Handle cgroups (program types)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 20:19, Alexei Starovoitov wrote: > On Sat, Aug 27, 2016 at 04:34:55PM +0200, Mickaël Salaün wrote: >> >> On 27/08/2016 01:05, Alexei Starovoitov wrote: >>> On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: >>> >>>>> As f

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 20:06, Alexei Starovoitov wrote: > On Sat, Aug 27, 2016 at 04:06:38PM +0200, Mickaël Salaün wrote: >> >> On 27/08/2016 01:05, Alexei Starovoitov wrote: >>> On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: >>>> >>>>> &

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing (cgroup delegation)

2016-08-27 Thread Mickaël Salaün
Cc Tejun and the cgroups ML. On 27/08/2016 17:10, Mickaël Salaün wrote: > On 27/08/2016 09:40, Andy Lutomirski wrote: >> On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >>> >>> # Sandbox example with conditional access control depending on cgroup >>> &g

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 09:40, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >> Hi, >> >> This series is a proof of concept to fill some missing part of seccomp as the >> ability to check syscall argument pointers or creating more dynamic securi

Re: [RFC v2 09/10] landlock: Handle cgroups (program types)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 01:05, Alexei Starovoitov wrote: > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: > >>> As far as safety and type checking that bpf programs has to do, >>> I like the approach of patch 06/10: >>> +LANDLOCK_HOOK2(file_open, FILE_OPE

Re: [RFC v2 09/10] landlock: Handle cgroups (netfilter match)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 01:05, Alexei Starovoitov wrote: > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: >> To sum up, there is four related patchsets: >> * "Landlock LSM: Unprivileged sandboxing" (this series) >> * "Add Checmate, BPF-driven minor LS

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-27 Thread Mickaël Salaün
On 27/08/2016 01:05, Alexei Starovoitov wrote: > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: >> >>> >>> - I don't think such 'for' loop can scale. The solution needs to work >>> with thousands of containers and thousands of

Re: [RFC v2 08/10] landlock: Handle file system comparisons

2016-08-27 Thread Mickaël Salaün
On 26/08/2016 16:57, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 7:10 AM, Mickaël Salaün wrote: >> >> On 25/08/2016 13:12, Andy Lutomirski wrote: >>> On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >>>> Add eBPF functions to compare fil

Re: [RFC v2 09/10] landlock: Handle cgroups

2016-08-26 Thread Mickaël Salaün
On 26/08/2016 04:14, Alexei Starovoitov wrote: > On Thu, Aug 25, 2016 at 12:32:44PM +0200, Mickaël Salaün wrote: >> Add an eBPF function bpf_landlock_cmp_cgroup_beneath(opt, map, map_op) >> to compare the current process cgroup with a cgroup handle, The handle >> can match

Re: [RFC v2 09/10] landlock: Handle cgroups

2016-08-25 Thread Mickaël Salaün
On 25/08/2016 13:09, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >> Add an eBPF function bpf_landlock_cmp_cgroup_beneath(opt, map, map_op) >> to compare the current process cgroup with a cgroup handle, The handle >> can match the curren

Re: [RFC v2 08/10] landlock: Handle file system comparisons

2016-08-25 Thread Mickaël Salaün
On 25/08/2016 13:12, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >> Add eBPF functions to compare file system access with a Landlock file >> system handle: >> * bpf_landlock_cmp_fs_prop_with_struct_file(prop, map, map_op, file) >>

Re: [RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-08-25 Thread Mickaël Salaün
On 25/08/2016 13:05, Andy Lutomirski wrote: > On Thu, Aug 25, 2016 at 3:32 AM, Mickaël Salaün wrote: >> Hi, >> >> This series is a proof of concept to fill some missing part of seccomp as the >> ability to check syscall argument pointers or creating more dynamic securi

[RFC v2 07/10] landlock: Add errno check

2016-08-25 Thread Mickaël Salaün
Add a max errno value. This is not strictly needed but should improve reliability. Signed-off-by: Mickaël Salaün Cc: Arnd Bergmann Cc: Serge E. Hallyn Cc: James Morris Cc: Kees Cook --- include/uapi/asm-generic/errno-base.h | 1 + security/landlock/lsm.c | 6 +++--- 2 files

[RFC v2 02/10] bpf: Move u64_to_ptr() to BPF headers and inline it

2016-08-25 Thread Mickaël Salaün
This helper will be useful for arraymap (next commit). Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: David S. Miller Cc: Daniel Borkmann --- include/linux/bpf.h | 6 ++ kernel/bpf/syscall.c | 6 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include

[RFC v2 05/10] seccomp: Handle Landlock

2016-08-25 Thread Mickaël Salaün
programs can be triggered by one or more seccomp filters. This way, each RET_LANDLOCK (with specific cookie) will trigger all the allowed Landlock programs once. Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry Cc: Andrew Morton --- include/linux/seccomp.h | 49

[RFC v2 04/10] seccomp: Split put_seccomp_filter() with put_seccomp()

2016-08-25 Thread Mickaël Salaün
The semantic is unchanged. This will be useful for the Landlock integration with seccomp (next commit). Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry --- include/linux/seccomp.h | 5 +++-- kernel/fork.c | 2 +- kernel/seccomp.c| 18

[RFC v2 01/10] landlock: Add Kconfig

2016-08-25 Thread Mickaël Salaün
Initial Landlock Kconfig needed to split the Landlock eBPF and seccomp parts to ease the review. Signed-off-by: Mickaël Salaün Cc: James Morris Cc: Kees Cook Cc: Serge E. Hallyn --- security/Kconfig | 1 + security/landlock/Kconfig | 16 2 files changed, 17

[RFC v2 03/10] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-08-25 Thread Mickaël Salaün
listed in enum bpf_map_array_type (e.g. BPF_MAP_ARRAY_TYPE_LANDLOCK_FS). For now, this new arraymap is only used by Landlock LSM (cf. next commits) but it could be useful for other needs. Signed-off-by: Mickaël Salaün Cc: Alexei Starovoitov Cc: David S. Miller Cc: Daniel Borkmann Cc: James

[RFC v2 06/10] landlock: Add LSM hooks

2016-08-25 Thread Mickaël Salaün
to an eBPF function according to their types (e.g. the bpf_landlock_cmp_fs_beneath_with_struct_file function can use a struct file pointer). For now, there is three hooks for file system access control: * file_open; * file_permission; * mmap_file. Signed-off-by: Mickaël Salaün Cc: Alexei

[RFC v2 08/10] landlock: Handle file system comparisons

2016-08-25 Thread Mickaël Salaün
. path or glob string). Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Alexei Starovoitov Cc: James Morris Cc: Serge E. Hallyn Cc: David S. Miller Cc: Daniel Borkmann --- include/linux/bpf.h| 4 +- include/uapi/linux/bpf.h | 52 +++- kernel/bpf/arraymap.c

[RFC v2 10/10] samples/landlock: Add sandbox example

2016-08-25 Thread Mickaël Salaün
p:/proc/self/fd/0' \ ./sandbox /bin/sh -i $ ls /home user1 $ echo $$ > /sys/fs/cgroup/sandboxed/cgroup.procs $ ls /home ls: cannot open directory '/home': Permission denied Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Alexei Starovoitov Cc: James Morris

[RFC v2 00/10] Landlock LSM: Unprivileged sandboxing

2016-08-25 Thread Mickaël Salaün
PS. I would really appreciate constructive comments on the usability, architecture, code and userland API of Landlock LSM. Regards, Mickaël Salaün (10): landlock: Add Kconfig bpf: Move u64_to_ptr() to BPF headers and inline it bpf,landlock: Add a new arraymap type to deal with (Landlock) hand

[RFC v2 09/10] landlock: Handle cgroups

2016-08-25 Thread Mickaël Salaün
manipulate cgroups thanks to cgroup delegation. Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Alexei Starovoitov Cc: James Morris Cc: Serge E. Hallyn Cc: David S. Miller Cc: Daniel Borkmann --- include/linux/bpf.h| 8 include/uapi/linux/bpf.h | 15 ++ kernel

Re: [RFC 0/4] RFC: Add Checmate, BPF-driven minor LSM

2016-08-15 Thread Mickaël Salaün
On 15/08/2016 05:09, Sargun Dhillon wrote: > On Mon, Aug 15, 2016 at 12:57:44AM +0200, Mickaël Salaün wrote: >> Our approaches have some common points (i.e. use eBPF in an LSM, stacked >> filters like seccomp) but I'm focused on a kind of unprivileged LSM (i.e. no >&g

Re: [RFC 0/4] RFC: Add Checmate, BPF-driven minor LSM

2016-08-14 Thread Mickaël Salaün
Hi, I've been working on an extension to seccomp-bpf since last year and published a first RFC about it [1]. I'm working on a second RFC/PoC which use eBPF instead of cBPF and is more close to a common LSM than the first RFC. I plan to publish this second RFC by the end of the month. Our appro

[PATCH v2 2/3] um/ptrace: Fix the syscall number update after a ptrace

2016-08-01 Thread Mickaël Salaün
ormally instead of by signal > (code: 1) > [ FAIL ] TRACE_syscall.kill_after_ptrace Fixes: 26703c636c1f ("um/ptrace: run seccomp after ptrace") Signed-off-by: Mickaël Salaün Acked-by: Kees Cook Cc: Jeff Dike Cc: Richard Weinberger Cc: James Morris Cc: user-mode-linux-de...@lists.sourceforge.net

[PATCH v2 1/3] um/ptrace: Fix the syscall_trace_leave call

2016-08-01 Thread Mickaël Salaün
nic - not syncing: BUG! Fixes: 26703c636c1f ("um/ptrace: run seccomp after ptrace") Signed-off-by: Mickaël Salaün Acked-by: Kees Cook Cc: Jeff Dike Cc: Richard Weinberger Cc: James Morris Cc: user-mode-linux-de...@lists.sourceforge.net --- arch/um/kernel/skas/syscall.c | 5 +++--

[PATCH v2 0/3] Fix seccomp for UM (next)

2016-08-01 Thread Mickaël Salaün
typo [2/3] * add Kees Cook's Acked-by * rebased on commit 7616ac70d1bb ("apparmor: fix SECURITY_APPARMOR_HASH_DEFAULT parameter handling") Available in the git repository at: https://github.com/l0kod/linux heads/um-fix-seccomp-ptrace-v2 Regards, Mickaël Salaün

[PATCH v2 3/3] seccomp: Remove 2-phase API documentation

2016-08-01 Thread Mickaël Salaün
Fixes: 8112c4f140fa ("seccomp: remove 2-phase API") Signed-off-by: Mickaël Salaün Acked-by: Kees Cook Cc: Andy Lutomirski Cc: James Morris --- arch/Kconfig | 11 --- 1 file changed, 11 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index d794384a0404..96e434638

Re: [PATCH v2 2/2] namespaces: add transparent user namespaces

2016-07-12 Thread Mickaël Salaün
Hi, I have been looking for this kind of feature for StemJail [1]. One of the main idea is to being able to create mount points inside a jail as an unprivileged user but to keep as much as possible the same environment from outside the jail. For now, I can only create a mapping for the current

[PATCH v1 3/3] seccomp: Remove 2-phase API documentation

2016-07-11 Thread Mickaël Salaün
Fixes: 8112c4f140fa ("seccomp: remove 2-phase API") Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Andy Lutomirski Cc: James Morris --- arch/Kconfig | 11 --- 1 file changed, 11 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index d794384a0404..96e434638767 100644

[PATCH v1 2/3] um/ptrace: Fix the syscall number update after a ptrace

2016-07-11 Thread Mickaël Salaün
ormally instead of by signal > (code: 1) > [ FAIL ] TRACE_syscall.kill_after_ptrace Fixes: 26703c636c1f ("um/ptrace: run seccomp after ptrace") Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Jeff Dike Cc: Richard Weinberger Cc: James Morris Cc: user-mode-linux-de...@lists.sourceforge.net --- arch

[PATCH v1 0/3] Fix seccomp for UM (next)

2016-07-11 Thread Mickaël Salaün
Hi, This series fix the recent seccomp update for the User-mode Linux architecture (32-bit and 64-bit) since commit 26703c636c1f3272b39bd0f6d04d2e970984f1b6 (close the hole where ptrace can change a syscall out from under seccomp). Regards, Mickaël Salaün (3): um/ptrace: Fix the

[PATCH v1 1/3] um/ptrace: Fix the syscall_trace_leave call

2016-07-11 Thread Mickaël Salaün
nic - not syncing: BUG! Fixes: 26703c636c1f ("um/ptrace: run seccomp after ptrace") Signed-off-by: Mickaël Salaün Cc: Kees Cook Cc: Jeff Dike Cc: Richard Weinberger Cc: James Morris Cc: user-mode-linux-de...@lists.sourceforge.net --- arch/um/kernel/skas/syscall.c | 5 +++-- 1 file ch

[PATCH v1] module: Fully remove the kernel_module_from_file hook

2016-07-09 Thread Mickaël Salaün
Fixes: a1db74209483 ("module: replace copy_module_from_fd with kernel version") Signed-off-by: Mickaël Salaün Cc: Mimi Zohar Cc: Kees Cook Cc: Luis R. Rodriguez Cc: Rusty Russell Cc: Linus Torvalds Cc: Greg Kroah-Hartman --- include/linux/lsm_hooks.h | 1 - include/linux/secur

Re: fs: NULL deref in atime_needs_update

2016-02-20 Thread Mickaël Salaün
On 20/02/2016 18:10, Al Viro wrote: > On Sat, Feb 20, 2016 at 02:25:40PM +0100, Mickaël Salaün wrote: > >> I think the bug may be somewhere in the nd->depth handling (when its value >> is 0) in fs/namei.c:get_link(): struct saved *last = nd->stack + nd->depth - >

<    5   6   7   8   9   10   11   >