1
0
Fork 0
alistair23-linux/fs/ext4
Jan Kara 8635f0fe06 ext4: fix deadlock with fs freezing and EA inodes
commit 46e294efc3 upstream.

Xattr code using inodes with large xattr data can end up dropping last
inode reference (and thus deleting the inode) from places like
ext4_xattr_set_entry(). That function is called with transaction started
and so ext4_evict_inode() can deadlock against fs freezing like:

CPU1					CPU2

removexattr()				freeze_super()
  vfs_removexattr()
    ext4_xattr_set()
      handle = ext4_journal_start()
      ...
      ext4_xattr_set_entry()
        iput(old_ea_inode)
          ext4_evict_inode(old_ea_inode)
					  sb->s_writers.frozen = SB_FREEZE_FS;
					  sb_wait_write(sb, SB_FREEZE_FS);
					  ext4_freeze()
					    jbd2_journal_lock_updates()
					      -> blocks waiting for all
					         handles to stop
            sb_start_intwrite()
	      -> blocks as sb is already in SB_FREEZE_FS state

Generally it is advisable to delete inodes from a separate transaction
as it can consume quite some credits however in this case it would be
quite clumsy and furthermore the credits for inode deletion are quite
limited and already accounted for. So just tweak ext4_evict_inode() to
avoid freeze protection if we have transaction already started and thus
it is not really needed anyway.

Cc: stable@vger.kernel.org
Fixes: dec214d00e ("ext4: xattr inode deduplication")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20201127110649.24730-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-30 11:51:37 +01:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile ext4: add basic fs-verity support 2019-08-12 19:33:50 -07:00
acl.c ext4: compare old and new mode before setting update_mode flag 2018-12-10 00:22:38 -05:00
acl.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
balloc.c ext4: fix potential race between online resizing and write operations 2020-02-28 17:22:22 +01:00
bitmap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
block_validity.c ext4: correctly restore system zone info when remount fails 2020-09-03 11:26:57 +02:00
dir.c ext4: avoid utf8_strncasecmp() with unstable name 2020-06-24 17:50:48 +02:00
ext4.h ext4: fix bogus warning in ext4_update_dx_flag() 2020-11-24 13:29:21 +01:00
ext4_extents.h ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max 2020-06-22 09:31:15 +02:00
ext4_jbd2.c ext4: shutdown should not prevent get_write_access 2018-02-18 22:07:36 -05:00
ext4_jbd2.h ext4: use jbd2_inode dirty range scoping 2019-06-20 17:26:26 -04:00
extents.c ext4: fix partial cluster initialization when splitting extent 2020-06-24 17:50:47 +02:00
extents_status.c ext4: use percpu_counters for extent_status cache hits/misses 2019-08-28 11:19:23 -04:00
extents_status.h ext4: use percpu_counters for extent_status cache hits/misses 2019-08-28 11:19:23 -04:00
file.c ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT 2020-02-24 08:36:24 +01:00
fsmap.c ext4: limit entries returned when counting fsmap records 2020-10-29 09:57:55 +01:00
fsmap.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
fsync.c ext4: fix race between ext4_sync_parent() and rename() 2020-06-22 09:31:16 +02:00
hash.c ext4: fix kernel oops caused by spurious casefold flag 2019-09-03 01:43:17 -04:00
ialloc.c ext4: increase wait time needed before reuse of deleted inode numbers 2020-05-02 08:48:59 +02:00
indirect.c ext4: clean up kerneldoc warnigns when building with W=1 2019-06-19 16:30:03 -04:00
inline.c ext4: unlock xattr_sem properly in ext4_inline_data_truncate() 2020-11-18 19:20:28 +01:00
inode.c ext4: fix deadlock with fs freezing and EA inodes 2020-12-30 11:51:37 +01:00
ioctl.c Added new ext4 debugging ioctls to allow userspace to get information 2019-09-21 13:37:39 -07:00
mballoc.c ext4: fix a memory leak of ext4_free_data 2020-12-30 11:51:37 +01:00
mballoc.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
migrate.c ext4: fix race between writepages and enabling EXT4_EXTENTS_FL 2020-02-28 17:22:23 +01:00
mmp.c ext4: don't assume that mmp_nodename/bdevname have NUL 2020-02-19 19:52:58 +01:00
move_extent.c ext4: use jbd2_inode dirty range scoping 2019-06-20 17:26:26 -04:00
namei.c ext4: fix potential negative array index in do_split() 2020-08-26 10:40:58 +02:00
page-io.c ext4: fix deadlock allocating crypto bounce page from mempool 2020-02-11 04:35:32 -08:00
readpage.c ext4: fix deadlock allocating bio_post_read_ctx from mempool 2020-02-24 08:36:29 +01:00
resize.c ext4: fix error handling code in add_new_gdb 2020-11-05 11:43:35 +01:00
super.c ext4: correctly report "not supported" for {usr,grp}jquota when !CONFIG_QUOTA 2020-11-18 19:20:28 +01:00
symlink.c ext4: switch to fscrypt_get_symlink() 2018-01-11 22:10:40 -05:00
sysfs.c ext4: add basic fs-verity support 2019-08-12 19:33:50 -07:00
truncate.h ext4: handle layout changes to pinned DAX mappings 2018-07-29 17:00:22 -04:00
verity.c ext4: add basic fs-verity support 2019-08-12 19:33:50 -07:00
xattr.c ext4: fix error pointer dereference 2020-06-22 09:31:15 +02:00
xattr.h ext4: add extra checks to ext4_xattr_block_get() 2018-03-30 20:04:11 -04:00
xattr_security.c ext4: use XATTR_CREATE in ext4_initxattrs() 2018-05-10 11:52:14 -04:00
xattr_trusted.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xattr_user.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00