From 0087bbc85f4f0c4e430becc53fde4b4ab363305b Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 21 Jun 2021 15:17:56 +0200 Subject: [PATCH 1/5] .github: fix tests Signed-off-by: Giuseppe Scrivano --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 823b903..d2bbc0e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -64,7 +64,6 @@ jobs: sudo mkdir -p /lower /upper /mnt sudo sh -c "(cd /; git clone https://github.com/amir73il/unionmount-testsuite.git)" sudo go get github.com/containers/storage - sudo GOPATH=$GOPATH sh -c "(cd /root/go/src/github.com/containers/storage; make tests/tools/build/ffjson; cp tests/tools/build/ffjson /usr/bin)" sudo GOPATH=$GOPATH sh -c "(cd /root/go/src/github.com/containers/storage; sed -i -e 's|^AUTOTAGS.*$|AUTOTAGS := exclude_graphdriver_devicemapper exclude_graphdriver_btrfs|' Makefile; make GO111MODULE=on containers-storage)" - name: run autogen.sh From f41a872e0de9747baf1a209af8c98ce8af1698e6 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 21 Jun 2021 15:09:43 +0200 Subject: [PATCH 2/5] main: fix invalid access when filtering xattrs Fix an invalid access when filtering internal xattrs. The size passed to memmove was longer than the remaining bytes to process. As part of the fix: move the filtering logic to a separate function. Closes: https://github.com/containers/fuse-overlayfs/issues/293 Signed-off-by: Giuseppe Scrivano --- main.c | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/main.c b/main.c index 2b04262..b448d9b 100644 --- a/main.c +++ b/main.c @@ -2474,6 +2474,42 @@ ovl_releasedir (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) fuse_reply_err (req, 0); } +/* in-place filter xattrs that cannot be accessed. */ +static ssize_t +filter_xattrs_list (char *buf, ssize_t len) +{ + ssize_t ret = 0; + size_t i = 0; + char *it; + + if (buf == NULL) + return len; + + it = buf; + + while (it < buf + len) + { + size_t it_len; + + it_len = strlen (it) + 1; + + if (can_access_xattr (it)) + { + it += it_len; + ret += it_len; + } + else + { + char *next = it + it_len; + + memmove (it, next, buf + len - next); + len -= it_len; + } + } + + return ret; +} + static void ovl_listxattr (fuse_req_t req, fuse_ino_t ino, size_t size) { @@ -2525,22 +2561,7 @@ ovl_listxattr (fuse_req_t req, fuse_ino_t ino, size_t size) return; } - len = ret; - - for (i = 0; buf && i < len;) - { - size_t current_len; - const char *cur_attr = buf + i; - - current_len = strlen (cur_attr) + 1; - if (can_access_xattr (cur_attr)) - i += current_len; - else - { - memmove (buf + i, cur_attr + current_len, len - current_len); - len -= current_len; - } - } + len = filter_xattrs_list (buf, ret); if (size == 0) fuse_reply_xattr (req, len); From 12552f315f959c71d677c29fa6426267e6b6e4f5 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 21 Jun 2021 15:11:25 +0200 Subject: [PATCH 3/5] main: check for parent->children before accessing it this should not happen, but better be sure. Signed-off-by: Giuseppe Scrivano --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index b448d9b..e89c51a 100644 --- a/main.c +++ b/main.c @@ -944,7 +944,7 @@ node_free (void *p) if (n->parent) { - if (hash_lookup (n->parent->children, n) == n) + if (n->parent->children && hash_lookup (n->parent->children, n) == n) hash_delete (n->parent->children, n); n->parent->loaded = 0; n->parent = NULL; From c0e6cca6c7e86fda365fac20c74b3f828a666657 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 21 Jun 2021 15:12:32 +0200 Subject: [PATCH 4/5] NEWS: tag 1.6 Signed-off-by: Giuseppe Scrivano --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d65920b..7e473f4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +* fuse-overlayfs-1.6 + +- fix an invalid access when filtering internal xattrs that could + deal to a segfault. + * fuse-overlayfs-1.5 - honor FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT also for renames diff --git a/configure.ac b/configure.ac index 04c2e7e..3e63c97 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([fuse-overlayfs], [1.6-dev], [giuseppe@scrivano.org]) +AC_INIT([fuse-overlayfs], [1.6], [giuseppe@scrivano.org]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h]) From 853f83d0b266194d379b4e22bfa00b8b20f5de3e Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 21 Jun 2021 15:12:46 +0200 Subject: [PATCH 5/5] configure.ac: prepare next release Signed-off-by: Giuseppe Scrivano --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3e63c97..a551ed8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([fuse-overlayfs], [1.6], [giuseppe@scrivano.org]) +AC_INIT([fuse-overlayfs], [1.7-dev], [giuseppe@scrivano.org]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h])