]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
fuse: truncate pagecache on atomic_o_trunc
authorMiklos Szeredi <mszeredi@redhat.com>
Tue, 17 Aug 2021 19:05:16 +0000 (21:05 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 15 Oct 2021 09:27:38 +0000 (11:27 +0200)
commit8e41cbb567d0d4989864bb0a67fcd1a9ad241736
tree1375b3e5b19c706d8448444c7b5f3a72764658f9
parent3ebf3b5aa6fd61afd94fff2b416160b47ad483e7
fuse: truncate pagecache on atomic_o_trunc

BugLink: https://bugs.launchpad.net/bugs/1946788
commit 76224355db7570cbe6b6f75c8929a1558828dd55 upstream.

fuse_finish_open() will be called with FUSE_NOWRITE in case of atomic
O_TRUNC.  This can deadlock with fuse_wait_on_page_writeback() in
fuse_launder_page() triggered by invalidate_inode_pages2().

Fix by replacing invalidate_inode_pages2() in fuse_finish_open() with a
truncate_pagecache() call.  This makes sense regardless of FOPEN_KEEP_CACHE
or fc->writeback cache, so do it unconditionally.

Reported-by: Xie Yongji <xieyongji@bytedance.com>
Reported-and-tested-by: syzbot+bea44a5189836d956894@syzkaller.appspotmail.com
Fixes: e4648309b85a ("fuse: truncate pending writes on O_TRUNC")
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: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/fuse/file.c