Re: [PATCH v4 00/11] Add seccomp notifier ioctl that enables adding fds

2020-06-18 Thread Sargun Dhillon
e kcmp() less required > selftests/seccomp: Rename user_trap_syscall() to user_notif_syscall() > seccomp: Switch addfd to Extensible Argument ioctl > seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID > This looks much cleaner than the original patchset. Thanks

Re: [PATCH v5 3/7] fs: Add fd_install_received() wrapper for __fd_install_received()

2020-06-17 Thread Sargun Dhillon
l_received_user(scm->fp->fp[i], cmsg_data + i, > o_flags); > - if (err) > + if (err < 0) > break; > } > > diff --git a/net/core/scm.c b/net/core/scm.c > index df190f1fdd28..b9a0442ebd26 100644 > --- a/net/core/scm.c > +++ b/net/core/scm.c > @@ -307,7 +307,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie > *scm) > > for (i = 0; i < fdmax; i++) { > err = fd_install_received_user(scm->fp->fp[i], cmsg_data + i, > o_flags); > - if (err) > + if (err < 0) > break; > } > > -- > 2.25.1 > Reviewed-by: Sargun Dhillon

Re: [PATCH v4 02/11] fs: Move __scm_install_fd() to __fd_install_received()

2020-06-15 Thread Sargun Dhillon
On Mon, Jun 15, 2020 at 08:25:15PM -0700, Kees Cook wrote: > In preparation for users of the "install a received file" logic outside > of net/ (pidfd and seccomp), relocate and rename __scm_install_fd() from > net/core/scm.c to __fd_install_received() in fs/file.c, and provide a > wrapper named fd_

Re: [PATCH 2/2] pidfd: Replace open-coded partial __scm_install_fd()

2020-06-10 Thread Sargun Dhillon
On Tue, Jun 09, 2020 at 09:52:14PM -0700, Kees Cook wrote: > The sock counting (sock_update_netprioidx() and sock_update_classid()) > was missing from this implementation of fd installation, compared to > SCM_RIGHTS. Use the new scm helper to get the work done, after adjusting > it to return the in

[PATCH] net/sunrpc: Make rpc_auth_create_args a const

2018-07-05 Thread Sargun Dhillon
This turns rpc_auth_create_args into a const as it gets passed through the auth stack. Signed-off-by: Sargun Dhillon --- include/linux/sunrpc/auth.h| 5 +++-- net/sunrpc/auth.c | 2 +- net/sunrpc/auth_gss/auth_gss.c | 9 + net/sunrpc/auth_null.c | 2 +- net

How should NFS, SUNRPC interact with Network and User Namespaces?

2018-06-29 Thread Sargun Dhillon
Today, sunrpc lives in net/sunrpc. As far as I can tell, the primary production consumer of it is NFS. The RPC clients have the concept of being tied back to a network namespace. On the other hand, NFS has its own superblock with its own user namespace. When sunrpc convert kuids to UIDs to send ov

Re: Userspace helper design

2018-03-06 Thread Sargun Dhillon
On Tue, Mar 6, 2018 at 12:31 PM, Daniel Borkmann wrote: > On 03/06/2018 05:02 PM, Sargun Dhillon wrote: >> On Tue, Mar 6, 2018 at 3:26 AM, Daniel Borkmann wrote: >>> On 03/06/2018 02:53 AM, Alexei Starovoitov wrote: >>>> On Mon, Mar 05, 2018 at 05:46:51PM -0800,

