|
|
ddf19c |
From feb005dfeb15dd5ac5156c994f323ab4c573b1fc Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
ddf19c |
Date: Mon, 27 Jan 2020 19:01:24 +0100
|
|
|
ddf19c |
Subject: [PATCH 053/116] virtiofsd: prevent ".." escape in lo_do_lookup()
|
|
|
ddf19c |
MIME-Version: 1.0
|
|
|
ddf19c |
Content-Type: text/plain; charset=UTF-8
|
|
|
ddf19c |
Content-Transfer-Encoding: 8bit
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
Message-id: <20200127190227.40942-50-dgilbert@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93500
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 049/112] virtiofsd: prevent ".." escape in lo_do_lookup()
|
|
|
ddf19c |
Bugzilla: 1694164
|
|
|
ddf19c |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Sergio Lopez <slp@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 854684bc0b3d63eb90b3abdfe471c2e4271ef176)
|
|
|
ddf19c |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
tools/virtiofsd/passthrough_ll.c | 7 ++++++-
|
|
|
ddf19c |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
ddf19c |
index e375406..79d5966 100644
|
|
|
ddf19c |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
ddf19c |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
ddf19c |
@@ -624,12 +624,17 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
|
|
ddf19c |
int res;
|
|
|
ddf19c |
int saverr;
|
|
|
ddf19c |
struct lo_data *lo = lo_data(req);
|
|
|
ddf19c |
- struct lo_inode *inode;
|
|
|
ddf19c |
+ struct lo_inode *inode, *dir = lo_inode(req, parent);
|
|
|
ddf19c |
|
|
|
ddf19c |
memset(e, 0, sizeof(*e));
|
|
|
ddf19c |
e->attr_timeout = lo->timeout;
|
|
|
ddf19c |
e->entry_timeout = lo->timeout;
|
|
|
ddf19c |
|
|
|
ddf19c |
+ /* Do not allow escaping root directory */
|
|
|
ddf19c |
+ if (dir == &lo->root && strcmp(name, "..") == 0) {
|
|
|
ddf19c |
+ name = ".";
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
newfd = openat(lo_fd(req, parent), name, O_PATH | O_NOFOLLOW);
|
|
|
ddf19c |
if (newfd == -1) {
|
|
|
ddf19c |
goto out_err;
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|