linux/fs/netfs
David Howells f89ea63f1c
netfs, 9p: Fix race between umount and async request completion
There's a problem in 9p's interaction with netfslib whereby a crash occurs
because the 9p_fid structs get forcibly destroyed during client teardown
(without paying attention to their refcounts) before netfslib has finished
with them.  However, it's not a simple case of deferring the clunking that
p9_fid_put() does as that requires the p9_client record to still be
present.

The problem is that netfslib has to unlock pages and clear the IN_PROGRESS
flag before destroying the objects involved - including the fid - and, in
any case, nothing checks to see if writeback completed barring looking at
the page flags.

Fix this by keeping a count of outstanding I/O requests (of any type) and
waiting for it to quiesce during inode eviction.

Reported-by: syzbot+df038d463cca332e8414@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/0000000000005be0aa061846f8d6@google.com/
Reported-by: syzbot+d7c7a495a5e466c031b6@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/000000000000b86c5e06130da9c6@google.com/
Reported-by: syzbot+1527696d41a634cc1819@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/000000000000041f960618206d7e@google.com/
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/755891.1716560771@warthog.procyon.org.uk
Tested-by: syzbot+d7c7a495a5e466c031b6@syzkaller.appspotmail.com
Reviewed-by: Dominique Martinet <asmadeus@codewreck.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Steve French <sfrench@samba.org>
cc: Hillf Danton <hdanton@sina.com>
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Reported-and-tested-by: syzbot+d7c7a495a5e466c031b6@syzkaller.appspotmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-05-27 13:12:13 +02:00
..
buffered_read.c netfs: Add some write-side stats and clean up some stat names 2024-05-01 18:07:36 +01:00
buffered_write.c netfs: Fix setting of BDP_ASYNC from iocb flags 2024-05-24 13:34:07 +02:00
direct_read.c cifs: Fix locking in cifs_strict_readv() 2024-05-13 17:02:05 -05:00
direct_write.c netfs: Fix io_uring based write-through 2024-05-24 13:34:06 +02:00
fscache_cache.c netfs, fscache: Prevent Oops in fscache_put_cache() 2024-01-22 21:58:35 +00:00
fscache_cookie.c netfs, fscache: Move fs/fscache/* into fs/netfs/ 2023-12-24 11:36:00 +00:00
fscache_internal.h netfs, fscache: Combine fscache with netfs 2023-12-24 15:08:46 +00:00
fscache_io.c mm: Remove the PG_fscache alias for PG_private_2 2024-04-29 15:01:42 +01:00
fscache_main.c netfs, fscache: Move /proc/fs/fscache to /proc/fs/netfs and put in a symlink 2023-12-24 15:08:48 +00:00
fscache_proc.c netfs: Fix proc/fs/fscache symlink to point to "netfs" not "../netfs" 2024-01-04 13:15:32 +00:00
fscache_stats.c netfs: Fix interaction between write-streaming and cachefiles culling 2024-01-05 15:42:25 +00:00
fscache_volume.c netfs, fscache: Move fs/fscache/* into fs/netfs/ 2023-12-24 11:36:00 +00:00
internal.h netfs: Cut over to using new writeback code 2024-05-01 18:07:37 +01:00
io.c cifs: Cut over to using netfslib 2024-05-01 18:08:21 +01:00
iterator.c netfs: Add func to calculate pagecount/size-limited span of an iterator 2023-12-28 09:45:18 +00:00
Kconfig netfs, fscache: Combine fscache with netfs 2023-12-24 15:08:46 +00:00
locking.c netfs: Implement unbuffered/DIO vs buffered I/O locking 2023-12-24 15:08:52 +00:00
main.c netfs: Switch to using unsigned long long rather than loff_t 2024-05-01 18:07:35 +01:00
Makefile netfs: Cut over to using new writeback code 2024-05-01 18:07:37 +01:00
misc.c netfs: Replace PG_fscache by setting folio->private and marking dirty 2024-04-29 15:01:42 +01:00
objects.c netfs, 9p: Fix race between umount and async request completion 2024-05-27 13:12:13 +02:00
stats.c netfs: Add some write-side stats and clean up some stat names 2024-05-01 18:07:36 +01:00
write_collect.c netfs: Fix io_uring based write-through 2024-05-24 13:34:06 +02:00
write_issue.c netfs: Fix AIO error handling when doing write-through 2024-05-24 13:34:06 +02:00