Patch "fuse: ioctl: translate ENOSYS" has been added to the 5.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    fuse: ioctl: translate ENOSYS

to the 5.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fuse-ioctl-translate-enosys.patch
and it can be found in the queue-5.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9a76a72661a15caa9ccd7884caa7f17bffb7a9ea
Author: Miklos Szeredi <mszeredi@xxxxxxxxxx>
Date:   Thu Jul 21 16:06:18 2022 +0200

    fuse: ioctl: translate ENOSYS
    
    [ Upstream commit 02c0cab8e7345b06f1c0838df444e2902e4138d3 ]
    
    Overlayfs may fail to complete updates when a filesystem lacks
    fileattr/xattr syscall support and responds with an ENOSYS error code,
    resulting in an unexpected "Function not implemented" error.
    
    This bug may occur with FUSE filesystems, such as davfs2.
    
    Steps to reproduce:
    
      # install davfs2, e.g., apk add davfs2
      mkdir /test mkdir /test/lower /test/upper /test/work /test/mnt
      yes '' | mount -t davfs -o ro http://some-web-dav-server/path \
        /test/lower
      mount -t overlay -o upperdir=/test/upper,lowerdir=/test/lower \
        -o workdir=/test/work overlay /test/mnt
    
      # when "some-file" exists in the lowerdir, this fails with "Function
      # not implemented", with dmesg showing "overlayfs: failed to retrieve
      # lower fileattr (/some-file, err=-38)"
      touch /test/mnt/some-file
    
    The underlying cause of this regresion is actually in FUSE, which fails to
    translate the ENOSYS error code returned by userspace filesystem (which
    means that the ioctl operation is not supported) to ENOTTY.
    
    Reported-by: Christian Kohlschütter <christian@xxxxxxxxxxxxxxxx>
    Fixes: 72db82115d2b ("ovl: copy up sync/noatime fileattr flags")
    Fixes: 59efec7b9039 ("fuse: implement ioctl support")
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index 33cde4bbccdc..61d8afcb10a3 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -9,6 +9,17 @@
 #include <linux/compat.h>
 #include <linux/fileattr.h>
 
+static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args)
+{
+	ssize_t ret = fuse_simple_request(fm, args);
+
+	/* Translate ENOSYS, which shouldn't be returned from fs */
+	if (ret == -ENOSYS)
+		ret = -ENOTTY;
+
+	return ret;
+}
+
 /*
  * CUSE servers compiled on 32bit broke on 64bit kernels because the
  * ABI was defined to be 'struct iovec' which is different on 32bit
@@ -259,7 +270,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 	ap.args.out_pages = true;
 	ap.args.out_argvar = true;
 
-	transferred = fuse_simple_request(fm, &ap.args);
+	transferred = fuse_send_ioctl(fm, &ap.args);
 	err = transferred;
 	if (transferred < 0)
 		goto out;
@@ -393,7 +404,7 @@ static int fuse_priv_ioctl(struct inode *inode, struct fuse_file *ff,
 	args.out_args[1].size = inarg.out_size;
 	args.out_args[1].value = ptr;
 
-	err = fuse_simple_request(fm, &args);
+	err = fuse_send_ioctl(fm, &args);
 	if (!err) {
 		if (outarg.result < 0)
 			err = outarg.result;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux