summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2018-12-04 07:28:02 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-13 12:07:11 +0300
commitd3f10a0116520e6ed383246eb877664c83308232 (patch)
tree29b7d4e8edfae3b21d68662a63d0e7715bf62ba6 /fs/ext4
parentaf860a6a026a3b50cf49bc4602dcb882acae108e (diff)
downloadlinux-d3f10a0116520e6ed383246eb877664c83308232.tar.xz
ext4: fix possible use after free in ext4_quota_enable
commit 61157b24e60fb3cd1f85f2c76a7b1d628f970144 upstream. 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: daf647d2dd5 ("ext4: add lockdep annotations for i_data_sem") Cc: stable@kernel.org # 4.6 Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/super.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c81c04288dcd..0aa7c5250f87 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5389,9 +5389,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;
}