Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5224650imu; Sun, 25 Nov 2018 19:24:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/WI68Ei4ZK8+ZNqGvFUNuVjLZ7ctFFEHbQnIN3P58IuzxjbZDBZyLFQ4iqvc+tKeaV9bXUY X-Received: by 2002:a63:6302:: with SMTP id x2mr22996631pgb.183.1543202641563; Sun, 25 Nov 2018 19:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543202641; cv=none; d=google.com; s=arc-20160816; b=BDFF7Ymq5ruG2TxEqqNRcBTmJMJUxQvRr6dRLp7PqaSi/8LdvzQ20+L11zplzf1Nmu NuqivmP9BK0bBv17u/jFuxonI6SqnSXVU1MVeKH3FMIDR+HK3MVz7EfJYGkBH8teKTjl vRZkdOyofGQaK/caRWz2IUnP0eaLP/L9e1XkI1mCvtpOlahkD5sw43YEeoO5qmLyVSsx YhqGxjTVwYTe91oQ+XKirHJCPuJGcdVbWLsb0hnR/8Gxc08OUh4zzXRDWMyfUANc2Rrg Y17AFusN0DHo/D1TX9O59j70wT3Dxw4Ef3K5Bd9a3It1VlTa7v6LK6Ri9MNxoLPenzDb BQ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=7A4ihKGl+zCslg/+6W5OvV8mY9+t1E/X9U+NulVAZjY=; b=nG8Awaxx77saDY3y4tDmTCMKbCK1s9Li6lgVtmvzRfQLpJMawpktkQZhVc23v8+yly Zb4pn9k5lpono0TemLTHv6i574BCiC+4y4O2WZddC+A8+6xKSK4/i6pIRC968Pdl6GF/ Jqx2bGw6pFM87Wp0JTFxDKfvbXpRmcBL2xbaLpQunaSIUP+6wWFCfcEk/QFF/Yp5vhtt pg/r8xUPv0Xeu5dho/X+8nlEl5g1t/HD+Yb0vvokZR8hQA1OFF93FMTGRJS1uEzFw+C1 SQueGxt4zMea96VcNkYtwGU6+LuEVk+ZJWdhmfy8cwpAejoUP1pqSovw+9ldc77gblSD 5wdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=T0SqVDwu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6-v6si64211083pfy.29.2018.11.25.19.23.43; Sun, 25 Nov 2018 19:24:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=T0SqVDwu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726168AbeKZOO0 (ORCPT + 99 others); Mon, 26 Nov 2018 09:14:26 -0500 Received: from m12-17.163.com ([220.181.12.17]:35171 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbeKZOOZ (ORCPT ); Mon, 26 Nov 2018 09:14:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=7A4ihKGl+zCslg/+6W 5OvV8mY9+t1E/X9U+NulVAZjY=; b=T0SqVDwur0Y7nR0XQaSQVs1LMTtWLqpolT yCnIgiHJvIYVNfN3/CFwAg2lode+P4G2jRNe0a0SD/zAiL8RTfuBW20b5oDBtu4x s0e+buhRxgau9qdPGy2ee0OoEReHTsuABTLIr+RaEZqMlRQA8AzmVJppf0/PE9cG ltDQWkovY= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp13 (Coremail) with SMTP id EcCowABXI2WiZvtbfg2eBg--.13072S3; Mon, 26 Nov 2018 11:21:08 +0800 (CST) From: Pan Bian To: "Theodore Ts\'o" , Andreas Dilger Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] ext4: fix possible use after free in ext4_quota_enable Date: Mon, 26 Nov 2018 11:21:06 +0800 Message-Id: <1543202466-68277-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EcCowABXI2WiZvtbfg2eBg--.13072S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xr4rKryfWryrAw4rAr4kCrg_yoWfZFg_Xa 1xKF4Iv3sxXrn3KayvkFW3tr1v9F48uF45GF9Yqw4fu34Y9Fs8JFyDArnrAwn3W3y3t3s8 Arn2yF15XFW8ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0vzuJUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZAgLclQHCq5JKQAAsC Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Pan Bian Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem") --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 53ff6c2..35689eb 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5690,9 +5690,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; } -- 2.7.4