linux-stable/fs/fuse
Miklos Szeredi ca62747b38 fuse: fix pipe buffer lifetime for direct_io
commit 0c4bcfdecb 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.

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>
2022-03-16 14:23:42 +01:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
control.c fuse: name fs_context consistently 2021-08-04 13:22:58 +02:00
cuse.c cuse: simplify refcount 2021-04-14 10:40:58 +02:00
dax.c \n 2021-08-30 10:24:50 -07:00
dev.c fuse: fix pipe buffer lifetime for direct_io 2022-03-16 14:23:42 +01:00
dir.c fuse: annotate lock in fuse_reverse_inval_entry() 2021-12-22 09:32:50 +01:00
file.c fuse: fix pipe buffer lifetime for direct_io 2022-03-16 14:23:42 +01:00
fuse_i.h fuse: fix pipe buffer lifetime for direct_io 2022-03-16 14:23:42 +01:00
inode.c fuse: make sure reclaim doesn't write the inode 2021-12-17 10:30:16 +01:00
ioctl.c fuse: fix fileattr op failure 2022-03-16 14:23:42 +01:00
Kconfig virtiofs: implement dax read/write operations 2020-09-10 11:39:23 +02:00
Makefile fuse: move ioctl to separate source file 2021-04-12 15:04:30 +02:00
readdir.c fuse: fix illegal access to inode with reused nodeid 2021-06-22 09:15:36 +02:00
virtio_fs.c fuse: clean up fuse_mount destruction 2021-10-21 10:01:39 +02:00
xattr.c fuse: extend FUSE_SETXATTR request 2021-04-14 10:40:57 +02:00