From: Jann Horn <jannh@google.com>
To: KP Singh <kpsingh@chromium.org>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andriin@fb.com>,
Brendan Jackman <jackmanb@google.com>,
Florent Revest <revest@google.com>,
Thomas Garnier <thgarnie@google.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kees Cook <keescook@chromium.org>, Paul Turner <pjt@google.com>,
Florent Revest <revest@chromium.org>,
Brendan Jackman <jackmanb@chromium.org>
Subject: Re: [PATCH bpf-next v9 7/8] bpf: lsm: Add selftests for BPF_PROG_TYPE_LSM
Date: Thu, 2 Apr 2020 16:38:41 +0200 [thread overview]
Message-ID: <CAG48ez3Nv0wA=7FOrHFJwy+uFfBQLP5-Y8h4wFnkKCp7HB9m2g@mail.gmail.com> (raw)
In-Reply-To: <20200402115306.GA100892@google.com>
On Thu, Apr 2, 2020 at 1:53 PM KP Singh <kpsingh@chromium.org> wrote:
> On 02-Apr 07:15, Jann Horn wrote:
[...]
> > I suspect that you're using different versions of libc, or something's
> > different in the memory layout, or something like that. The brk region
> > is used for memory allocations using brk(), but memory allocations
> > using mmap() land outside it. At least some versions of libc try to
> > allocate memory for malloc() with brk(), then fall back to mmap() if
> > that fails because there's something else behind the current end of
> > the brk region; but I think there might also be versions of libc that
> > directly use mmap() and don't even try to use brk().
>
> Yeah missed this that heap can also be allocated using mmap:
[...]
> I updated my test case to check for mmaps on the stack instead:
[...]
> + is_stack = (vma->vm_start <= vma->vm_mm->start_stack &&
> + vma->vm_end >= vma->vm_mm->start_stack);
>
> - if (is_heap && monitored_pid == pid) {
> + if (is_stack && monitored_pid == pid) {
> mprotect_count++;
> ret = -EPERM;
> }
>
> and the the logic seems to work for me. Do you think we could use
> this instead?
Yeah, I think that should work. (Just keep in mind that a successful
mprotect() operation will split the VMA into three VMAs - but that
shouldn't be a problem here, since you only do it once per process,
and since you're denying the operation, it won't go through anyway.)
next prev parent reply other threads:[~2020-04-02 14:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-29 0:43 [PATCH bpf-next v9 0/8] MAC and Audit policy using eBPF (KRSI) KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 1/8] bpf: Introduce BPF_PROG_TYPE_LSM KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 2/8] security: Refactor declaration of LSM hooks KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 3/8] bpf: lsm: provide attachment points for BPF LSM programs KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 4/8] bpf: lsm: Implement attach, detach and execution KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 5/8] bpf: lsm: Initialize the BPF LSM hooks KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 6/8] tools/libbpf: Add support for BPF_PROG_TYPE_LSM KP Singh
2020-03-29 0:43 ` [PATCH bpf-next v9 7/8] bpf: lsm: Add selftests " KP Singh
2020-04-02 0:09 ` Alexei Starovoitov
2020-04-02 4:03 ` KP Singh
2020-04-02 4:30 ` Alexei Starovoitov
2020-04-02 5:15 ` Jann Horn
2020-04-02 11:53 ` KP Singh
2020-04-02 14:38 ` Jann Horn [this message]
2020-04-02 14:40 ` KP Singh
2020-04-02 15:57 ` Alexei Starovoitov
2020-03-29 0:43 ` [PATCH bpf-next v9 8/8] bpf: lsm: Add Documentation KP Singh
2020-03-29 23:46 ` [PATCH bpf-next v9 0/8] MAC and Audit policy using eBPF (KRSI) Daniel Borkmann
2020-04-29 12:31 ` Mikko Ylinen
2020-04-29 12:34 ` KP Singh
2020-04-29 12:45 ` Mikko Ylinen
2020-04-29 16:17 ` KP Singh
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='CAG48ez3Nv0wA=7FOrHFJwy+uFfBQLP5-Y8h4wFnkKCp7HB9m2g@mail.gmail.com' \
--to=jannh@google.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andriin@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jackmanb@chromium.org \
--cc=jackmanb@google.com \
--cc=keescook@chromium.org \
--cc=kpsingh@chromium.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).