qemu/tools/virtiofsd
Stefan Hajnoczi a3fdbbc7f2 virtiofsd: prevent opening of special files (CVE-2020-35517)
A well-behaved FUSE client does not attempt to open special files with
FUSE_OPEN because they are handled on the client side (e.g. device nodes
are handled by client-side device drivers).

The check to prevent virtiofsd from opening special files is missing in
a few cases, most notably FUSE_OPEN. A malicious client can cause
virtiofsd to open a device node, potentially allowing the guest to
escape. This can be exploited by a modified guest device driver. It is
not exploitable from guest userspace since the guest kernel will handle
special files inside the guest instead of sending FUSE requests.

This patch fixes this issue by introducing the lo_inode_open() function
to check the file type before opening it. This is a short-term solution
because it does not prevent a compromised virtiofsd process from opening
device nodes on the host.

Restructure lo_create() to try O_CREAT | O_EXCL first. Note that O_CREAT
| O_EXCL does not follow symlinks, so O_NOFOLLOW masking is not
necessary here. If the file exists and the user did not specify O_EXCL,
open it via lo_do_open().

Reported-by: Alex Xu <alex@alxu.ca>
Fixes: CVE-2020-35517
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210204150208.367837-4-stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2021-02-04 17:34:55 +00:00
..
50-qemu-virtiofsd.json.in virtiofsd: add vhost-user.json file 2020-01-23 16:41:36 +00:00
buffer.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_common.h virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON 2020-12-15 12:52:10 -05:00
fuse_i.h tools/virtiofsd: add support for --socket-group 2020-10-12 12:39:38 +01:00
fuse_log.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_log.h Clean up includes 2020-12-10 17:16:44 +01:00
fuse_lowlevel.c virtiofsd: Remove useless code about send_notify_iov 2020-12-18 10:08:24 +00:00
fuse_lowlevel.h Clean up includes 2020-12-10 17:16:44 +01:00
fuse_misc.h Clean up includes 2020-12-10 17:16:44 +01:00
fuse_opt.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_opt.h virtiofsd: Format imported files to qemu style 2020-01-23 16:41:36 +00:00
fuse_signals.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_virtio.c virtiofsd: Use --thread-pool-size=0 to mean no thread pool 2020-12-18 10:08:24 +00:00
fuse_virtio.h virtiofsd: cleanup allocated resource in se 2020-01-23 16:41:37 +00:00
helper.c Clean up includes 2020-12-10 17:16:44 +01:00
meson.build libvhost-user: make it a meson subproject 2020-12-08 13:48:58 -05:00
passthrough_helpers.h virtiofsd: Format imported files to qemu style 2020-01-23 16:41:36 +00:00
passthrough_ll.c virtiofsd: prevent opening of special files (CVE-2020-35517) 2021-02-04 17:34:55 +00:00
passthrough_seccomp.c Clean up includes 2020-12-10 17:16:44 +01:00
passthrough_seccomp.h Clean up includes 2020-12-10 17:16:44 +01:00