linux-stable/fs/fuse
Miklos Szeredi 0ab55e14cf 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: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-20 09:08:08 +02:00
..
acl.c fuse: fix bad inode 2022-01-27 09:01:01 +01:00
control.c fuse: use READ_ONCE on congestion_threshold and max_background 2019-11-20 18:00:52 +01:00
cuse.c cuse: prevent clone 2021-05-22 10:57:36 +02:00
dev.c fuse: fix pipe buffer lifetime for direct_io 2022-04-20 09:08:08 +02:00
dir.c fuse: fix bad inode 2022-01-27 09:01:01 +01:00
file.c fuse: fix pipe buffer lifetime for direct_io 2022-04-20 09:08:08 +02:00
fuse_i.h fuse: fix pipe buffer lifetime for direct_io 2022-04-20 09:08:08 +02:00
inode.c fuse: fix bad inode 2022-01-27 09:01:01 +01:00
Kconfig fuse: Add posix ACL support 2016-10-01 07:32:32 +02:00
Makefile fuse: Use generic xattr ops 2016-10-01 07:32:32 +02:00
xattr.c fuse: fix bad inode 2022-01-27 09:01:01 +01:00