From: Theodore Ts'o Date: Thu, 27 Dec 2012 06:42:50 +0000 (-0500) Subject: UPSTREAM: ext4: avoid hang when mounting non-journal filesystems with orphan list X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d9bb491d6924b78800af1b8514f6346fe7077058;p=people%2Faperard%2Flinux-chromebook.git UPSTREAM: 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" Reviewed-by: Zheng Liu Cc: stable@vger.kernel.org BUG=chromium-os:37768 TEST=link build, manual test with corrupted filesystem image (cherry picked from commit 0e9a9a1ad619e7e987815d20262d36a2f95717ca) Change-Id: I5e985a85e94f3b38f0dd5d8c1517c0bccc93eb04 Signed-off-by: Kees Cook Reviewed-on: https://gerrit.chromium.org/gerrit/41038 Reviewed-by: Olof Johansson --- diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 99a6970414515..4c5b1eaf929b7 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2052,7 +2052,8 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) struct ext4_iloc iloc; int err = 0; - if (!EXT4_SB(inode->i_sb)->s_journal) + if ((!EXT4_SB(inode->i_sb)->s_journal) && + !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) return 0; mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);