yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-fail-when-parent-inode-isn-t-known-in-lo_d.patch

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