OrangePi_CM5/fs/fuse
Miklos Szeredi 24d464d38b BACKPORT: fuse: fix pipe buffer lifetime for direct_io
commit 0c4bcfdecb1ac0967619ee7ff44871d93c08c909 upstream.

In FOPEN_DIRECT_IO mode, fuse_file_write_iter() calls
fuse_direct_write_iter(), which normally calls fuse_direct_io(), which then
imports the write buffer with fuse_get_user_pages(), which uses
iov_iter_get_pages() to grab references to userspace pages instead of
actually copying memory.

On the filesystem device side, these pages can then either be read to
userspace (via fuse_dev_read()), or splice()d over into a pipe using
fuse_dev_splice_read() as pipe buffers with &nosteal_pipe_buf_ops.

This is wrong because after fuse_dev_do_read() unlocks the FUSE request,
the userspace filesystem can mark the request as completed, causing write()
to return. At that point, the userspace filesystem should no longer have
access to the pipe buffer.

Fix by copying pages coming from the user address space to new pipe
buffers.

Bug: 226679409
Reported-by: Jann Horn <jannh@google.com>
Fixes: c3021629a0 ("fuse: support splice() reading from fuse device")
Cc: <stable@vger.kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: I57a98e96e36bb97ce3e7b1ebf88917c6c8b0247d
2022-04-28 11:33:22 +00:00
..
Kconfig
Makefile FROMLIST: fuse: Definitions and ioctl for passthrough 2021-01-26 17:20:09 +00:00
acl.c fuse: fix bad inode 2021-01-09 13:46:24 +01:00
control.c
cuse.c cuse: prevent clone 2021-05-19 10:12:56 +02:00
dax.c
dev.c BACKPORT: fuse: fix pipe buffer lifetime for direct_io 2022-04-28 11:33:22 +00:00
dir.c This is the 5.10.88 stable release 2021-12-22 10:12:32 +01:00
file.c BACKPORT: fuse: fix pipe buffer lifetime for direct_io 2022-04-28 11:33:22 +00:00
fuse_i.h BACKPORT: fuse: fix pipe buffer lifetime for direct_io 2022-04-28 11:33:22 +00:00
inode.c Merge branch 'android12-5.10' into `android12-5.10-lts` 2022-01-17 18:47:02 +01:00
passthrough.c ANDROID: fs/fuse: Keep FUSE file times consistent with lower file 2021-09-24 13:30:08 +00:00
readdir.c fuse: fix illegal access to inode with reused nodeid 2021-09-08 08:49:02 +02:00
virtio_fs.c virtiofs: fix userns 2021-05-19 10:12:56 +02:00
xattr.c Merge 5.10.6 into android12-5.10 2021-01-13 10:28:55 +01:00