]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
32bfe1a78c5e54a79e20fef7d64f00a3673407d5
[thirdparty/kernel/stable-queue.git] /
1 From b9a037b7f3c401d3c63e0423e56aef606b1ffaaf Mon Sep 17 00:00:00 2001
2 From: Zhang Yi <yi.zhang@huawei.com>
3 Date: Fri, 7 May 2021 15:19:04 +0800
4 Subject: ext4: cleanup in-core orphan list if ext4_truncate() failed to get a transaction handle
5
6 From: Zhang Yi <yi.zhang@huawei.com>
7
8 commit b9a037b7f3c401d3c63e0423e56aef606b1ffaaf upstream.
9
10 In ext4_orphan_cleanup(), if ext4_truncate() failed to get a transaction
11 handle, it didn't remove the inode from the in-core orphan list, which
12 may probably trigger below error dump in ext4_destroy_inode() during the
13 final iput() and could lead to memory corruption on the later orphan
14 list changes.
15
16 EXT4-fs (sda): Inode 6291467 (00000000b8247c67): orphan list check failed!
17 00000000b8247c67: 0001f30a 00000004 00000000 00000023 ............#...
18 00000000e24cde71: 00000006 014082a3 00000000 00000000 ......@.........
19 0000000072c6a5ee: 00000000 00000000 00000000 00000000 ................
20 ...
21
22 This patch fix this by cleanup in-core orphan list manually if
23 ext4_truncate() return error.
24
25 Cc: stable@kernel.org
26 Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
27 Reviewed-by: Jan Kara <jack@suse.cz>
28 Link: https://lore.kernel.org/r/20210507071904.160808-1-yi.zhang@huawei.com
29 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31
32 ---
33 fs/ext4/super.c | 9 ++++++++-
34 1 file changed, 8 insertions(+), 1 deletion(-)
35
36 --- a/fs/ext4/super.c
37 +++ b/fs/ext4/super.c
38 @@ -2689,8 +2689,15 @@ static void ext4_orphan_cleanup(struct s
39 inode_lock(inode);
40 truncate_inode_pages(inode->i_mapping, inode->i_size);
41 ret = ext4_truncate(inode);
42 - if (ret)
43 + if (ret) {
44 + /*
45 + * We need to clean up the in-core orphan list
46 + * manually if ext4_truncate() failed to get a
47 + * transaction handle.
48 + */
49 + ext4_orphan_del(NULL, inode);
50 ext4_std_error(inode->i_sb, ret);
51 + }
52 inode_unlock(inode);
53 nr_truncates++;
54 } else {