From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Paul Moore <pmoore@redhat.com>,
qemu-devel@nongnu.org, Avi Kivity <avi@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Eduardo Otubo <otubo@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [RFC] [PATCHv2 2/2] Adding basic calls to libseccomp in vl.c
Date: Mon, 02 Jul 2012 14:05:08 -0400 [thread overview]
Message-ID: <4FF1E2D4.1050702@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAAu8pHtYmoJ7WCK7LAOj_j2YU-nAgiLTg7q4qXL3Vu-kPRpZnw@mail.gmail.com>
On 06/28/2012 03:49 PM, Blue Swirl wrote:
> On Wed, Jun 27, 2012 at 9:25 PM, Anthony Liguori <anthony@codemonkey.ws> wrote:
>> On 06/21/2012 03:04 AM, Avi Kivity wrote:
>>>
>>> On 06/19/2012 09:58 PM, Blue Swirl wrote:
>>>>>>
>>>>>> At least qemu-ifup/down scripts, migration exec and smbd have been
>>>>>> mentioned. Only the system calls made by smbd (for some version of it)
>>>>>> can be known. The user could specify arbitrary commands for the
>>>>>> others, those could be assumed to use some common (large) subset of
>>>>>> system calls but I think the security value would be close to zero
>>>>>> then.
>>>>>
>>>>>
>>>>> We're not trying to protect against the user, but against the guest. If
>>>>> we assume the user wrote those scripts with care so they cannot be
>>>>> exploited by the guest, then we are okay.
>>>>
>>>>
>>>> My concern was that first we could accidentally filter a system call
>>>> that changes the script or executable behavior, much like sendmail +
>>>> capabilities bug, and then a guest could trigger running this
>>>> script/executable and exploit the changed behavior.
>>>
>>>
>>> Ah, I see. I agree this is dangerous. We should probably disable exec
>>> if we seccomp.
>>
>>
>> There's no great place to jump into this thread so I guess I'll do it here.
>>
>> There is absolutely no doubt that white-listing syscalls that we currently
>> use provides an improvement in security.
>>
>> We need to assume:
>>
>> 1) QEMU is run as an unprivileged user
>>
>> 2) QEMU is already heavily restricted by SELinux
>>
>> In this case, seccomp() is not being used to replace MAC or DAC. It's
>> supplementing both of them by additionally filtering out syscalls that may
>> have unknown kernel exploits in them. That's all this initial effort is
>> about. Since it's scope is so limited, we can simply enable it
>> unconditionally too.
>
> I don't think the scope is limited in a safe way. What is the set of
> system calls that can't ever cause problems to any possible ifup/down
> scripts, migration exec helpers and various versions of smbd?
>
> For example, unlink() is missing. What if the ifup/down script needs
> it for lock file cleanup? ftruncate()? Every socket syscalls in case
> LDAP is used to access user information by the libc?
>
> I think we can't define the safe set, except 'allow all'. I'd propose
> one of the following to avoid breakage:
>
> 1. Allow all system calls for the initial patch, refactor later to
> reduce the set. Useless until refactored.
One thing I like about starting with a known subset of syscalls used by
QEMU is that it forces us to expand the whitelist if we come across more
syscalls that QEMU uses.
An issue with this approach is that if seccomp kills QEMU for using a
disallowed syscall, I don't think we know what syscall it is. (At
least, I don't think it is accessible anywhere.) This is good for
security but makes it hard for developers who are debugging.
Would it make sense to have the ability to configure QEMU in either:
1) seccomp kill mode (this is what the existing patches do), or
2) seccomp debug mode?
In debug mode we could trap on the failing syscall (using
SCMP_ACT_TRAP), determine the syscall value, and issue an error message
that displays the syscall value.
The emulator() function here gives an idea of how this could be done:
https://lkml.org/lkml/2012/4/12/449
>
> 2. Don't make seccomp mode enabled default, when enabled, forbid
> execve(). Limits functionality when enabled, no security benefit if
> not enabled.
>
> 3. Before enabling seccomp, fork a helper process without restrictions
> that is used to launch other programs. Needs some work.
>
>>
>> After we have this initial support, then we can look at a -sandbox option.
>> This open could prevent things like open()/execve() but that will come at a
>> cost of features.
>>
>> I think the reasonable thing to do for -sandbox is to basically focus on the
>> set of syscalls that QEMU would use if it were launched under libvirt. We
>> should obviously make improvements (things like -blockdev) to make this even
>> more restrictive.
>>
>> Who knows, maybe we end up having multiple types of sandboxes. A '-sandbox
>> libvirt' and a '-sandbox user' where the later is focused on the typical
>> usage of an unprivileged user.
>>
>> But this is all stuff that can come later. We solve a big problem by just
>> getting the initial whitelist support in.
>
> Fully agree, but we'd have to agree about what is a safe initial whitelist.
>
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>
>>>
>>>>>
>>>>> We have decomposed qemu to some extent, in that privileged operations
>>>>> happen in libvirt. So the modes make sense - qemu has no idea whether a
>>>>> privileged management system is controlling it or not.
>>>>
>>>>
>>>> So with -seccomp, libvirt could tell QEMU that for example open(),
>>>> execve(), bind() and connect() will never be needed?
>>>
>>>
>>> Yes.
>>>
>>
>
--
Regards,
Corey
next prev parent reply other threads:[~2012-07-02 18:09 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 19:20 [Qemu-devel] [RFC] [PATCHv2 0/2] Sandboxing Qemu guests with Libseccomp Eduardo Otubo
2012-06-13 19:20 ` [Qemu-devel] [RFC] [PATCHv2 1/2] Adding support for libseccomp in configure Eduardo Otubo
2012-06-13 19:45 ` Blue Swirl
2012-06-13 19:20 ` [Qemu-devel] [RFC] [PATCHv2 2/2] Adding basic calls to libseccomp in vl.c Eduardo Otubo
2012-06-13 19:56 ` Blue Swirl
2012-06-13 20:33 ` Daniel P. Berrange
2012-06-15 19:04 ` Blue Swirl
2012-06-18 8:33 ` Daniel P. Berrange
2012-06-18 15:22 ` Corey Bryant
2012-06-18 20:18 ` Blue Swirl
2012-06-18 21:53 ` Corey Bryant
[not found] ` <CABqD9hYKLf9D37XsF6nvNmtJ=0wJ39Yu_A-JeWxDJ_8haBmEWA@mail.gmail.com>
[not found] ` <4FE08025.6030406@linux.vnet.ibm.com>
[not found] ` <CABqD9ha32FAuikpDojzO91Jg8Q6VTY340LShKzpvTx6FN_uacQ@mail.gmail.com>
2012-06-19 16:51 ` Corey Bryant
2012-07-01 13:25 ` Paolo Bonzini
2012-07-02 2:18 ` Will Drewry
2012-07-02 14:20 ` Corey Bryant
2012-06-13 20:30 ` Daniel P. Berrange
2012-06-15 19:06 ` Blue Swirl
2012-06-15 21:02 ` Paul Moore
2012-06-15 21:23 ` Blue Swirl
2012-06-15 21:36 ` Paul Moore
2012-06-16 6:46 ` Blue Swirl
2012-06-18 17:41 ` Corey Bryant
2012-06-19 11:04 ` Avi Kivity
2012-06-19 18:58 ` Blue Swirl
2012-06-21 8:04 ` Avi Kivity
[not found] ` <4FEB7A4D.7050608@redhat.com>
[not found] ` <CAAu8pHtYmoJ7WCK7LAOj_j2YU-nAgiLTg7q4qXL3Vu-kPRpZnw@mail.gmail.com>
2012-07-02 18:05 ` Corey Bryant [this message]
2012-07-03 19:15 ` Blue Swirl
2012-06-15 21:44 ` Eric Blake
2012-06-18 8:31 ` Daniel P. Berrange
2012-06-18 8:38 ` Daniel P. Berrange
2012-06-18 13:52 ` Paul Moore
2012-06-18 13:55 ` Daniel P. Berrange
2012-06-18 14:02 ` Paul Moore
2012-06-18 20:13 ` Eduardo Otubo
2012-06-18 20:23 ` Blue Swirl
2012-06-18 15:29 ` Corey Bryant
2012-06-18 20:15 ` Blue Swirl
2012-06-19 9:23 ` Daniel P. Berrange
2012-06-19 18:44 ` Blue Swirl
2012-06-18 8:26 ` Daniel P. Berrange
2012-06-13 20:37 ` Daniel P. Berrange
2012-06-13 20:31 ` [Qemu-devel] [RFC] [PATCHv2 0/2] Sandboxing Qemu guests with Libseccomp Paul Moore
2012-06-14 21:59 ` [Qemu-devel] [libseccomp-discuss] " Kees Cook
2012-06-15 13:54 ` Paul Moore
2012-10-29 15:11 ` Corey Bryant
2012-10-29 15:32 ` Daniel P. Berrange
2012-10-29 15:40 ` Paul Moore
2012-10-29 15:51 ` Corey Bryant
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=4FF1E2D4.1050702@linux.vnet.ibm.com \
--to=coreyb@linux.vnet.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=otubo@linux.vnet.ibm.com \
--cc=pmoore@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).