From 4ad759b35a054b6010b348755921977a9dcf6e0e Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 28 Jul 2021 13:03:53 +0200 Subject: [PATCH 1/2] fuse-overlayfs: fix read xattrs for devices always use llistxattr and lgetxattr for listing and reading xattrs so that the open/openat2 call doesn't fail when accessing a device. Closes: https://github.com/containers/fuse-overlayfs/issues/312 Signed-off-by: Giuseppe Scrivano --- direct.c | 20 ++------------------ tests/fedora-installs.sh | 3 +++ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/direct.c b/direct.c index ac013b8..6eba043 100644 --- a/direct.c +++ b/direct.c @@ -43,17 +43,9 @@ direct_file_exists (struct ovl_layer *l, const char *pathname) static int direct_listxattr (struct ovl_layer *l, const char *path, char *buf, size_t size) { - cleanup_close int fd = -1; char full_path[PATH_MAX]; - int ret; - full_path[0] = '\0'; - ret = open_fd_or_get_path (l, path, full_path, &fd, O_RDONLY); - if (ret < 0) - return ret; - - if (fd >= 0) - return flistxattr (fd, buf, size); + strconcat3 (full_path, PATH_MAX, l->path, "/", path); return llistxattr (full_path, buf, size); } @@ -61,17 +53,9 @@ direct_listxattr (struct ovl_layer *l, const char *path, char *buf, size_t size) static int direct_getxattr (struct ovl_layer *l, const char *path, const char *name, char *buf, size_t size) { - cleanup_close int fd = -1; char full_path[PATH_MAX]; - int ret; - full_path[0] = '\0'; - ret = open_fd_or_get_path (l, path, full_path, &fd, O_RDONLY); - if (ret < 0) - return ret; - - if (fd >= 0) - return fgetxattr (fd, name, buf, size); + strconcat3 (full_path, PATH_MAX, l->path, "/", path); return lgetxattr (full_path, name, buf, size); } diff --git a/tests/fedora-installs.sh b/tests/fedora-installs.sh index d9a1730..3d746a5 100755 --- a/tests/fedora-installs.sh +++ b/tests/fedora-installs.sh @@ -246,5 +246,8 @@ mkdir -p merged/a/b rm -rf merged/a/b test \! -e upper/a/b +mknod merged/dev-foo c 10 175 +attr -l merged/dev-foo + umount merged From 79f885bc7b713cb69ebe6a96da216b73e8412469 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 28 Jul 2021 14:37:18 +0200 Subject: [PATCH 2/2] tests: fix race condition Signed-off-by: Giuseppe Scrivano --- tests/fedora-installs.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/fedora-installs.sh b/tests/fedora-installs.sh index 3d746a5..0039bc0 100755 --- a/tests/fedora-installs.sh +++ b/tests/fedora-installs.sh @@ -204,8 +204,9 @@ fi touch merged/$(printf %${merged_max_filename_len}s | tr ' ' A}) # If a file is removed but referenced, we must still be able to access it. -echo 12345 > merged/toremove -sleep 30 < merged/toremove & +echo 12345 | tee merged/toremove +cat merged/toremove +sleep 90 < merged/toremove & sleep_pid=$! rm merged/toremove grep 12345 /proc/$sleep_pid/fd/0