linux-stable/fs/fuse
Miklos Szeredi b160dbd123 fuse: fix readdir cache race
commit 9fa248c65b upstream.

There's a race in fuse's readdir cache that can result in an uninitilized
page being read.  The page lock is supposed to prevent this from happening
but in the following case it doesn't:

Two fuse_add_dirent_to_cache() start out and get the same parameters
(size=0,offset=0).  One of them wins the race to create and lock the page,
after which it fills in data, sets rdc.size and unlocks the page.

In the meantime the page gets evicted from the cache before the other
instance gets to run.  That one also creates the page, but finds the
size to be mismatched, bails out and leaves the uninitialized page in the
cache.

Fix by marking a filled page uptodate and ignoring non-uptodate pages.

Reported-by: Frank Sorenson <fsorenso@redhat.com>
Fixes: 5d7bc7e868 ("fuse: allow using readdir cache")
Cc: <stable@vger.kernel.org> # v4.20
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-10 18:17:34 +01:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
control.c fuse: Remove the control interface for virtio-fs 2022-07-21 16:06:19 +02:00
cuse.c cuse: simplify refcount 2021-04-14 10:40:58 +02:00
dax.c fuse: avoid unnecessary spinlock bump 2022-07-21 16:02:45 +02:00
dev.c iov_iter: advancing variants of iov_iter_get_pages{,_alloc}() 2022-08-08 22:37:22 -04:00
dir.c fuse: Add module param for CAP_SYS_ADMIN access bypassing allow_other 2022-07-21 16:06:19 +02:00
file.c fuse: add file_modified() to fallocate 2022-11-10 18:17:33 +01:00
fuse_i.h fs: Remove ->readpages address space operation 2022-04-01 13:45:33 -04:00
inode.c fuse: retire block-device-based superblock on force unmount 2022-07-27 11:30:31 +02:00
ioctl.c fuse: ioctl: translate ENOSYS 2022-07-21 16:06:18 +02:00
Kconfig dax: remove CONFIG_DAX_DRIVER 2021-12-04 08:58:51 -08:00
Makefile fuse: move ioctl to separate source file 2021-04-12 15:04:30 +02:00
readdir.c fuse: fix readdir cache race 2022-11-10 18:17:34 +01:00
virtio_fs.c virtio_fs: Modify format for virtio_fs_direct_access 2022-07-26 10:38:58 +02:00
xattr.c fuse: move fuse_invalidate_attr() into fuse_update_ctime() 2021-10-22 17:03:01 +02:00