|
|
22c213 |
From b3cd18ab58e331d3610cf00f857d6a945f11a030 Mon Sep 17 00:00:00 2001
|
|
|
22c213 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
22c213 |
Date: Mon, 27 Jan 2020 19:01:49 +0100
|
|
|
22c213 |
Subject: [PATCH 078/116] virtiofsd: fail when parent inode isn't known in
|
|
|
22c213 |
lo_do_lookup()
|
|
|
22c213 |
MIME-Version: 1.0
|
|
|
22c213 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c213 |
Content-Transfer-Encoding: 8bit
|
|
|
22c213 |
|
|
|
22c213 |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
22c213 |
Message-id: <20200127190227.40942-75-dgilbert@redhat.com>
|
|
|
22c213 |
Patchwork-id: 93529
|
|
|
22c213 |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 074/112] virtiofsd: fail when parent inode isn't known in lo_do_lookup()
|
|
|
22c213 |
Bugzilla: 1694164
|
|
|
22c213 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
22c213 |
|
|
|
22c213 |
From: Miklos Szeredi <mszeredi@redhat.com>
|
|
|
22c213 |
|
|
|
22c213 |
The Linux file handle APIs (struct export_operations) can access inodes
|
|
|
22c213 |
that are not attached to parents because path name traversal is not
|
|
|
22c213 |
performed. Refuse if there is no parent in lo_do_lookup().
|
|
|
22c213 |
|
|
|
22c213 |
Also clean up lo_do_lookup() while we're here.
|
|
|
22c213 |
|
|
|
22c213 |
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
|
|
|
22c213 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
22c213 |
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
|
|
|
22c213 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
22c213 |
(cherry picked from commit 9de4fab5995d115f8ebfb41d8d94a866d80a1708)
|
|
|
22c213 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
22c213 |
---
|
|
|
22c213 |
tools/virtiofsd/passthrough_ll.c | 14 ++++++++++++--
|
|
|
22c213 |
1 file changed, 12 insertions(+), 2 deletions(-)
|
|
|
22c213 |
|
|
|
22c213 |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
22c213 |
index de12e75..33bfb4d 100644
|
|
|
22c213 |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
22c213 |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
22c213 |
@@ -777,6 +777,15 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
|
|
22c213 |
struct lo_data *lo = lo_data(req);
|
|
|
22c213 |
struct lo_inode *inode, *dir = lo_inode(req, parent);
|
|
|
22c213 |
|
|
|
22c213 |
+ /*
|
|
|
22c213 |
+ * name_to_handle_at() and open_by_handle_at() can reach here with fuse
|
|
|
22c213 |
+ * mount point in guest, but we don't have its inode info in the
|
|
|
22c213 |
+ * ino_map.
|
|
|
22c213 |
+ */
|
|
|
22c213 |
+ if (!dir) {
|
|
|
22c213 |
+ return ENOENT;
|
|
|
22c213 |
+ }
|
|
|
22c213 |
+
|
|
|
22c213 |
memset(e, 0, sizeof(*e));
|
|
|
22c213 |
e->attr_timeout = lo->timeout;
|
|
|
22c213 |
e->entry_timeout = lo->timeout;
|
|
|
22c213 |
@@ -786,7 +795,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
|
|
22c213 |
name = ".";
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
- newfd = openat(lo_fd(req, parent), name, O_PATH | O_NOFOLLOW);
|
|
|
22c213 |
+ newfd = openat(dir->fd, name, O_PATH | O_NOFOLLOW);
|
|
|
22c213 |
if (newfd == -1) {
|
|
|
22c213 |
goto out_err;
|
|
|
22c213 |
}
|
|
|
22c213 |
@@ -796,7 +805,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
|
|
22c213 |
goto out_err;
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
- inode = lo_find(lo_data(req), &e->attr);
|
|
|
22c213 |
+ inode = lo_find(lo, &e->attr);
|
|
|
22c213 |
if (inode) {
|
|
|
22c213 |
close(newfd);
|
|
|
22c213 |
newfd = -1;
|
|
|
22c213 |
@@ -812,6 +821,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
|
|
22c213 |
inode->is_symlink = S_ISLNK(e->attr.st_mode);
|
|
|
22c213 |
inode->refcount = 1;
|
|
|
22c213 |
inode->fd = newfd;
|
|
|
22c213 |
+ newfd = -1;
|
|
|
22c213 |
inode->ino = e->attr.st_ino;
|
|
|
22c213 |
inode->dev = e->attr.st_dev;
|
|
|
22c213 |
|
|
|
22c213 |
--
|
|
|
22c213 |
1.8.3.1
|
|
|
22c213 |
|