From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Jann Horn <jannh@google.com>, Prasad J Pandit <prasad@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 00/28] 9pfs: local: fix vulnerability to symlink attacks
Date: Mon, 27 Feb 2017 00:45:33 +0100 [thread overview]
Message-ID: <20170227004533.3fb25129@bahia.lan> (raw)
In-Reply-To: <148814889214.28146.16915712763478774662.stgit@bahia>
[-- Attachment #1: Type: text/plain, Size: 4179 bytes --]
On Sun, 26 Feb 2017 23:41:32 +0100
Greg Kurz <groug@kaod.org> wrote:
> This series tries to fix CVE-2016-9602 reported by Jann Horn of Google
> Project Zero:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1413929
>
> This vulnerability affects all accesses to the underlying filesystem in
> the "local" backend code.
>
> If QEMU is started with:
>
> -fsdev local,security_model=<passthrough|none>,path=/foo/bar
>
> then the guest can cause QEMU to create symlinks in /foo/bar.
>
> This causes accesses to any path /foo/bar/some/path to be unsafe, since
> untrusted code within the guest (or in another guest sharing the same
> virtfs folder) could change some/path to point to a random path of the
> host filesystem.
>
> The core problem is that the "local" backend relies on path-based syscalls
> to access the underlying filesystem. All path-based syscalls are vulnerable
> to this issue, even open(O_NOFOLLOW) or syscalls that explicitly don't
> dereference symlinks, since the kernel only checks the rightmost element of
> the path. Depending on the privilege level of the QEMU process, a guest can
> end up opening, renaming, changing ACLs, unlinking... files on the host
> filesystem.
>
> The right way to address this is to use "at" variants of all syscalls in
> the "local" backend code. This requires to open directories without
> traversing any symlink in the intermediate path elements. There was a
> tentative to introduce an O_BENEATH flag for openat() that would address
> this:
>
> https://patchwork.kernel.org/patch/7007181/
>
> Unfortunately this never got merged. An alternative is to walk through all
> path elements manually with openat(O_NOFOLLOW).
>
> v2:
> - /proc based implementation for xattr code (fixes metadata perf drop
> observed with v1)
> - some code refactoring
>
> Stefan.
>
> I had to rework some patches you had already reviewed, please consider
> giving your Reviewed-by again if the changes are ok.
>
> Thanks.
>
> --
> Greg
>
> ---
>
> Greg Kurz (28):
> 9pfs: local: move xattr security ops to 9p-xattr.c
> 9pfs: remove side-effects in local_init()
> 9pfs: remove side-effects in local_open() and local_opendir()
> 9pfs: introduce openat_nofollow() helper
> 9pfs: local: keep a file descriptor on the shared folder
> 9pfs: local: open/opendir: don't follow symlinks
> 9pfs: local: lgetxattr: don't follow symlinks
> 9pfs: local: llistxattr: don't follow symlinks
> 9pfs: local: lsetxattr: don't follow symlinks
> 9pfs: local: lremovexattr: don't follow symlinks
> 9pfs: local: unlinkat: don't follow symlinks
> 9pfs: local: remove: don't follow symlinks
> 9pfs: local: utimensat: don't follow symlinks
> 9pfs: local: statfs: don't follow symlinks
> 9pfs: local: truncate: don't follow symlinks
> 9pfs: local: readlink: don't follow symlinks
> 9pfs: local: lstat: don't follow symlinks
> 9pfs: local: renameat: don't follow symlinks
> 9pfs: local: rename: use renameat
> 9pfs: local: improve error handling in link op
> 9pfs: local: link: don't follow symlinks
> 9pfs: local: chmod: don't follow symlinks
> 9pfs: local: chown: don't follow symlinks
> 9pfs: local: symlink: don't follow symlinks
> 9pfs: local: mknod: don't follow symlinks
> 9pfs: local: mkdir: don't follow symlinks
> 9pfs: local: open2: don't follow symlinks
> 9pfs: local: drop unused code
>
>
> hw/9pfs/9p-local.c | 1023 ++++++++++++++++++++++++++---------------------
> hw/9pfs/9p-local.h | 20 +
> hw/9pfs/9p-posix-acl.c | 44 --
> hw/9pfs/9p-util.c | 65 +++
> hw/9pfs/9p-util.h | 52 ++
> hw/9pfs/9p-xattr-user.c | 24 -
> hw/9pfs/9p-xattr.c | 166 +++++++-
> hw/9pfs/9p-xattr.h | 87 +---
> hw/9pfs/Makefile.objs | 2
> 9 files changed, 887 insertions(+), 596 deletions(-)
> create mode 100644 hw/9pfs/9p-local.h
> create mode 100644 hw/9pfs/9p-util.c
> create mode 100644 hw/9pfs/9p-util.h
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-02-26 23:45 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-26 22:41 [Qemu-devel] [PATCH v2 00/28] Series short description Greg Kurz
2017-02-26 22:41 ` [Qemu-devel] [PATCH v2 01/28] 9pfs: local: move xattr security ops to 9p-xattr.c Greg Kurz
2017-02-26 22:41 ` [Qemu-devel] [PATCH v2 02/28] 9pfs: remove side-effects in local_init() Greg Kurz
2017-02-26 22:41 ` [Qemu-devel] [PATCH v2 03/28] 9pfs: remove side-effects in local_open() and local_opendir() Greg Kurz
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 04/28] 9pfs: introduce openat_nofollow() helper Greg Kurz
2017-02-27 12:44 ` Stefan Hajnoczi
2017-02-27 14:31 ` Greg Kurz
2017-02-27 15:32 ` Stefan Hajnoczi
2017-02-27 23:28 ` Eric Blake
2017-02-28 0:32 ` Greg Kurz
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 05/28] 9pfs: local: keep a file descriptor on the shared folder Greg Kurz
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 06/28] 9pfs: local: open/opendir: don't follow symlinks Greg Kurz
2017-02-27 12:49 ` Stefan Hajnoczi
2017-02-27 14:35 ` Greg Kurz
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 07/28] 9pfs: local: lgetxattr: " Greg Kurz
2017-02-27 12:58 ` Stefan Hajnoczi
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 08/28] 9pfs: local: llistxattr: " Greg Kurz
2017-02-27 13:08 ` Stefan Hajnoczi
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 09/28] 9pfs: local: lsetxattr: " Greg Kurz
2017-02-27 13:10 ` Stefan Hajnoczi
2017-02-26 22:42 ` [Qemu-devel] [PATCH v2 10/28] 9pfs: local: lremovexattr: " Greg Kurz
2017-02-27 13:12 ` Stefan Hajnoczi
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 11/28] 9pfs: local: unlinkat: " Greg Kurz
2017-02-27 13:14 ` Stefan Hajnoczi
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 12/28] 9pfs: local: remove: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 13/28] 9pfs: local: utimensat: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 14/28] 9pfs: local: statfs: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 15/28] 9pfs: local: truncate: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 16/28] 9pfs: local: readlink: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 17/28] 9pfs: local: lstat: " Greg Kurz
2017-02-26 22:43 ` [Qemu-devel] [PATCH v2 18/28] 9pfs: local: renameat: " Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 19/28] 9pfs: local: rename: use renameat Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 20/28] 9pfs: local: improve error handling in link op Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 21/28] 9pfs: local: link: don't follow symlinks Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 22/28] 9pfs: local: chmod: " Greg Kurz
2017-02-27 13:17 ` Stefan Hajnoczi
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 23/28] 9pfs: local: chown: " Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 24/28] 9pfs: local: symlink: " Greg Kurz
2017-02-26 22:44 ` [Qemu-devel] [PATCH v2 25/28] 9pfs: local: mknod: " Greg Kurz
2017-02-27 13:18 ` Stefan Hajnoczi
2017-02-26 22:45 ` [Qemu-devel] [PATCH v2 26/28] 9pfs: local: mkdir: " Greg Kurz
2017-02-26 22:45 ` [Qemu-devel] [PATCH v2 27/28] 9pfs: local: open2: " Greg Kurz
2017-02-27 13:18 ` Stefan Hajnoczi
2017-02-26 22:45 ` [Qemu-devel] [PATCH v2 28/28] 9pfs: local: drop unused code Greg Kurz
2017-02-26 23:45 ` Greg Kurz [this message]
2017-02-27 13:24 ` [Qemu-devel] [PATCH v2 00/28] Series short description Stefan Hajnoczi
2017-02-27 15:33 ` Stefan Hajnoczi
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=20170227004533.3fb25129@bahia.lan \
--to=groug@kaod.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=eblake@redhat.com \
--cc=jannh@google.com \
--cc=prasad@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).