kernel_optimize_test/fs
Roman Gushchin 0c1d1517d6 writeback, cgroup: increment isw_nr_in_flight before grabbing an inode
[ Upstream commit 8826ee4fe75051f8cbfa5d4a9aa70565938e724c ]

isw_nr_in_flight is used to determine whether the inode switch queue
should be flushed from the umount path.  Currently it's increased after
grabbing an inode and even scheduling the switch work.  It means the
umount path can walk past cleanup_offline_cgwb() with active inode
references, which can result in a "Busy inodes after unmount." message and
use-after-free issues (with inode->i_sb which gets freed).

Fix it by incrementing isw_nr_in_flight before doing anything with the
inode and decrementing in the case when switching wasn't scheduled.

The problem hasn't yet been seen in the real life and was discovered by
Jan Kara by looking into the code.

Link: https://lkml.kernel.org/r/20210608230225.2078447-4-guro@fb.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Suggested-by: Jan Kara <jack@suse.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-14 16:56:02 +02:00
..
9p
adfs
affs
afs afs: Fix an IS_ERR() vs NULL check 2021-06-23 14:42:40 +02:00
autofs
befs
bfs
btrfs btrfs: disable build on platforms having page size 256K 2021-07-14 16:55:56 +02:00
cachefiles
ceph netfs: fix test for whether we can skip read when writing beyond EOF 2021-06-30 08:47:29 -04:00
cifs cifs: fix missing spinlock around update to ses->status 2021-07-14 16:56:01 +02:00
coda
configfs
cramfs
crypto
debugfs
devpts
dlm fs: dlm: fix memory leak when fenced 2021-07-14 16:55:59 +02:00
ecryptfs
efivarfs
efs
erofs
exfat
exportfs
ext2
ext4 ext4: use ext4_grp_locked_error in mb_find_extent 2021-07-14 16:55:41 +02:00
f2fs f2fs: Prevent swap file in LFS mode 2021-07-14 16:55:43 +02:00
fat
freevxfs
fscache
fuse fuse: reject internal errno 2021-07-14 16:55:47 +02:00
gfs2 gfs2: Fix error handling in init_statfs 2021-07-14 16:55:38 +02:00
hfs
hfsplus
hostfs
hpfs
hugetlbfs
iomap
isofs
jbd2
jffs2
jfs
kernfs
lockd
minix
nfs NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. 2021-06-16 12:01:47 +02:00
nfs_common
nfsd
nilfs2 nilfs2: fix memory leak in nilfs_sysfs_delete_device_group 2021-06-30 08:47:24 -04:00
nls
notify fanotify: fix copy_event_to_user() fid error clean up 2021-06-23 14:42:41 +02:00
ntfs ntfs: fix validity check for file name attribute 2021-07-14 16:55:38 +02:00
ocfs2 ocfs2: fix data corruption by fallocate 2021-06-10 13:39:26 +02:00
omfs
openpromfs
orangefs
overlayfs
proc proc: only require mm_struct for writing 2021-06-16 12:01:47 +02:00
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
squashfs
sysfs
sysv
tracefs
ubifs
udf
ufs
unicode
vboxsf
verity
xfs
zonefs
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf_fdpic.c
binfmt_elf.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
block_dev.c block: fix a race between del_gendisk and BLKRRPART 2021-06-03 09:00:45 +02:00
buffer.c
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c
dcache.c
dcookies.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c Add a reference to ucounts for each cred 2021-07-14 16:55:48 +02:00
fcntl.c
fhandle.c
file_table.c
file.c
filesystems.c
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fs-writeback.c writeback, cgroup: increment isw_nr_in_flight before grabbing an inode 2021-07-14 16:56:02 +02:00
fsopen.c
init.c
inode.c
internal.h
io_uring.c io_uring: use better types for cflags 2021-06-10 13:39:23 +02:00
io-wq.c
io-wq.h
ioctl.c
Kconfig
Kconfig.binfmt
kernel_read_file.c
libfs.c
locks.c
Makefile
mbcache.c
mount.h
mpage.c
namei.c
namespace.c
no-block.c
nsfs.c
open.c open: don't silently ignore unknown O-flags in openat2() 2021-07-14 16:55:59 +02:00
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c
super.c
sync.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c