[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/25] virtiofsd: prevent ".." escape in lo_do_lookup()
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 13/25] virtiofsd: prevent ".." escape in lo_do_lookup() |
Date: |
Thu, 24 Oct 2019 12:27:06 +0100 |
From: Stefan Hajnoczi <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
contrib/virtiofsd/passthrough_ll.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/virtiofsd/passthrough_ll.c
b/contrib/virtiofsd/passthrough_ll.c
index 702fedc38a..7a61bf94fe 100644
--- a/contrib/virtiofsd/passthrough_ll.c
+++ b/contrib/virtiofsd/passthrough_ll.c
@@ -606,12 +606,17 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t
parent, const char *name,
int res;
int saverr;
struct lo_data *lo = lo_data(req);
- struct lo_inode *inode;
+ struct lo_inode *inode, *dir = lo_inode(req, parent);
memset(e, 0, sizeof(*e));
e->attr_timeout = lo->timeout;
e->entry_timeout = lo->timeout;
+ /* Do not allow escaping root directory */
+ if (dir == &lo->root && strcmp(name, "..") == 0) {
+ name = ".";
+ }
+
newfd = openat(lo_fd(req, parent), name, O_PATH | O_NOFOLLOW);
if (newfd == -1)
goto out_err;
--
2.23.0
- [PATCH 03/25] virtiofsd: passthrough_ll: add ino_map to hide lo_inode pointers, (continued)
- [PATCH 03/25] virtiofsd: passthrough_ll: add ino_map to hide lo_inode pointers, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 05/25] virtiofsd: passthrough_ll: add fd_map to hide file descriptors, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 07/25] virtiofsd: validate path components, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 06/25] virtiofsd: passthrough_ll: add fallback for racy ops, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 08/25] virtiofsd: Plumb fuse_bufvec through to do_write_buf, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 09/25] virtiofsd: Pass write iov's all the way through, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 10/25] virtiofsd: add fuse_mbuf_iter API, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 11/25] virtiofsd: validate input buffer sizes in do_write_buf(), Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 12/25] virtiofsd: check input buffer size in fuse_lowlevel.c ops, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 15/25] virtiofsd: use /proc/self/fd/ O_PATH file descriptor, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 13/25] virtiofsd: prevent ".." escape in lo_do_lookup(),
Dr. David Alan Gilbert (git) <=
- [PATCH 14/25] virtiofsd: prevent ".." escape in lo_do_readdir(), Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 16/25] virtiofsd: sandbox mount namespace, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 17/25] virtiofsd: move to an empty network namespace, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 18/25] virtiofsd: move to a new pid namespace, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 19/25] virtiofsd: add seccomp whitelist, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 20/25] virtiofsd: Parse flag FUSE_WRITE_KILL_PRIV, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 21/25] virtiofsd: Drop CAP_FSETID if client asked for it, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 22/25] virtiofsd: set maximum RLIMIT_NOFILE limit, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 23/25] virtiofsd: add security guide document, Dr. David Alan Gilbert (git), 2019/10/24
- [PATCH 24/25] virtiofsd: add --syslog command-line option, Dr. David Alan Gilbert (git), 2019/10/24