From: Andrea Arcangeli <aarcange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
linux-kernel@vger.kernel.org, Hugh Dickins <hughd@google.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
kvm@vger.kernel.org, Jerome Glisse <jglisse@redhat.com>,
Pavel Emelyanov <xemul@virtuozzo.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Martin Cracauer <cracauer@cons.org>,
Denis Plotnikov <dplotnikov@virtuozzo.com>,
linux-mm@kvack.org, Marty McFadden <mcfadden8@llnl.gov>,
Maya Gokhale <gokhale2@llnl.gov>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Kees Cook <keescook@chromium.org>, Mel Gorman <mgorman@suse.de>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
linux-fsdevel@vger.kernel.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Subject: Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users
Date: Wed, 13 Mar 2019 14:52:30 -0400 [thread overview]
Message-ID: <20190313185230.GH25147@redhat.com> (raw)
In-Reply-To: <3714d120-64e3-702e-6eef-4ef253bdb66d@redhat.com>
Hello,
On Wed, Mar 13, 2019 at 09:22:31AM +0100, Paolo Bonzini wrote:
> On 13/03/19 07:00, Peter Xu wrote:
> >> However, I can imagine more special cases being added for other users. And,
> >> once you have more than one special case then you may want to combine them.
> >> For example, kvm and hugetlbfs together.
> > It looks fine to me if we're using MMF_USERFAULTFD_ALLOW flag upon
> > mm_struct, since that seems to be a very general flag that can be used
> > by anything we want to grant privilege for, not only KVM?
>
> Perhaps you can remove the fork() limitation, and add a new suboption to
> prctl(PR_SET_MM) that sets/resets MMF_USERFAULTFD_ALLOW. If somebody
> wants to forbid unprivileged userfaultfd and use KVM, they'll have to
> use libvirt or some other privileged management tool.
>
> We could also add support for this prctl to systemd, and then one could
> do "systemd-run -pAllowUserfaultfd=yes COMMAND".
systemd can already implement -pAllowUserfaultfd=no with seccomp if it
wants. It can also implement -yes if by default turns off userfaultfd
like firejail -seccomp would do.
If the end goal is to implement the filtering with an userland policy
instead of a kernel policy, seccomp enabled for all services sounds
reasonable. It's very unlikely you'll block only userfaultfd, firejail
-seccomp by default blocks dozen of syscalls that are unnecessary
99.9% of the time.
This is not about implementing an userland flexible policy, it's just
a simple kernel policy, to use until userland disables the kernel
policy to takeover with seccomp across the board.
I wouldn't like this too be too complicated because this is already
theoretically overlapping 100% with seccomp.
hugetlbfs is more complicated to detect, because even if you inherit
it from fork(), the services that mounts the fs may be in a different
container than the one that Oracle that uses userfaultfd later on down
the road from a different context. And I don't think it would be ok to
allow running userfaultfd just because you can open a file in an
hugetlbfs file system. With /dev/kvm it's a bit different, that's
chmod o-r by default.. no luser should be able to open it.
Unless somebody suggests a consistent way to make hugetlbfs "just
work" (like we could achieve clean with CRIU and KVM), I think Oracle
will need a one liner change in the Oracle setup to echo into that
file in addition of running the hugetlbfs mount.
Note that DPDK host bridge process will also need a one liner change
to do a dummy open/close of /dev/kvm to unblock the syscall.
Thanks,
Andrea
WARNING: multiple messages have this Message-ID (diff)
From: Andrea Arcangeli <aarcange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
linux-kernel@vger.kernel.org, Hugh Dickins <hughd@google.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
kvm@vger.kernel.org, Jerome Glisse <jglisse@redhat.com>,
Pavel Emelyanov <xemul@virtuozzo.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Martin Cracauer <cracauer@cons.org>,
Denis Plotnikov <dplotnikov@virtuozzo.com>,
linux-mm@kvack.org, Marty McFadden <mcfadden8@llnl.gov>,
Maya Gokhale <gokhale2@llnl.gov>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Kees Cook <keescook@chromium.org>, Mel Gorman <mgorman@suse.de>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
linux-fsdevel@vger.kernel.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users
Date: Wed, 13 Mar 2019 14:52:30 -0400 [thread overview]
Message-ID: <20190313185230.GH25147@redhat.com> (raw)
In-Reply-To: <3714d120-64e3-702e-6eef-4ef253bdb66d@redhat.com>
Hello,
On Wed, Mar 13, 2019 at 09:22:31AM +0100, Paolo Bonzini wrote:
> On 13/03/19 07:00, Peter Xu wrote:
> >> However, I can imagine more special cases being added for other users. And,
> >> once you have more than one special case then you may want to combine them.
> >> For example, kvm and hugetlbfs together.
> > It looks fine to me if we're using MMF_USERFAULTFD_ALLOW flag upon
> > mm_struct, since that seems to be a very general flag that can be used
> > by anything we want to grant privilege for, not only KVM?
>
> Perhaps you can remove the fork() limitation, and add a new suboption to
> prctl(PR_SET_MM) that sets/resets MMF_USERFAULTFD_ALLOW. If somebody
> wants to forbid unprivileged userfaultfd and use KVM, they'll have to
> use libvirt or some other privileged management tool.
>
> We could also add support for this prctl to systemd, and then one could
> do "systemd-run -pAllowUserfaultfd=yes COMMAND".
systemd can already implement -pAllowUserfaultfd=no with seccomp if it
wants. It can also implement -yes if by default turns off userfaultfd
like firejail -seccomp would do.
If the end goal is to implement the filtering with an userland policy
instead of a kernel policy, seccomp enabled for all services sounds
reasonable. It's very unlikely you'll block only userfaultfd, firejail
-seccomp by default blocks dozen of syscalls that are unnecessary
99.9% of the time.
This is not about implementing an userland flexible policy, it's just
a simple kernel policy, to use until userland disables the kernel
policy to takeover with seccomp across the board.
I wouldn't like this too be too complicated because this is already
theoretically overlapping 100% with seccomp.
hugetlbfs is more complicated to detect, because even if you inherit
it from fork(), the services that mounts the fs may be in a different
container than the one that Oracle that uses userfaultfd later on down
the road from a different context. And I don't think it would be ok to
allow running userfaultfd just because you can open a file in an
hugetlbfs file system. With /dev/kvm it's a bit different, that's
chmod o-r by default.. no luser should be able to open it.
Unless somebody suggests a consistent way to make hugetlbfs "just
work" (like we could achieve clean with CRIU and KVM), I think Oracle
will need a one liner change in the Oracle setup to echo into that
file in addition of running the hugetlbfs mount.
Note that DPDK host bridge process will also need a one liner change
to do a dummy open/close of /dev/kvm to unblock the syscall.
Thanks,
Andrea
next prev parent reply other threads:[~2019-03-13 18:52 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 9:36 [PATCH 0/3] userfaultfd: allow to forbid unprivileged users Peter Xu
2019-03-11 9:36 ` Peter Xu
2019-03-11 9:36 ` [PATCH 1/3] userfaultfd/sysctl: introduce unprivileged_userfaultfd Peter Xu
2019-03-11 9:36 ` Peter Xu
2019-03-12 6:58 ` Mike Rapoport
2019-03-12 6:58 ` Mike Rapoport
2019-03-12 12:26 ` Peter Xu
2019-03-12 12:26 ` Peter Xu
2019-03-12 13:53 ` Mike Rapoport
2019-03-12 13:53 ` Mike Rapoport
2019-03-11 9:37 ` [PATCH 2/3] kvm/mm: introduce MMF_USERFAULTFD_ALLOW flag Peter Xu
2019-03-11 9:37 ` Peter Xu
2019-03-11 9:37 ` [PATCH 3/3] userfaultfd: apply unprivileged_userfaultfd check Peter Xu
2019-03-11 9:37 ` Peter Xu
2019-03-11 9:58 ` Peter Xu
2019-03-11 9:58 ` Peter Xu
2019-03-12 7:01 ` [PATCH 0/3] userfaultfd: allow to forbid unprivileged users Mike Rapoport
2019-03-12 7:01 ` Mike Rapoport
2019-03-12 12:29 ` Peter Xu
2019-03-12 12:29 ` Peter Xu
2019-03-12 7:49 ` Kirill A. Shutemov
2019-03-12 7:49 ` Kirill A. Shutemov
2019-03-12 7:49 ` Kirill A. Shutemov
2019-03-12 12:43 ` Peter Xu
2019-03-12 12:43 ` Peter Xu
2019-03-12 12:43 ` Peter Xu
2019-03-12 19:59 ` Mike Kravetz
2019-03-12 19:59 ` Mike Kravetz
2019-03-13 6:00 ` Peter Xu
2019-03-13 6:00 ` Peter Xu
2019-03-13 8:22 ` Paolo Bonzini
2019-03-13 8:22 ` Paolo Bonzini
2019-03-13 18:52 ` Andrea Arcangeli [this message]
2019-03-13 18:52 ` Andrea Arcangeli
2019-03-13 19:12 ` Paolo Bonzini
2019-03-13 19:12 ` Paolo Bonzini
2019-03-13 23:44 ` Andrea Arcangeli
2019-03-13 23:44 ` Andrea Arcangeli
2019-03-14 10:58 ` Paolo Bonzini
2019-03-14 10:58 ` Paolo Bonzini
2019-03-14 15:23 ` Alexei Starovoitov
2019-03-14 15:23 ` Alexei Starovoitov
2019-03-14 16:00 ` Paolo Bonzini
2019-03-14 16:00 ` Paolo Bonzini
2019-03-14 16:16 ` Andrea Arcangeli
2019-03-14 16:16 ` Andrea Arcangeli
2019-03-15 16:09 ` Kees Cook
2019-03-15 16:09 ` Kees Cook
2019-03-13 20:01 ` Mike Kravetz
2019-03-13 23:55 ` Andrea Arcangeli
2019-03-13 23:55 ` Andrea Arcangeli
2019-03-14 3:32 ` Mike Kravetz
2019-03-14 3:32 ` Mike Kravetz
2019-03-13 17:50 ` Mike Kravetz
2019-03-13 17:50 ` Mike Kravetz
2019-03-15 8:26 ` Peter Xu
2019-03-15 8:26 ` Peter Xu
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=20190313185230.GH25147@redhat.com \
--to=aarcange@redhat.com \
--cc=cracauer@cons.org \
--cc=dgilbert@redhat.com \
--cc=dplotnikov@virtuozzo.com \
--cc=gokhale2@llnl.gov \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jglisse@redhat.com \
--cc=keescook@chromium.org \
--cc=kirill@shutemov.name \
--cc=kvm@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maxime.coquelin@redhat.com \
--cc=mcfadden8@llnl.gov \
--cc=mcgrof@kernel.org \
--cc=mgorman@suse.de \
--cc=mike.kravetz@oracle.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=xemul@virtuozzo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.