thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
22c213
From feb005dfeb15dd5ac5156c994f323ab4c573b1fc Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Mon, 27 Jan 2020 19:01:24 +0100
22c213
Subject: [PATCH 053/116] virtiofsd: prevent ".." escape in 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-50-dgilbert@redhat.com>
22c213
Patchwork-id: 93500
22c213
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 049/112] virtiofsd: prevent ".." escape 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: Stefan Hajnoczi <stefanha@redhat.com>
22c213
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Reviewed-by: Sergio Lopez <slp@redhat.com>
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
(cherry picked from commit 854684bc0b3d63eb90b3abdfe471c2e4271ef176)
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
---
22c213
 tools/virtiofsd/passthrough_ll.c | 7 ++++++-
22c213
 1 file changed, 6 insertions(+), 1 deletion(-)
22c213
22c213
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
22c213
index e375406..79d5966 100644
22c213
--- a/tools/virtiofsd/passthrough_ll.c
22c213
+++ b/tools/virtiofsd/passthrough_ll.c
22c213
@@ -624,12 +624,17 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
22c213
     int res;
22c213
     int saverr;
22c213
     struct lo_data *lo = lo_data(req);
22c213
-    struct lo_inode *inode;
22c213
+    struct lo_inode *inode, *dir = lo_inode(req, parent);
22c213
 
22c213
     memset(e, 0, sizeof(*e));
22c213
     e->attr_timeout = lo->timeout;
22c213
     e->entry_timeout = lo->timeout;
22c213
 
22c213
+    /* Do not allow escaping root directory */
22c213
+    if (dir == &lo->root && strcmp(name, "..") == 0) {
22c213
+        name = ".";
22c213
+    }
22c213
+
22c213
     newfd = openat(lo_fd(req, parent), name, O_PATH | O_NOFOLLOW);
22c213
     if (newfd == -1) {
22c213
         goto out_err;
22c213
-- 
22c213
1.8.3.1
22c213