linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: KP Singh <kpsingh@chromium.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: open list <linux-kernel@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>,
	linux-security-module@vger.kernel.org,
	Brendan Jackman <jackmanb@google.com>,
	Florent Revest <revest@google.com>,
	Thomas Garnier <thgarnie@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	James Morris <jmorris@namei.org>,
	Kees Cook <keescook@chromium.org>, Paul Turner <pjt@google.com>,
	Jann Horn <jannh@google.com>,
	Florent Revest <revest@chromium.org>,
	Brendan Jackman <jackmanb@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH bpf-next v7 7/8] bpf: lsm: Add selftests for BPF_PROG_TYPE_LSM
Date: Thu, 26 Mar 2020 20:44:00 +0100	[thread overview]
Message-ID: <20200326194400.GB15273@chromium.org> (raw)
In-Reply-To: <CAEf4BzZRe_kFR4yzhPFGgauvYLKvre1reuGp=5=jq_nvQGAayw@mail.gmail.com>

On 26-Mär 12:24, Andrii Nakryiko wrote:
> On Thu, Mar 26, 2020 at 7:30 AM KP Singh <kpsingh@chromium.org> wrote:
> >
> > From: KP Singh <kpsingh@google.com>
> >
> > * Load/attach a BPF program that hooks to file_mprotect (int)
> >   and bprm_committed_creds (void).
> > * Perform an action that triggers the hook.
> > * Verify if the audit event was received using the shared global
> >   variables for the process executed.
> > * Verify if the mprotect returns a -EPERM.
> >
> > Signed-off-by: KP Singh <kpsingh@google.com>
> > Reviewed-by: Brendan Jackman <jackmanb@google.com>
> > Reviewed-by: Florent Revest <revest@google.com>
> > Reviewed-by: Thomas Garnier <thgarnie@google.com>
> > ---
> 
> Please fix endlines below. With that:
> 
> Acked-by: Andrii Nakryiko <andriin@fb.com>
> 
> >  tools/testing/selftests/bpf/config            |  2 +
> >  .../selftests/bpf/prog_tests/test_lsm.c       | 86 +++++++++++++++++++
> >  tools/testing/selftests/bpf/progs/lsm.c       | 48 +++++++++++
> >  3 files changed, 136 insertions(+)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/test_lsm.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/lsm.c
> >
> 
> [...]
> 
> > +void test_test_lsm(void)
> > +{
> > +       struct lsm *skel = NULL;
> > +       int err, duration = 0;
> > +
> > +       skel = lsm__open_and_load();
> > +       if (CHECK(!skel, "skel_load", "lsm skeleton failed\n"))
> > +               goto close_prog;
> > +
> > +       err = lsm__attach(skel);
> > +       if (CHECK(err, "attach", "lsm attach failed: %d\n", err))
> > +               goto close_prog;
> > +
> > +       err = exec_cmd(&skel->bss->monitored_pid);
> > +       if (CHECK(err < 0, "exec_cmd", "err %d errno %d\n", err, errno))
> > +               goto close_prog;
> > +
> > +       CHECK(skel->bss->bprm_count != 1, "bprm_count", "bprm_count = %d",
> 
> \n is missing

Done.

> 
> > +             skel->bss->bprm_count);
> > +
> > +       skel->bss->monitored_pid = getpid();
> > +
> > +       err = heap_mprotect();
> > +       if (CHECK(errno != EPERM, "heap_mprotect", "want errno=EPERM, got %d\n",
> > +                 errno))
> > +               goto close_prog;
> > +
> > +       CHECK(skel->bss->mprotect_count != 1, "mprotect_count",
> > +             "mprotect_count = %d", skel->bss->mprotect_count);
> 
> \n is missing

Done.

- KP

> 
> > +
> > +close_prog:
> > +       lsm__destroy(skel);
> > +}
> 
> [...]

  reply	other threads:[~2020-03-26 19:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 14:28 [PATCH bpf-next v7 0/8] MAC and Audit policy using eBPF (KRSI) KP Singh
2020-03-26 14:28 ` [PATCH bpf-next v7 1/8] bpf: Introduce BPF_PROG_TYPE_LSM KP Singh
2020-03-27  0:27   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 2/8] security: Refactor declaration of LSM hooks KP Singh
2020-03-27  0:28   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 3/8] bpf: lsm: provide attachment points for BPF LSM programs KP Singh
2020-03-27  0:29   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 4/8] bpf: lsm: Implement attach, detach and execution KP Singh
2020-03-26 19:12   ` Andrii Nakryiko
2020-03-26 19:39     ` KP Singh
2020-03-27  0:24   ` James Morris
2020-03-27 12:27     ` Stephen Smalley
2020-03-27 12:41       ` KP Singh
2020-03-27 13:43         ` Stephen Smalley
2020-03-27 14:29           ` KP Singh
2020-03-27 16:36           ` Casey Schaufler
2020-03-27 18:59             ` Kees Cook
2020-03-27 19:17               ` KP Singh
2020-03-27  3:12   ` Alexei Starovoitov
2020-03-27 15:06     ` KP Singh
2020-03-26 14:28 ` [PATCH bpf-next v7 5/8] bpf: lsm: Initialize the BPF LSM hooks KP Singh
2020-03-27  0:29   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 6/8] tools/libbpf: Add support for BPF_PROG_TYPE_LSM KP Singh
2020-03-27  0:30   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 7/8] bpf: lsm: Add selftests " KP Singh
2020-03-26 19:24   ` Andrii Nakryiko
2020-03-26 19:44     ` KP Singh [this message]
2020-03-27  0:31   ` James Morris
2020-03-26 14:28 ` [PATCH bpf-next v7 8/8] bpf: lsm: Add Documentation KP Singh
2020-03-26 19:31   ` Andrii Nakryiko
2020-03-26 20:56     ` KP Singh
2020-03-26 22:01       ` Andrii Nakryiko
2020-03-27  0:33   ` James Morris

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=20200326194400.GB15273@chromium.org \
    --to=kpsingh@chromium.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackmanb@chromium.org \
    --cc=jackmanb@google.com \
    --cc=jannh@google.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=pjt@google.com \
    --cc=revest@chromium.org \
    --cc=revest@google.com \
    --cc=thgarnie@google.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;
as well as URLs for NNTP newsgroup(s).