From: Stefan Hajnoczi <stefanha@gmail.com>
To: "M. Mohan Kumar" <mohan@in.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V12 00/15] virtio-9p: chroot environment for passthrough security model
Date: Tue, 6 Sep 2011 15:49:41 +0100 [thread overview]
Message-ID: <CAJSP0QV34e6XCWtSNEbxkLiNDsE4TyQbNXCByvq3Atj6C-Y3fQ@mail.gmail.com> (raw)
In-Reply-To: <20110906144822.GA27940@stefanha-thinkpad.localdomain>
Sorry, I forgot to include Daniel Berrange who might have thoughts
about a nice way of running the privileged virtfs helper and how to
integrate with libvirt.
On Tue, Sep 6, 2011 at 3:48 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Mon, Sep 05, 2011 at 09:48:21PM +0530, M. Mohan Kumar wrote:
>> Qemu need to be invoked by root user for using virtfs with passthrough
>> security model (i.e to use chroot() syscall).
>>
>> Question is: Is running qemu by root user expected and allowed? Some of the
>> virtfs features can be utilized only if qemu is started by root user (for
>> example passthrough security model and handle based file driver need root
>> privilege).
>>
>> This issue can be resolved by root user starting qemu and spawning a process
>> with root privilege to do all privileged operations there and main qemu
>> process dropping its privileges to avoid any security issue in running qemu in
>> root mode. Privileged operations can be done similar to the chroot patchset.
>>
>> But how to determine to which user-id(ie non root user id) qemu needs to drop
>> the privileges? Do we have a common user-id across all distributions/systems
>> to which qemu process can be dropped down? Also it becomes too complex i.e when
>> a new feature needing root privilege is added, a process with root privilege
>> needs to be created to handle this.
>>
>> So is it allowed to run qemu by root user? If no, is it okay to add the
>> complexity of adding a root privilege process for each feature that needs root
>> privilege?
>
> I believe libvirt performs the privilege dropping itself and then
> invokes QEMU. So in the context of KVM + libvirt we do not have
> privileges in QEMU. Of course the administrator can edit
> /etc/libvirt/qemu.conf and configure the user to run QEMU as (i.e.
> root). But the intention here is to run QEMU unprivileged.
>
> QEMU has its own -runas switch which may be used when QEMU is run
> directly by a user or by custom scripts. This switch looks up the user
> and switches to their uid/gid/groups.
>
> We need to think carefully before adding privileged features to QEMU
> since they usually require extra configuration to safely limit the group
> of users who may use the feature. These features will be unavailable to
> unprivileged users on a system.
>
> The main part of QEMU (vcpu execution and device emulation) should never
> run privileged. This way attacks on QEMU's code are limited to giving
> unprivileged access on the host.
>
> A virtfs feature that needs root therefore needs to be in a separate
> process. Either QEMU needs to fork or virtfs could use a separate
> daemon binary.
>
> You have already implemented the fork approach in the chroot patches.
> Handle-based open could work in the same way.
>
> To summarize this architecture: all path-related operations are
> performed by a separate privileged process. File descriptors are passed
> to QEMU over a UNIX domain socket. This way QEMU can do the actual
> read(2)/write(2) calls directly to/from guest memory.
>
> I think it would be nice to build a completely separate binary that QEMU
> connects to. The separate binary would have a much smaller footprint
> (doesn't include QEMU code). More importantly the
> privileged/unprivileged boundary would be simple and could be
> automatically set up by libvirt:
>
> $ sudo namespace_helper --sock /var/run/virtfs/1234.sock --export my_dir/
> $ qemu -fsdev local,id=my_fs,namespace_helper=/var/run/virtfs/1234.sock \
> -device virtio-9p-pci,fsdev=my_fs
>
> Stefan
>
next prev parent reply other threads:[~2011-09-06 14:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 16:18 [Qemu-devel] [PATCH V12 00/15] virtio-9p: chroot environment for passthrough security model M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 01/15] Implement qemu_read_full M. Mohan Kumar
2011-09-05 17:57 ` malc
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 02/15] hw/9pfs: Enable CONFIG_THREAD if CONFIG_VIRTFS is enabled M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 03/15] hw/9pfs: Provide chroot worker side interfaces M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 04/15] hw/9pfs: qemu interfaces for chroot environment M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 05/15] hw/9pfs: Support for opening a file in " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 06/15] hw/9pfs: Create support " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 07/15] hw/9pfs: Creating special files " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 08/15] hw/9pfs: Removing file or directory " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 09/15] hw/9pfs: Rename " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 10/15] hw/9pfs: Move file post creation changes to none security model M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 11/15] hw/9pfs: chmod in chroot environment M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 12/15] hw/9pfs: chown " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 13/15] hw/9pfs: stat " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 14/15] hw/9pfs: readlink " M. Mohan Kumar
2011-09-05 16:18 ` [Qemu-devel] [PATCH V12 15/15] hw/9pfs: Chroot environment for other functions M. Mohan Kumar
2011-09-06 14:48 ` [Qemu-devel] [PATCH V12 00/15] virtio-9p: chroot environment for passthrough security model Stefan Hajnoczi
2011-09-06 14:49 ` Stefan Hajnoczi [this message]
2011-09-12 14:15 ` M. Mohan Kumar
2011-09-12 16:23 ` Daniel P. Berrange
2011-09-13 6:29 ` M. Mohan Kumar
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=CAJSP0QV34e6XCWtSNEbxkLiNDsE4TyQbNXCByvq3Atj6C-Y3fQ@mail.gmail.com \
--to=stefanha@gmail.com \
--cc=mohan@in.ibm.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).