[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200326133617.GC8575@chromium.org>
Date: Thu, 26 Mar 2020 14:36:17 +0100
From: KP Singh <kpsingh@...omium.org>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: open list <linux-kernel@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, linux-security-module@...r.kernel.org,
Brendan Jackman <jackmanb@...gle.com>,
Florent Revest <revest@...gle.com>,
Thomas Garnier <thgarnie@...gle.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
James Morris <jmorris@...ei.org>,
Kees Cook <keescook@...omium.org>,
Paul Turner <pjt@...gle.com>, Jann Horn <jannh@...gle.com>,
Florent Revest <revest@...omium.org>,
Brendan Jackman <jackmanb@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH bpf-next v6 7/8] bpf: lsm: Add selftests for
BPF_PROG_TYPE_LSM
On 25-Mär 19:01, Andrii Nakryiko wrote:
> On Wed, Mar 25, 2020 at 8:27 AM KP Singh <kpsingh@...omium.org> wrote:
> >
> > From: KP Singh <kpsingh@...gle.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@...gle.com>
> > Reviewed-by: Brendan Jackman <jackmanb@...gle.com>
> > Reviewed-by: Florent Revest <revest@...gle.com>
> > Reviewed-by: Thomas Garnier <thgarnie@...gle.com>
> > ---
> > tools/testing/selftests/bpf/config | 2 +
> > .../selftests/bpf/prog_tests/test_lsm.c | 84 +++++++++++++++++++
> > tools/testing/selftests/bpf/progs/lsm.c | 48 +++++++++++
> > 3 files changed, 134 insertions(+)
> > create mode 100644 tools/testing/selftests/bpf/prog_tests/test_lsm.c
> > create mode 100644 tools/testing/selftests/bpf/progs/lsm.c
> >
>
> [...]
>
> > +
> > +int exec_cmd(int *monitored_pid)
> > +{
> > + int child_pid;
> > +
> > + child_pid = fork();
> > + if (child_pid == 0) {
> > + *monitored_pid = getpid();
> > + execvp(CMD_ARGS[0], CMD_ARGS);
> > + return -EINVAL;
> > + } else if (child_pid > 0)
>
> This test is part of test_progs, so let's be a good citizen and wait
> for your specific child. I'd rather not hunt for elusive bugs later,
> so please use waitpid() instead.
Good idea. Done.
- KP
>
> Otherwise looks good and clean, thanks!
>
> > + return wait(NULL);
> > +
> > + return -EINVAL;
> > +}
> > +
>
> [...]
Powered by blists - more mailing lists