This is a note to let you know that I've just added the patch titled fuse: write inode in fuse_release() 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-write-inode-in-fuse_release.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. >From 035ff33cf4db101250fb980a3941bf078f37a544 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi <mszeredi@xxxxxxxxxx> Date: Wed, 20 Apr 2022 16:05:41 +0200 Subject: fuse: write inode in fuse_release() From: Miklos Szeredi <mszeredi@xxxxxxxxxx> commit 035ff33cf4db101250fb980a3941bf078f37a544 upstream. A race between write(2) and close(2) allows pages to be dirtied after fuse_flush -> write_inode_now(). If these pages are not flushed from fuse_release(), then there might not be a writable open file later. So any remaining dirty pages must be written back before the file is released. This is a partial revert of the blamed commit. Reported-by: syzbot+6e1efbd8efaaa6860e91@xxxxxxxxxxxxxxxxxxxxxxxxx Fixes: 36ea23374d1f ("fuse: write inode in fuse_vma_close() instead of fuse_release()") Cc: <stable@xxxxxxxxxxxxxxx> # v5.16 Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/fuse/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -338,6 +338,15 @@ static int fuse_open(struct inode *inode static int fuse_release(struct inode *inode, struct file *file) { + struct fuse_conn *fc = get_fuse_conn(inode); + + /* + * Dirty pages might remain despite write_inode_now() call from + * fuse_flush() due to writes racing with the close. + */ + if (fc->writeback_cache) + write_inode_now(inode, 1); + fuse_release_common(file, false); /* return value is ignored by VFS */ Patches currently in stable-queue which might be from mszeredi@xxxxxxxxxx are queue-5.19/fuse-write-inode-in-fuse_release.patch queue-5.19/ovl-drop-warn_on-dentry-is-null-in-ovl_encode_fh.patch queue-5.19/fuse-limit-nsec.patch queue-5.19/fuse-ioctl-translate-enosys.patch queue-5.19/fuse-fix-deadlock-between-atomic-o_trunc-and-page-invalidation.patch