add patch clean-up-identation-issues
[ext4-patch-queue.git] / fix-possible-use-after-free-in-ext4_quota_enable
blob0ad28b49d724c82a4e933948463c10c30b223007
1 ext4: fix possible use after free in ext4_quota_enable
3 From: Pan Bian <bianpan2016@163.com>
5 The function frees qf_inode via iput but then pass qf_inode to
6 lockdep_set_quota_inode on the failure path. This may result in a
7 use-after-free bug. The patch frees df_inode only when it is never used.
9 Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")
10 Reviewed-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Pan Bian <bianpan2016@163.com>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 ---
14  fs/ext4/super.c | 2 +-
15  1 file changed, 1 insertion(+), 1 deletion(-)
17 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
18 index 53ff6c2..35689eb 100644
19 --- a/fs/ext4/super.c
20 +++ b/fs/ext4/super.c
21 @@ -5690,9 +5690,9 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
22         qf_inode->i_flags |= S_NOQUOTA;
23         lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
24         err = dquot_enable(qf_inode, type, format_id, flags);
25 -       iput(qf_inode);
26         if (err)
27                 lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
28 +       iput(qf_inode);
30         return err;
31  }
32 -- 
33 2.7.4