cryptospore / rpms / qemu-kvm

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