Re: [net-next v3 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-03-05 Thread Sargun Dhillon
On Mon, Mar 5, 2018 at 8:10 AM, Tycho Andersen wrote: > Hi Andy, > > On Thu, Mar 01, 2018 at 10:05:47PM +, Andy Lutomirski wrote: >> But Tycho: would hooking user notifiers in right here work for you? >> As I see it, this would be the best justification for seccomp eBPF. > > Sorry for the dela

Re: [net-next v3 0/2] eBPF seccomp filters

2018-03-01 Thread Sargun Dhillon
On Thu, Mar 1, 2018 at 1:59 PM, Andy Lutomirski wrote: > On Thu, Mar 1, 2018 at 9:51 PM, Sargun Dhillon wrote: >> On Thu, Mar 1, 2018 at 9:44 AM, Andy Lutomirski wrote: >>> On Wed, Feb 28, 2018 at 7:56 PM, Daniel Borkmann >>> wrote: >>>> On 02/28/2018 12

Re: [net-next v3 0/2] eBPF seccomp filters

2018-03-01 Thread Sargun Dhillon
On Thu, Mar 1, 2018 at 9:44 AM, Andy Lutomirski wrote: > On Wed, Feb 28, 2018 at 7:56 PM, Daniel Borkmann wrote: >> On 02/28/2018 12:55 AM, chris hyser wrote: On 02/27/2018 04:58 PM, Daniel Borkmann wrote: >> On 02/27/2018 05:59 PM, chris hyser wrote: >> On 02/27/2018 11:00 AM, Kee

Re: [net-next v3 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-26 Thread Sargun Dhillon
On Mon, Feb 26, 2018 at 7:57 PM, Tycho Andersen wrote: > On Mon, Feb 26, 2018 at 07:49:48PM -0800, Sargun Dhillon wrote: >> On Mon, Feb 26, 2018 at 4:54 PM, Tycho Andersen wrote: >> > On Mon, Feb 26, 2018 at 07:27:05AM +0000, Sargun Dhillon wrote: >> >> +

Re: [net-next v3 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-26 Thread Sargun Dhillon
On Mon, Feb 26, 2018 at 4:54 PM, Tycho Andersen wrote: > On Mon, Feb 26, 2018 at 07:27:05AM +0000, Sargun Dhillon wrote: >> +config SECCOMP_FILTER_EXTENDED >> + bool "Extended BPF seccomp filters" >> + depends on SECCOMP_FILTER && BPF_SYSCALL

Re: [net-next v3 0/2] eBPF seccomp filters

2018-02-26 Thread Sargun Dhillon
On Mon, Feb 26, 2018 at 5:01 PM, Tycho Andersen wrote: > On Mon, Feb 26, 2018 at 03:20:15PM -0800, Kees Cook wrote: >> On Mon, Feb 26, 2018 at 3:04 PM, Alexei Starovoitov >> wrote: >> > On Mon, Feb 26, 2018 at 07:26:54AM +, Sargun Dhillon wrote: >> >> This

Re: [net-next v3 0/2] eBPF seccomp filters

2018-02-26 Thread Sargun Dhillon
On Mon, Feb 26, 2018 at 3:04 PM, Alexei Starovoitov wrote: > On Mon, Feb 26, 2018 at 07:26:54AM +0000, Sargun Dhillon wrote: >> This patchset enables seccomp filters to be written in eBPF. Although, this >> patchset doesn't introduce much of the functionality enabled by

[net-next v3 2/2] bpf: Add eBPF seccomp sample programs

2018-02-25 Thread Sargun Dhillon
This adds a sample program that uses seccomp-eBPF, called seccomp1. It shows the simple ability to code seccomp filters in C. Signed-off-by: Sargun Dhillon --- samples/bpf/Makefile| 5 + samples/bpf/bpf_load.c | 9 ++-- samples/bpf/test_seccomp_kern.c | 41

[net-next v3 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-25 Thread Sargun Dhillon
cBPF one. Verification occurs at program load time, so the user should only receive errors related to attachment. Signed-off-by: Sargun Dhillon --- arch/Kconfig | 8 +++ include/linux/bpf_types.h| 3 + include/linux/seccomp.h | 3 +- include/uapi/linux/bpf.h | 2

[net-next v3 0/2] eBPF seccomp filters

2018-02-25 Thread Sargun Dhillon
er, not a separate command * Remove printk helper * Remove ptrace patch / restore filter / sample * Add some safe helpers Sargun Dhillon (2): bpf, seccomp: Add eBPF filter capabilities bpf: Add eBPF seccomp sample programs arch/Kconfig| 8 ++ include/linux/bpf_t

Re: [net-next v2 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-20 Thread Sargun Dhillon
On Mon, Feb 19, 2018 at 4:00 PM, Daniel Borkmann wrote: > On 02/19/2018 05:22 PM, Sargun Dhillon wrote: >> This introduces the BPF_PROG_TYPE_SECCOMP bpf program type. It is meant >> to be used for seccomp filters as an alternative to cBPF filters. The >> program type h

Re: [net-next v2 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-20 Thread Sargun Dhillon
On Mon, Feb 19, 2018 at 4:00 PM, Daniel Borkmann wrote: > On 02/19/2018 05:22 PM, Sargun Dhillon wrote: >> This introduces the BPF_PROG_TYPE_SECCOMP bpf program type. It is meant >> to be used for seccomp filters as an alternative to cBPF filters. The >> program type h

[net-next v2 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-19 Thread Sargun Dhillon
cBPF one. Verification occurs at program load time, so the user should only receive errors related to attachment. Signed-off-by: Sargun Dhillon --- arch/Kconfig | 8 +++ include/linux/bpf_types.h| 3 + include/linux/seccomp.h | 3 +- include/uapi/linux/bpf.h | 2

Re: [net-next v2 2/2] bpf: Add eBPF seccomp sample programs

2018-02-18 Thread Sargun Dhillon
On Sat, Feb 17, 2018 at 9:58 AM, Randy Dunlap wrote: > On 02/16/2018 11:36 PM, Sargun Dhillon wrote: >> + close(111); >> + assert(errno == EBADF); >> + close(999); >> + assert(errno = EPERM); > > should that be == ? > Woops. Embarassin

[net-next v2 1/2] bpf, seccomp: Add eBPF filter capabilities

2018-02-16 Thread Sargun Dhillon
cBPF one. Verification occurs at program load time, so the user should only receive errors related to attachment. Signed-off-by: Sargun Dhillon --- arch/Kconfig | 8 +++ include/linux/bpf_types.h| 3 + include/linux/seccomp.h | 3 +- include/uapi/linux/bpf.h | 2

[net-next v2 0/2] eBPF Seccomp filters

2018-02-16 Thread Sargun Dhillon
emove ptrace patch / restore filter / sample * Add some safe helpers Sargun Dhillon (2): bpf, seccomp: Add eBPF filter capabilities bpf: Add eBPF seccomp sample programs arch/Kconfig | 8 +++ include/linux/bpf_types.h| 3 + include/linux/seccomp.h | 3 +- includ

[net-next v2 2/2] bpf: Add eBPF seccomp sample programs

2018-02-16 Thread Sargun Dhillon
This adds a sample program that uses seccomp-eBPF, called seccomp1. It shows the simple ability to code seccomp filters in C. Signed-off-by: Sargun Dhillon --- samples/bpf/Makefile| 5 + samples/bpf/bpf_load.c | 9 +++-- samples/bpf/seccomp1_kern.c | 43

Re: [PATCH net-next 1/3] bpf, seccomp: Add eBPF filter capabilities

2018-02-16 Thread Sargun Dhillon
On Tue, Feb 13, 2018 at 12:34 PM, Kees Cook wrote: > On Tue, Feb 13, 2018 at 7:42 AM, Sargun Dhillon wrote: >> From: Sargun Dhillon >> >> This introduces the BPF_PROG_TYPE_SECCOMP bpf program type. It is meant >> to be used for seccomp filters as an alternative to c

Re: [PATCH net-next 0/3] eBPF Seccomp filters

2018-02-16 Thread Sargun Dhillon
On Wed, Feb 14, 2018 at 8:30 PM, Alexei Starovoitov wrote: > On Wed, Feb 14, 2018 at 10:32:22AM -0700, Tycho Andersen wrote: >> > > >> > > What's the reason for adding eBPF support? seccomp shouldn't need it, >> > > and it only makes the code more complex. I'd rather stick with cBPF >> > > until w

Re: [PATCH net-next 0/3] eBPF Seccomp filters

2018-02-13 Thread Sargun Dhillon
On Tue, Feb 13, 2018 at 9:02 AM, Jessie Frazelle wrote: > On Tue, Feb 13, 2018 at 11:29 AM, Sargun Dhillon wrote: >> On Tue, Feb 13, 2018 at 7:47 AM, Kees Cook wrote: >>> On Tue, Feb 13, 2018 at 7:42 AM, Sargun Dhillon wrote: >>>> This patchset enables seccomp

Re: [PATCH net-next 0/3] eBPF Seccomp filters

2018-02-13 Thread Sargun Dhillon
On Tue, Feb 13, 2018 at 7:47 AM, Kees Cook wrote: > On Tue, Feb 13, 2018 at 7:42 AM, Sargun Dhillon wrote: >> This patchset enables seccomp filters to be written in eBPF. Although, >> this patchset doesn't introduce much of the functionality enabled by >> eBPF, it l

[PATCH net-next 3/3] bpf: Add eBPF seccomp sample programs

2018-02-13 Thread Sargun Dhillon
From: Sargun Dhillon This adds two sample programs: seccomp1: A simple eBPF seccomp filter seccomp2: A program which installs an eBPF filter and then retrieves it via ptrace to show checkpoint / restore capability. Signed-off-by: Sargun Dhillon --- samples/bpf/Makefile

[PATCH net-next 0/3] eBPF Seccomp filters

2018-02-13 Thread Sargun Dhillon
ss, if we come to an agreement, this can be in a follow-up patchset. Sargun Dhillon (3): bpf, seccomp: Add eBPF filter capabilities seccomp, ptrace: Add a mechanism to retrieve attached eBPF seccomp filters bpf: Add eBPF seccomp sample programs arch/Kconfig |

[PATCH net-next 1/3] bpf, seccomp: Add eBPF filter capabilities

2018-02-13 Thread Sargun Dhillon
From: Sargun Dhillon This introduces the BPF_PROG_TYPE_SECCOMP bpf program type. It is meant to be used for seccomp filters as an alternative to cBPF filters. The program type has relatively limited capabilities in terms of helpers, but that can be extended later on. It also introduces a new

[PATCH net-next 2/3] seccomp, ptrace: Add a mechanism to retrieve attached eBPF seccomp filters

2018-02-13 Thread Sargun Dhillon
From: Sargun Dhillon This extends the the ptrace API to allow fetching eBPF seccomp filters attached to programs. This is to enable checkpoint / restore cases. The user will have to use the traditional PTRACE_SECCOMP_GET_FILTER API call, and if they get an invalid medium type error they can

Re: bpf bounded loops. Was: [flamebait] xdp

2016-12-03 Thread Sargun Dhillon
On Fri, Dec 2, 2016 at 4:20 PM, Alexei Starovoitov wrote: > On Fri, Dec 02, 2016 at 11:42:15AM -0800, John Fastabend wrote: >> >> As far as pattern search for DNS packets... >> >> it was requested by Cloudflare guys back in March: >> >> https://github.com/iovisor/bcc/issues/471 >> >> and it is use

[PATCH net-next 1/2] samples, bpf: Refactor test_current_task_under_cgroup - separate out helpers

2016-12-02 Thread Sargun Dhillon
This patch modifies test_current_task_under_cgroup_user. The test has several helpers around creating a temporary environment for cgroup testing, and moving the current task around cgroups. This set of helpers can then be used in other tests. Signed-off-by: Sargun Dhillon --- samples/bpf

[PATCH net-next 2/2] samples, bpf: Add automated test for cgroup filter attachments

2016-12-02 Thread Sargun Dhillon
ls is enabled, this test will fail. Signed-off-by: Sargun Dhillon --- samples/bpf/Makefile | 2 + samples/bpf/test_cgrp2_attach2.c | 132 +++ 2 files changed, 134 insertions(+) create mode 100644 samples/bpf/test_cgrp2_attach2.c diff --git a/sample

[PATCH net-next 0/2] samples, bpf: Refactor; Add automated tests for cgroups

2016-12-02 Thread Sargun Dhillon
With this code, we're able to pretty easily add an automated test for future cgroupsv2 functionality. Sargun Dhillon (2): samples, bpf: Refactor test_current_task_under_cgroup - separate out helpers samples, bpf: Add automated test for cgroup filter attachments sample

Re: [net-next 1/1] samples: bpf: Refactor test_cgrp2_attach -- use getopt, and add mode

2016-11-28 Thread Sargun Dhillon
On Mon, Nov 28, 2016 at 7:50 PM, Alexei Starovoitov wrote: > On Mon, Nov 28, 2016 at 02:52:42PM -0800, Sargun Dhillon wrote: >> This patch modifies test_cgrp2_attach to use getopt so we can use standard >> command line parsing. >> >> It also adds an option to run the

[net-next 1/1] samples: bpf: Refactor test_cgrp2_attach -- use getopt, and add mode

2016-11-28 Thread Sargun Dhillon
then attach. It relies on the 'hotswap' behaviour of CGroup BPF programs to be able to change in-place. If detach-then-attach behaviour needs to be tested, the example can be run in detach only mode prior to attachment. Signed-off-by: Sargun Dhillon --- samples/bpf/test_cgrp2_att

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

2016-11-14 Thread Sargun Dhillon
ivileges. Moreover, a >> Landlock eBPF program could come from outside a process (e.g. passed through >> a >> UNIX socket). It is then useful to differentiate the creation/load of >> Landlock >> eBPF programs via bpf(2), from rule enforcing via seccomp(2). >> &g

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

2016-09-19 Thread Sargun Dhillon
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, 2016 at 9:31 PM, Alexei Starovoitov > >> wrote: > >>> On Wed, Sep 14, 2016 at 09:08:57PM -07

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

2016-09-19 Thread Sargun Dhillon
I'm fine giving up the Checmate name. Landlock seems easy enough to Google. I haven't gotten a chance to look through the entire patchset yet, but it does seem like they are somewhat similar. On Mon, Sep 19, 2016 at 5:12 PM, Alexei Starovoitov wrote: > On Thu, Sep 15, 2016 at 11:25:10PM +0200, Mi

Re: [PATCH v5 0/6] Add eBPF hooks for cgroups

2016-09-19 Thread Sargun Dhillon
On Mon, Sep 19, 2016 at 06:34:28PM +0200, Daniel Mack wrote: > Hi, > > On 09/16/2016 09:57 PM, Sargun Dhillon wrote: > > On Wed, Sep 14, 2016 at 01:13:16PM +0200, Daniel Mack wrote: > > >> I have no idea what makes you think this is limited to systemd. As I > >

Re: [PATCH v5 0/6] Add eBPF hooks for cgroups

2016-09-18 Thread Sargun Dhillon
On Fri, Sep 16, 2016 at 12:57:29PM -0700, Sargun Dhillon wrote: > On Wed, Sep 14, 2016 at 01:13:16PM +0200, Daniel Mack wrote: > > Hi Pablo, > > > > On 09/13/2016 07:24 PM, Pablo Neira Ayuso wrote: > > > On Tue, Sep 13, 2016 at 03:31:20PM +0200, Daniel Mack wrote:

Re: [PATCH v5 0/6] Add eBPF hooks for cgroups

2016-09-16 Thread Sargun Dhillon
On Wed, Sep 14, 2016 at 01:13:16PM +0200, Daniel Mack wrote: > Hi Pablo, > > On 09/13/2016 07:24 PM, Pablo Neira Ayuso wrote: > > On Tue, Sep 13, 2016 at 03:31:20PM +0200, Daniel Mack wrote: > >> On 09/13/2016 01:56 PM, Pablo Neira Ayuso wrote: > >>> On Mon, Sep 12, 2016 at 06:12:09PM +0200, Danie

Re: [PATCH v3 2/6] cgroup: add support for eBPF programs

2016-09-05 Thread Sargun Dhillon
On Mon, Sep 05, 2016 at 04:49:26PM +0200, Daniel Mack wrote: > Hi, > > On 08/30/2016 01:04 AM, Sargun Dhillon wrote: > > On Fri, Aug 26, 2016 at 09:58:48PM +0200, Daniel Mack wrote: > >> This patch adds two sets of eBPF program pointers to struct cgroup. > >> One

Re: [net-next RFC v2 4/9] bpf, security: Add Checmate security LSM and BPF program type

2016-08-29 Thread Sargun Dhillon
On Mon, Aug 29, 2016 at 02:49:17PM -0700, Alexei Starovoitov wrote: > On 8/29/16 12:24 PM, Tejun Heo wrote: > >Hello, Sargun. > > > >On Mon, Aug 29, 2016 at 11:49:07AM -0700, Sargun Dhillon wrote: > >>It would be a separate hook per LSM hook. Why wouldn't we wa

Re: [PATCH v3 2/6] cgroup: add support for eBPF programs

2016-08-29 Thread Sargun Dhillon
On Fri, Aug 26, 2016 at 09:58:48PM +0200, Daniel Mack wrote: > This patch adds two sets of eBPF program pointers to struct cgroup. > One for such that are directly pinned to a cgroup, and one for such > that are effective for it. > > To illustrate the logic behind that, assume the following exampl

Re: [PATCH v3 5/6] net: core: run cgroup eBPF egress programs

2016-08-29 Thread Sargun Dhillon
On Tue, Aug 30, 2016 at 12:03:23AM +0200, Daniel Borkmann wrote: > On 08/26/2016 09:58 PM, Daniel Mack wrote: > >If the cgroup associated with the receiving socket has an eBPF > >programs installed, run them from __dev_queue_xmit(). > > > >eBPF programs used in this context are expected to either r

Re: [net-next RFC v2 4/9] bpf, security: Add Checmate security LSM and BPF program type

2016-08-29 Thread Sargun Dhillon
On Mon, Aug 29, 2016 at 01:01:18PM -0400, Tejun Heo wrote: > Hello, > > On Mon, Aug 29, 2016 at 04:47:07AM -0700, Sargun Dhillon wrote: > > This patch adds a minor LSM, Checmate. Checmate is a flexible programmable, > > extensible minor LSM that's coupled with cgroups

[net-next RFC v2 7/9] samples/bpf: Split out helper code from test_current_task_under_cgroup_user

2016-08-29 Thread Sargun Dhillon
easier. This patch is used in follow on samples. Signed-off-by: Sargun Dhillon --- samples/bpf/Makefile | 2 +- samples/bpf/cgroup_helpers.c | 103 ++ samples/bpf/cgroup_helpers.h | 15 samples/bpf

[net-next RFC v2 8/9] samples/bpf: Add limit_connections, remap_bind checmate examples / tests

2016-08-29 Thread Sargun Dhillon
for not refcnting 2-tuples using atomic counters is the lack of a safe free mechanism. In order to run this program, you may need to bump your ulimit -l. 2) remap_bind This program rewrites binds from 6789 to 12345. It is meant to mimic the usage of DNAT. Signed-off-by: Sargun Dhillon

[net-next RFC v2 9/9] doc: Add LSM / BPF Checmate docs

2016-08-29 Thread Sargun Dhillon
This adds documentation on how to operate, and develop against the Checmate LSM and Cgroup controller. Signed-off-by: Sargun Dhillon --- Documentation/security/Checmate.txt | 54 + 1 file changed, 54 insertions(+) create mode 100644 Documentation/security

[net-next RFC v2 6/9] bpf: Share current_task_under_cgroup helper and expose to Checmate programs

2016-08-29 Thread Sargun Dhillon
This patch exposes the current_task_under_cgroup helper to Checmate programs. It can be used to implement exemptions for certain policies when using Checmate programs by wrapping a pre-compiled policy in a tail call along with this helper. Signed-off-by: Sargun Dhillon --- include/linux/bpf.h

[net-next RFC v2 5/9] bpf: Add bpf_probe_write_checmate helper

2016-08-29 Thread Sargun Dhillon
D API for introspecting sockets (getpeername) still works. Signed-off-by: Sargun Dhillon --- include/uapi/linux/bpf.h | 11 security/checmate/checmate_bpf.c | 55 2 files changed, 66 insertions(+) diff --git a/include/uapi/linux/bpf.h b/in

[net-next RFC v2 4/9] bpf, security: Add Checmate security LSM and BPF program type

2016-08-29 Thread Sargun Dhillon
chestrator complex policies can be installed on the cgroup hierarchy. These cgroup programs are tied to the kernel ABI version. If one tries to load a BPF program compiled against a different kernel version, an error will be thrown. Signed-off-by: Sargun Dhillon --- include/linux/cgroup_subsys.

[net-next RFC v2 1/9] net: Make cgroup sk data present when calling security_sk_(alloc/free)

2016-08-29 Thread Sargun Dhillon
This patch changes the order of allocations / calls to allocate the sock_cgroup_data before calling security_sk_alloc. In addition, this patch also reorders the deallocation when calling security_sk_free so that LSMs can examine the cgroup that a particular sk belongs to. Signed-off-by: Sarguun Dh

[net-next RFC v2 2/9] cgroups: move helper cgroup_parent to cgroup.h

2016-08-29 Thread Sargun Dhillon
This patch moves cgroup_parent into cgroup.h as a static inline helper function so that others can use it. Although this pattern is easy to implement, having it in one place simplifies the creation of new cgroup controllers. Signed-off-by: Sargun Dhillon --- include/linux/cgroup.h | 16

[net-next RFC v2 3/9] bpf: move tracing helpers (probe_read, get_current_task) to shared helpers

2016-08-29 Thread Sargun Dhillon
This patch moves bpf_probe_read and bpf_get_current_task to be the shared cgroup infrastructure. These are useful outside of the context of just tracing, but also inspection of a process memory during security policy enforcement. Signed-off-by: Sargun Dhillon --- include/linux/bpf.h | 2

[net-next RFC v2 0/9] Add Checmate: BPF-driven minor LSM

2016-08-29 Thread Sargun Dhillon
at. 2) API The API right now tightly ties programs to the kernel version. I don't see a good way around this unless we decide that a subset of the lsm hooks API is immutable. That's a question for the LSM maintainers. Thanks to Alexei, Daniel B, and Daniel Mack, and Tejun for input.

Re: [RFC PATCH 0/5] Add eBPF hooks for cgroups

2016-08-23 Thread Sargun Dhillon
On Tue, Aug 23, 2016 at 10:27:28AM +0200, Daniel Mack wrote: > On 08/22/2016 07:20 PM, Sargun Dhillon wrote: > > On Mon, Aug 22, 2016 at 06:22:20PM +0200, Daniel Mack wrote: > >> On 08/22/2016 06:06 PM, Pablo Neira Ayuso wrote: > > >>> This patchset also needs an

Re: [RFC PATCH 0/5] Add eBPF hooks for cgroups

2016-08-22 Thread Sargun Dhillon
On Mon, Aug 22, 2016 at 06:22:20PM +0200, Daniel Mack wrote: > On 08/22/2016 06:06 PM, Pablo Neira Ayuso wrote: > > On Fri, Aug 19, 2016 at 07:07:39PM +0200, Thomas Graf wrote: > > >> You brought up multiple tables which reflect the cumulative approach. > >> This sometimes works but has its issues

Re: [RFC PATCH 4/5] net: filter: run cgroup eBPF programs

2016-08-21 Thread Sargun Dhillon
On Wed, Aug 17, 2016 at 04:00:47PM +0200, Daniel Mack wrote: > If CONFIG_CGROUP_BPF is enabled, and the cgroup associated with the > receiving socket has an eBPF programs installed, run them from > sk_filter_trim_cap(). > > eBPF programs used in this context are expected to either return 1 to > le

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

2016-08-15 Thread Sargun Dhillon
On Mon, Aug 15, 2016 at 12:59:13PM +0200, Mickaël Salaün wrote: > > 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 > >>

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

2016-08-14 Thread Sargun Dhillon
getpeername. I'm curious about your filesystem access limiter. Do you have a way to make it so that a given container can only write, say, 100mb of data to disk? > Mickaël > > > [1] http://www.openwall.com/lists/kernel-hardening/2016/03/24/2 > > > > On 09/0

[PATCH net-next v5 0/3] Add test_current_task_under_cgroup bpf helper and test

2016-08-12 Thread Sargun Dhillon
defs out of *.c files, add an "integration" test v3->v4: De-genercize arraymap fetching function; rename helper from in_cgroup to under_cgroup (makes much more sense) Split adding cgroups task_under_cgroup_hierarchy function v4->v5: Fix formatti

[PATCH net-next v5 3/3] samples/bpf: Add test_current_task_under_cgroup test

2016-08-12 Thread Sargun Dhillon
p prior to execution in userspace. This means that the program must be run in the same cgroups namespace as the programs that are being traced. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo --- samples/bpf/Makefile | 5 + s

[PATCH net-next v5 2/3] bpf: Add bpf_current_task_under_cgroup helper

2016-08-12 Thread Sargun Dhillon
it'll return an error. The helper is primarily to be used in debugging activities for containers, where you may have multiple programs running in a given top-level "container". Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo Acked-by: Tejun H

[PATCH net-next v5 1/3] cgroup: Add task_under_cgroup_hierarchy cgroup inline function to headers

2016-08-12 Thread Sargun Dhillon
This commit adds an inline function to cgroup.h to check whether a given task is under a given cgroup hierarchy. This is to avoid having to put ifdefs in .c files to gate access to cgroups. When cgroups are disabled this always returns true. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov

Re: [PATCH net-next v4 2/3] bpf: Add bpf_current_task_under_cgroup helper

2016-08-12 Thread Sargun Dhillon
On Fri, Aug 12, 2016 at 09:16:07AM +0200, Daniel Borkmann wrote: > On 08/12/2016 06:50 AM, Sargun Dhillon wrote: > >I realize that in_cgroup is more consistent, but under_cgroup makes > >far more sense to me. I think it's more intuitive. > > > >On Thu, Aug 11, 201

Re: [PATCH net-next v4 2/3] bpf: Add bpf_current_task_under_cgroup helper

2016-08-11 Thread Sargun Dhillon
I realize that in_cgroup is more consistent, but under_cgroup makes far more sense to me. I think it's more intuitive. On Thu, Aug 11, 2016 at 9:48 PM, Alexei Starovoitov wrote: > On Thu, Aug 11, 2016 at 08:14:56PM -0700, Sargun Dhillon wrote: >> This adds a bpf helper that&#x

[PATCH net-next v4 3/3] samples/bpf: Add test_current_task_under_cgroup test

2016-08-11 Thread Sargun Dhillon
p prior to execution in userspace. This means that the program must be run in the same cgroups namespace as the programs that are being traced. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo --- samples/bpf/Makefile | 5 + s

[PATCH net-next v4 2/3] bpf: Add bpf_current_task_under_cgroup helper

2016-08-11 Thread Sargun Dhillon
it'll return an error. The helper is primarily to be used in debugging activities for containers, where you may have multiple programs running in a given top-level "container". Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo --- include/u

[PATCH net-next v4 1/3] cgroup: Add task_under_cgroup_hierarchy cgroup inline function to headers

2016-08-11 Thread Sargun Dhillon
This commit adds an inline function to cgroup.h to check whether a given task is under a given cgroup hierarchy. This is to avoid having to put ifdefs in .c files to gate access to cgroups. When cgroups are disabled this always returns true. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov

[PATCH net-next v4 0/3]

2016-08-11 Thread Sargun Dhillon
defs out of *.c files, add an "integration" test v3->v4: De-genercize arraymap fetching function; rename helper from in_cgroup to under_cgroup (makes much more sense) Split adding cgroups task_under_cgroup_hierarchy function Sargun Dhillon (3): cgroup: Add task_un

[PATCH net-next v3 2/2] samples/bpf: Add test_current_task_in_cgroup test

2016-08-11 Thread Sargun Dhillon
p prior to execution in userspace. This means that the program must be run in the same cgroups namespace as the programs that are being traced. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo --- samples/bpf/Makefile | 4 + s

[PATCH net-next v3 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-11 Thread Sargun Dhillon
helper. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Tejun Heo --- include/linux/bpf.h | 22 ++ include/linux/cgroup.h | 23 +++ include/uapi/linux/bpf.h | 11 +++ kernel/bpf/arraymap.c| 2 +- kernel/bp

[PATCH net-next v3 0/2] Add bpf current_task_in_cgroup helper & opensnoop example

2016-08-11 Thread Sargun Dhillon
of *.c files, add an "integration" test Sargun Dhillon (2): bpf: Add bpf_current_task_in_cgroup helper samples/bpf: Add test_current_task_in_cgroup test include/linux/bpf.h| 22 include/linux/cgroup.h | 23 include/uapi/linux/bp

Re: [net-next v2 v2 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
On Tue, Aug 09, 2016 at 08:52:01PM -0700, Alexei Starovoitov wrote: > On Tue, Aug 09, 2016 at 08:40:05PM -0700, Sargun Dhillon wrote: > > On Tue, Aug 09, 2016 at 08:27:32PM -0700, Alexei Starovoitov wrote: > > > On Tue, Aug 09, 2016 at 06:26:37PM -0700, Sargun Dhillon wrote: >

Re: [net-next v2 v2 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
On Tue, Aug 09, 2016 at 08:27:32PM -0700, Alexei Starovoitov wrote: > On Tue, Aug 09, 2016 at 06:26:37PM -0700, Sargun Dhillon wrote: > > On Tue, Aug 09, 2016 at 06:02:34PM -0700, Alexei Starovoitov wrote: > > > On Tue, Aug 09, 2016 at 05:55:26PM -0700, Sargun Dhillon wrote: >

Re: [net-next v2 v2 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
On Tue, Aug 09, 2016 at 06:02:34PM -0700, Alexei Starovoitov wrote: > On Tue, Aug 09, 2016 at 05:55:26PM -0700, Sargun Dhillon wrote: > > On Tue, Aug 09, 2016 at 05:23:50PM -0700, Alexei Starovoitov wrote: > > > On Tue, Aug 09, 2016 at 05:00:12PM -0700, Sargun Dhillon wrote: &

Re: [net-next v2 v2 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
On Tue, Aug 09, 2016 at 05:23:50PM -0700, Alexei Starovoitov wrote: > On Tue, Aug 09, 2016 at 05:00:12PM -0700, Sargun Dhillon wrote: > > This adds a bpf helper that's similar to the skb_in_cgroup helper to check > > whether the probe is currently executing in the context of a

[net-next v2 v2 2/2] samples/bpf: Add opensnoop example that uses current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
t the program must be run in the same cgroups namespace as the programs that are being traced. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann --- samples/bpf/Makefile | 4 +++ samples/bpf/bpf_helpers.h | 2 ++ samples/bpf/trace_opensnoop_kern.c

[net-next v2 v2 1/2] bpf: Add bpf_current_task_in_cgroup helper

2016-08-09 Thread Sargun Dhillon
helper. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann --- include/linux/bpf.h | 24 include/uapi/linux/bpf.h | 11 +++ kernel/bpf/arraymap.c| 2 +- kernel/bpf/verifier.c| 4 +++- kernel/tr

[net-next v2 v2 0/2] Add bpf current_task_in_cgroup helper & opensnoop example

2016-08-09 Thread Sargun Dhillon
t supply a specific cgroup in the hierarchy, and it'll print out all files being opened under it. v1->v2: Add better example code -- OpenSnoop, clean up Sargun Dhillon (2): bpf: Add bpf_current_task_in_cgroup helper samples/bpf: Add opensnoop example that uses current_task_in

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

2016-08-08 Thread Sargun Dhillon
On Mon, Aug 08, 2016 at 04:44:02PM -0700, Kees Cook wrote: > On Thu, Aug 4, 2016 at 12:11 AM, Sargun Dhillon wrote: > > I distributed this patchset to linux-security-mod...@vger.kernel.org > > earlier, > > but based on the fact that the archive is down, and this is a fair

Re: [net-next 0/2] BPF, kprobes: Add current_in_cgroup helper

2016-08-08 Thread Sargun Dhillon
On Mon, Aug 08, 2016 at 11:27:32AM +0200, Daniel Borkmann wrote: > On 08/08/2016 05:52 AM, Alexei Starovoitov wrote: > >On Sun, Aug 07, 2016 at 08:08:19PM -0700, Sargun Dhillon wrote: > >>Thanks for your feedback Alexei, > >>I really appreciate it. > >> > >

Re: [net-next 0/2] BPF, kprobes: Add current_in_cgroup helper

2016-08-07 Thread Sargun Dhillon
Thanks for your feedback Alexei, I really appreciate it. On Sun, Aug 07, 2016 at 05:52:36PM -0700, Alexei Starovoitov wrote: > On Sat, Aug 06, 2016 at 09:56:06PM -0700, Sargun Dhillon wrote: > > On Sat, Aug 06, 2016 at 09:32:05PM -0700, Alexei Starovoitov wrote: > > > On Sat,

Re: [net-next 0/2] BPF, kprobes: Add current_in_cgroup helper

2016-08-06 Thread Sargun Dhillon
On Sat, Aug 06, 2016 at 09:32:05PM -0700, Alexei Starovoitov wrote: > On Sat, Aug 06, 2016 at 09:06:53PM -0700, Sargun Dhillon wrote: > > This patchset includes a helper and an example to determine whether the > > kprobe > > is currently executing in the context of a speci

[net-next 2/2] samples/bpf: Add example using current_in_cgroup

2016-08-06 Thread Sargun Dhillon
This is a simple trace example that shows programs connecting, but only if they're in a chosen cgroup. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann --- samples/bpf/Makefile | 4 ++ samples/bpf/bpf_helpers.h | 2 + sa

[net-next 0/2] BPF, kprobes: Add current_in_cgroup helper

2016-08-06 Thread Sargun Dhillon
This patchset includes a helper and an example to determine whether the kprobe is currently executing in the context of a specific cgroup based on a cgroup bpf map / array. Sargun Dhillon (2): bpf: Add bpf_current_in_cgroup helper samples/bpf: Add example using current_in_cgroup include

[net-next 1/2] bpf: Add bpf_current_in_cgroup helper

2016-08-06 Thread Sargun Dhillon
This adds a kprobe helper that's similar to the skb_in_cgroup helper. It checks whether the probe is currently executing in the context of the cgroup at the given index a CGROUP_ARRAY. Signed-off-by: Sargun Dhillon Cc: Alexei Starovoitov Cc: Daniel Borkmann --- include/linux/bpf.h

Re: [RFC 2/4] bpf, security: Add Checmate

2016-08-05 Thread Sargun Dhillon
On Thu, Aug 04, 2016 at 05:34:32PM +0800, zhuyj wrote: > Sure. > Is it better to add > #ifndef CONFIG_PREEMPT_RCU ? > > On Thu, Aug 4, 2016 at 4:28 PM, Eric Dumazet wrote: > > Please do not top post > > > > On Thu, 2016-08-04 at 16:08 +0800, zhuyj wrote: > >> +void register_checmate_prog_ops(vo

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

2016-08-04 Thread Sargun Dhillon
On Thu, Aug 04, 2016 at 11:45:08AM +0200, Daniel Borkmann wrote: > Hi Sargun, > > On 08/04/2016 09:11 AM, Sargun Dhillon wrote: > [...] > >[It's a] minor LSM. My particular use case is one in which containers are > >being > >dynamically deployed to machines by

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

2016-08-04 Thread Sargun Dhillon
On Thu, Aug 04, 2016 at 10:41:17AM +0200, Richard Weinberger wrote: > Sargun, > > On Thu, Aug 4, 2016 at 9:11 AM, Sargun Dhillon wrote: > > I distributed this patchset to linux-security-mod...@vger.kernel.org > > earlier, > > but based on the fact that the archive is

[RFC 4/4] bpf: Restrict Checmate bpf programs to current kernel ABI

2016-08-04 Thread Sargun Dhillon
I think it makes sense to restrict Checmate to loading programs that have been compiled with the current kernel ABI. We can further stabilize the ABI, and perhaps lift this restriction later. Signed-off-by: Sargun Dhillon --- kernel/bpf/syscall.c | 2 +- samples/bpf/checmate1_kern.c

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

2016-08-04 Thread Sargun Dhillon
nforcing a hook. BPF programs also have access to maps, which somewhat works around the need for security blobs in some cases. I would love to know what y'all think. Sargun Dhillon (4): bpf: move tracing helpers to shared helpers bpf, security: Add Checmate security/checmate: Add Checma

[RFC 2/4] bpf, security: Add Checmate

2016-08-04 Thread Sargun Dhillon
t the user would lock their hooks. Signed-off-by: Sargun Dhillon --- include/linux/checmate.h | 38 + include/uapi/linux/Kbuild| 1 + include/uapi/linux/bpf.h | 1 + include/uapi/linux/checmate.h| 65 + include/uapi/linux/prctl.h

[RFC 1/4] bpf: move tracing helpers to shared helpers

2016-08-04 Thread Sargun Dhillon
Move bpf_probe_read and bpf_get_current_task to the shared helpers so that Checmate can use them. Signed-off-by: Sargun Dhillon --- include/linux/bpf.h | 2 ++ kernel/bpf/helpers.c | 34 ++ kernel/trace/bpf_trace.c | 33

[RFC 3/4] security/checmate: Add Checmate sample

2016-08-04 Thread Sargun Dhillon
The Checmate sample installs a policy barring new AF_INET connections to port 1. We install the hook, and show an example of connect returning EPERM, and then reset the policy. If this is running concurrently with other policy engines, bad things could happen. Signed-off-by: Sargun Dhillon

[PATCH net-next v7 0/2] bpf: add bpf_probe_write_user helper & example

2016-07-25 Thread Sargun Dhillon
Rename bpf_probe_write -> bpf_probe_write_user v6->v7: More formatting cleanup. Clarifying a few comments Clarified log message Sargun Dhillon (2): bpf: Add bpf_probe_write_user BPF helper to be called in tracers samples/bpf: Add test/example of using bpf_probe_write_us

  1   2   >