[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 045/109] virtiofsd: prevent ".." escape in lo_do_lookup()
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH v2 045/109] virtiofsd: prevent ".." escape in lo_do_lookup() |
Date: |
Tue, 21 Jan 2020 12:23:29 +0000 |
From: Stefan Hajnoczi <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Sergio Lopez <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 3aa26b4255..6975417949 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -623,12 +623,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.24.1
- [PATCH v2 034/109] virtiofsd: passthrough_ll: add lo_map for ino/fh indirection, (continued)
- [PATCH v2 034/109] virtiofsd: passthrough_ll: add lo_map for ino/fh indirection, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 035/109] virtiofsd: passthrough_ll: add ino_map to hide lo_inode pointers, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 036/109] virtiofsd: passthrough_ll: add dirp_map to hide lo_dirp pointers, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 037/109] virtiofsd: passthrough_ll: add fd_map to hide file descriptors, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 038/109] virtiofsd: passthrough_ll: add fallback for racy ops, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 039/109] virtiofsd: validate path components, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 040/109] virtiofsd: Plumb fuse_bufvec through to do_write_buf, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 041/109] virtiofsd: Pass write iov's all the way through, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 042/109] virtiofsd: add fuse_mbuf_iter API, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 043/109] virtiofsd: validate input buffer sizes in do_write_buf(), Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 045/109] virtiofsd: prevent ".." escape in lo_do_lookup(),
Dr. David Alan Gilbert (git) <=
- [PATCH v2 044/109] virtiofsd: check input buffer size in fuse_lowlevel.c ops, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 046/109] virtiofsd: prevent ".." escape in lo_do_readdir(), Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 047/109] virtiofsd: use /proc/self/fd/ O_PATH file descriptor, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 048/109] virtiofsd: sandbox mount namespace, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 049/109] virtiofsd: move to an empty network namespace, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 051/109] virtiofsd: add seccomp whitelist, Dr. David Alan Gilbert (git), 2020/01/21
- Re: [PATCH v2 051/109] virtiofsd: add seccomp whitelist, Florian Weimer, 2020/01/24