aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-12-27 01:42:50 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-12-27 01:42:50 -0500
commit0e9a9a1ad619e7e987815d20262d36a2f95717ca (patch)
treef8bfb87bf543ccd931bc18bbdb050d1725a81573
parent721e3eba21e43532e438652dd8f1fcdfce3187e7 (diff)
ext4: avoid hang when mounting non-journal filesystems with orphan list
When trying to mount a file system which does not contain a journal, but which does have a orphan list containing an inode which needs to be truncated, the mount call with hang forever in ext4_orphan_cleanup() because ext4_orphan_del() will return immediately without removing the inode from the orphan list, leading to an uninterruptible loop in kernel code which will busy out one of the CPU's on the system. This can be trivially reproduced by trying to mount the file system found in tests/f_orphan_extents_inode/image.gz from the e2fsprogs source tree. If a malicious user were to put this on a USB stick, and mount it on a Linux desktop which has automatic mounts enabled, this could be considered a potential denial of service attack. (Not a big deal in practice, but professional paranoids worry about such things, and have even been known to allocate CVE numbers for such problems.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Zheng Liu <wenqing.lz@taobao.com> Cc: stable@vger.kernel.org
-rw-r--r--fs/ext4/namei.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index cac448282331..8990165346ee 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2648,7 +2648,8 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
2648 struct ext4_iloc iloc; 2648 struct ext4_iloc iloc;
2649 int err = 0; 2649 int err = 0;
2650 2650
2651 if (!EXT4_SB(inode->i_sb)->s_journal) 2651 if ((!EXT4_SB(inode->i_sb)->s_journal) &&
2652 !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
2652 return 0; 2653 return 0;
2653 2654
2654 mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock); 2655 mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);