]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ext4: fix possible use after free in ext4_quota_enable
authorPan Bian <bianpan2016@163.com>
Tue, 4 Dec 2018 04:28:02 +0000 (23:28 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837257
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>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/ext4/super.c

index f52238c2d30cfeda5e9e4695e5b275b2e599fb71..cd76885f48d13507842d28eac0da46b4f7d288f4 100644 (file)
@@ -5675,9 +5675,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;
 }