Skip to content

Commit

Permalink
ext4: fix possible use after free in ext4_quota_enable
Browse files Browse the repository at this point in the history
The function frees qf_inode via iput but then pass qf_inode to
lockdep_set_quota_inode on the failure path. This may result in a
use-after-free bug. The patch frees df_inode only when it is never used.

Fixes: daf647d ("ext4: add lockdep annotations for i_data_sem")
Cc: [email protected] # 4.6
Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Pan Bian <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
SinkFinder authored and tytso committed Dec 4, 2018
1 parent 96f1e09 commit 61157b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -5713,9 +5713,9 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
qf_inode->i_flags |= S_NOQUOTA;
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
err = dquot_enable(qf_inode, type, format_id, flags);
iput(qf_inode);
if (err)
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
iput(qf_inode);

return err;
}
Expand Down

0 comments on commit 61157b2

Please sign in to comment.