aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ialloc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2016-04-30 00:48:54 -0400
committerTheodore Ts'o <tytso@mit.edu>2016-04-30 00:48:54 -0400
commitc9eb13a9105e2e418f72e46a2b6da3f49e696902 (patch)
treef7c98c4a9720744af5957c76b483a6f1ba0e7dd8 /fs/ext4/ialloc.c
parent8d2ae1cbe8a984d7a755755fb53955de2f60a2f9 (diff)
ext4: fix hang when processing corrupted orphaned inode list
If the orphaned inode list contains inode #5, ext4_iget() returns a bad inode (since the bootloader inode should never be referenced directly). Because of the bad inode, we end up processing the inode repeatedly and this hangs the machine. This can be reproduced via: mke2fs -t ext4 /tmp/foo.img 100 debugfs -w -R "ssv last_orphan 5" /tmp/foo.img mount -o loop /tmp/foo.img /mnt (But don't do this if you are using an unpatched kernel if you care about the system staying functional. :-) This bug was found by the port of American Fuzzy Lop into the kernel to find file system problems[1]. (Since it *only* happens if inode #5 shows up on the orphan list --- 3, 7, 8, etc. won't do it, it's not surprising that AFL needed two hours before it found it.) [1] http://events.linuxfoundation.org/sites/events/files/slides/AFL%20filesystem%20fuzzing%2C%20Vault%202016_0.pdf Cc: stable@vger.kernel.org Reported by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r--fs/ext4/ialloc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 237b877d316d..c2caf2df3695 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1183,11 +1183,13 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1183 goto iget_failed; 1183 goto iget_failed;
1184 1184
1185 /* 1185 /*
1186 * If the orphans has i_nlinks > 0 then it should be able to be 1186 * If the orphans has i_nlinks > 0 then it should be able to
1187 * truncated, otherwise it won't be removed from the orphan list 1187 * be truncated, otherwise it won't be removed from the orphan
1188 * during processing and an infinite loop will result. 1188 * list during processing and an infinite loop will result.
1189 * Similarly, it must not be a bad inode.
1189 */ 1190 */
1190 if (inode->i_nlink && !ext4_can_truncate(inode)) 1191 if ((inode->i_nlink && !ext4_can_truncate(inode)) ||
1192 is_bad_inode(inode))
1191 goto bad_orphan; 1193 goto bad_orphan;
1192 1194
1193 if (NEXT_ORPHAN(inode) > max_ino) 1195 if (NEXT_ORPHAN(inode) > max_ino)