linux-stable/fs/ext4
Theodore Ts'o e1513b3631 ext4: work around deleting a file with i_nlink == 0 safely
[ Upstream commit c7df4a1ecb ]

If the file system is corrupted such that a file's i_links_count is
too small, then it's possible that when unlinking that file, i_nlink
will already be zero.  Previously we were working around this kind of
corruption by forcing i_nlink to one; but we were doing this before
trying to delete the directory entry --- and if the file system is
corrupted enough that ext4_delete_entry() fails, then we exit with
i_nlink elevated, and this causes the orphan inode list handling to be
FUBAR'ed, such that when we unmount the file system, the orphan inode
list can get corrupted.

A better way to fix this is to simply skip trying to call drop_nlink()
if i_nlink is already zero, thus moving the check to the place where
it makes the most sense.

https://bugzilla.kernel.org/show_bug.cgi?id=205433

Link: https://lore.kernel.org/r/20191112032903.8828-1-tytso@mit.edu
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-04 13:40:58 +01:00
..
Kconfig ext4 crypto: migrate into vfs's crypto engine 2016-07-10 14:01:03 -04:00
Makefile ext4 crypto: migrate into vfs's crypto engine 2016-07-10 14:01:03 -04:00
acl.c ext4: Don't clear SGID when inheriting ACLs 2017-10-12 11:51:26 +02:00
acl.h
balloc.c ext4: check for allocation block validity with block group locked 2018-08-03 07:55:26 +02:00
bitmap.c
block_validity.c ext4: add missing KERN_CONT to a few more debugging uses 2016-10-15 09:57:31 -04:00
dir.c ext4: check for directory entries too close to block end 2020-01-04 13:40:23 +01:00
ext4.h ext4: avoid running out of journal credits when appending to an inline file 2018-10-20 09:51:32 +02:00
ext4_extents.h ext4: verify the depth of extent tree in ext4_find_extent() 2018-07-11 16:26:44 +02:00
ext4_jbd2.c ext4: fix potential use after free in __ext4_journal_stop 2015-10-17 22:57:06 -04:00
ext4_jbd2.h ext4: fix NULL pointer dereference while journal is aborted 2019-03-27 14:13:03 +09:00
extents.c ext4: fix warning inside ext4_convert_unwritten_extents_endio 2019-10-05 12:30:35 +02:00
extents_status.c ext4: remove trailing \n from ext4_warning/ext4_error calls 2016-04-27 01:11:21 -04:00
extents_status.h ext4: move procfs registration code to fs/ext4/sysfs.c 2015-09-23 12:46:17 -04:00
file.c ext4: fix data corruption caused by overlapping unaligned and aligned IO 2019-05-21 18:49:01 +02:00
fsync.c ext4: cleanup ext4_sync_parent() 2016-09-05 23:21:43 -04:00
hash.c
ialloc.c ext4: fix check to prevent initializing reserved inodes 2018-08-15 18:14:41 +02:00
indirect.c ext4: cleanup bh release code in ext4_ind_remove_space() 2019-04-05 22:29:04 +02:00
inline.c ext4: fix a potential fiemap/page fault deadlock w/ inline_data 2019-01-16 22:12:32 +01:00
inode.c ext4: fix a bug in ext4_wait_for_tail_page_commit 2019-12-21 10:42:18 +01:00
ioctl.c ext4: actually request zeroing of inode table after grow 2019-05-21 18:48:59 +02:00
mballoc.c ext4: fix spectre gadget in ext4_mb_regular_allocator() 2018-08-24 13:12:41 +02:00
mballoc.h ext4: add missing KERN_CONT to a few more debugging uses 2016-10-15 09:57:31 -04:00
migrate.c ext4: fix misspellings in comments. 2016-03-09 23:49:05 -05:00
mmp.c ext4: don't mark mmp buffer head dirty 2018-09-29 03:07:34 -07:00
move_extent.c ext4: fix argument checking in EXT4_IOC_MOVE_EXT 2018-11-13 11:16:52 -08:00
namei.c ext4: work around deleting a file with i_nlink == 0 safely 2020-01-04 13:40:58 +01:00
page-io.c fs: use mapping_set_error instead of opencoded set_bit 2016-10-11 15:06:33 -07:00
readpage.c Merge branch 'akpm' (patches from Andrew) 2016-07-26 19:55:54 -07:00
resize.c ext4: report real fs size after failed resize 2019-04-20 09:07:46 +02:00
super.c ext4: fix ext4_show_options for file systems w/o journal 2019-05-21 18:48:59 +02:00
symlink.c Merge branch 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-10-10 17:11:50 -07:00
sysfs.c ext4: sysfs: print ext4_super_block fields as little-endian 2018-09-05 09:20:06 +02:00
truncate.h ext4: fix races between page faults and hole punching 2015-12-07 14:28:03 -05:00
xattr.c ext4: include terminating u32 in size of xattr entries when expanding inodes 2019-01-09 16:16:43 +01:00
xattr.h ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea() 2017-03-12 06:41:41 +01:00
xattr_security.c switch xattr_handler->set() to passing dentry and inode separately 2016-05-27 15:39:43 -04:00
xattr_trusted.c switch xattr_handler->set() to passing dentry and inode separately 2016-05-27 15:39:43 -04:00
xattr_user.c switch xattr_handler->set() to passing dentry and inode separately 2016-05-27 15:39:43 -04:00