add patch fix-use-after-free-race-with-debug_want_extra_isize
[ext4-patch-queue.git] / avoid-drop-reference-to-iloc.bh-twice
blob29c50f7ba0a6e814db34da0a2ab74e319ee845d0
1 ext4: avoid drop reference to iloc.bh twice
3 From: Pan Bian <bianpan2016@163.com>
5 The reference to iloc.bh has been dropped in ext4_mark_iloc_dirty.
6 However, the reference is dropped again if error occurs during
7 ext4_handle_dirty_metadata, which may result in use-after-free bugs.
9 Fixes: fb265c9cb49e("ext4: add ext4_sb_bread() to disambiguate ENOMEM
10 cases")
12 Signed-off-by: Pan Bian <bianpan2016@163.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 Reviewed-by: Jan Kara <jack@suse.cz>
15 ---
16  fs/ext4/resize.c | 1 +
17  1 file changed, 1 insertion(+)
19 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
20 index e7ae26e..4d5c0fc 100644
21 --- a/fs/ext4/resize.c
22 +++ b/fs/ext4/resize.c
23 @@ -874,6 +874,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
24         err = ext4_handle_dirty_metadata(handle, NULL, gdb_bh);
25         if (unlikely(err)) {
26                 ext4_std_error(sb, err);
27 +               iloc.bh = NULL;
28                 goto errout;
29         }
30         brelse(dind);
31 -- 
32 2.7.4