From 2a766e391245f9d5e5dc4362e6bf4731b8923b16 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 16:44:05 +0100 Subject: [PATCH 1/6] main: use full path to detect existing node Closes: https://github.com/containers/fuse-overlayfs/issues/333 Signed-off-by: Giuseppe Scrivano --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 92dbc84..120cf1f 100644 --- a/main.c +++ b/main.c @@ -1195,7 +1195,7 @@ register_inode (struct ovl_data *lo, struct ovl_node *n, mode_t mode) for (it = ino->node; it; it = it->next_link) { - if (n->parent == it->parent && node_compare (n, it)) + if (node_dirp (it) || strcmp (n->path, it->path) == 0) { node_free (n); return it; From 59816ac69d9f836438801825fd31b0c9077bc790 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 17:03:14 +0100 Subject: [PATCH 2/6] main: always lookup the parent directory Signed-off-by: Giuseppe Scrivano --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 120cf1f..bb94a0c 100644 --- a/main.c +++ b/main.c @@ -4465,6 +4465,13 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name, struct ovl_node key; bool destnode_is_whiteout = false; + pnode = do_lookup_file (lo, parent, NULL); + if (pnode == NULL || pnode->whiteout) + { + fuse_reply_err (req, ENOENT); + return; + } + node = do_lookup_file (lo, parent, name); if (node == NULL || node->whiteout) { @@ -4487,7 +4494,6 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name, return; } } - pnode = node->parent; destpnode = do_lookup_file (lo, newparent, NULL); destnode = NULL; @@ -4527,6 +4533,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name, { size_t destnode_whiteouts = 0; + errno = EINVAL; if (!destnode->whiteout && destnode->tmp_ino == node->tmp_ino && destnode->tmp_dev == node->tmp_dev) goto error; From 6d4dbb88fcce8fa7b35ca3808e6f9a31d791ea8f Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 17:03:45 +0100 Subject: [PATCH 3/6] main: fix code style Signed-off-by: Giuseppe Scrivano --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index bb94a0c..3827ed7 100644 --- a/main.c +++ b/main.c @@ -1077,7 +1077,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src) // if the parent directory is opaque, there's no need to put a whiteout in it. if (node->parent != NULL) - needs_whiteout = needs_whiteout && (is_directory_opaque(get_upper_layer(lo), node->parent->path) < 1); + needs_whiteout = needs_whiteout && (is_directory_opaque (get_upper_layer(lo), node->parent->path) < 1); if (needs_whiteout) { From 0476f8464b65da1c6eab77888dbee30cce372c97 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 17:49:44 +0100 Subject: [PATCH 4/6] main: fix type for ioctl fuse_reply_ioctl expects a int. Closes: https://github.com/containers/fuse-overlayfs/issues/330 Signed-off-by: Giuseppe Scrivano --- main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 3827ed7..e2bd46f 100644 --- a/main.c +++ b/main.c @@ -5131,12 +5131,6 @@ ovl_fsyncdir (fuse_req_t req, fuse_ino_t ino, int datasync, struct fuse_file_inf return do_fsync (req, ino, datasync, -1); } -static int -direct_ioctl (struct ovl_layer *l, int fd, int cmd, unsigned long *r) -{ - return ioctl (fd, cmd, &r); -} - static void ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi, unsigned int flags, @@ -5147,7 +5141,7 @@ ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, cleanup_close int cleaned_fd = -1; struct ovl_node *node; int fd = -1; - unsigned long r; + int r = 0; if (flags & FUSE_IOCTL_COMPAT) { @@ -5203,7 +5197,7 @@ ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, l = release_big_lock (); - if (direct_ioctl (node->layer, fd, cmd, &r) < 0) + if (ioctl (fd, cmd, &r, sizeof (r)) < 0) fuse_reply_err (req, errno); else fuse_reply_ioctl (req, 0, &r, out_bufsz ? sizeof (r) : 0); From 87fca95f570cfce4226bf9a2d253c43b0e00cf58 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 17:53:42 +0100 Subject: [PATCH 5/6] NEWS: tag 1.8.1 Signed-off-by: Giuseppe Scrivano --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 77fd5fb..a9776b5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +* fuse-overlayfs-1.8.1 + +- main: fix race when looking up an inode that was renamed. +- main: fix type used for ioctl. + * fuse-overlayfs-1.8 - main: honor user.overlay. xattrs. Native overlay uses user.overlay diff --git a/configure.ac b/configure.ac index 993d52d..3027728 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([fuse-overlayfs], [1.9-dev], [giuseppe@scrivano.org]) +AC_INIT([fuse-overlayfs], [1.8.1], [giuseppe@scrivano.org]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h]) From 551eb8cf123f1d5a35d0b357961bf4df180db23e Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 17 Jan 2022 17:53:58 +0100 Subject: [PATCH 6/6] configure.ac: go back to dev Signed-off-by: Giuseppe Scrivano --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3027728..993d52d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([fuse-overlayfs], [1.8.1], [giuseppe@scrivano.org]) +AC_INIT([fuse-overlayfs], [1.9-dev], [giuseppe@scrivano.org]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h])