Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp470498imu; Tue, 27 Nov 2018 01:17:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/U9M8FuacUs9V98+iyjn2rcpNuyxicnGqE5B2mtswB1pRkc6kZ2bc61s32mW9DdPvs49Gh0 X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr30949822plq.195.1543310273522; Tue, 27 Nov 2018 01:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543310273; cv=none; d=google.com; s=arc-20160816; b=mhhOpSOOyRU49rIrRX6WO4UR5gl882Dg+GFyNvwqgXDZKaXoba1qu3gcSExxBGo4fd /k6jTd3fzn2n+2o6gpqQLqqc9aqs2ao1t5AeuWCBMluSPsaSTyNq0f7p03W+JxED3BX2 PwLWK8JIVAU7beSV4Pidr/eHdmVWb4yQLCoavlBI4MeWeT4zu3TieBYrVwdyZv2uMTo3 lQpNFKcuXVqHF6uIfQqd2VcwExS0CBeqWniQRvjE9DNChd1y3Jiy5jHdFxKCGk5GKUFQ DYWWKM8VZbxL5F63x5r451lYNDQLpFXj2K3HQNr2GNYgy3Yda4bmWg4+etoTzjzFGbzg ygKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ns5OlLEZQQgT/b9yRSInyMrrXHMX2h9UKRShJuE0dvY=; b=dGOkK8JeNeFbXyPKkmo6IoIh90+FGQ+uBd6B4Fv196COJCVWtyJSs36YoSo+tlcJvY DjPkHUe8R6ycSk/0+aoMDDuAnhhOuVEV63PuPzu/c47v8oRtcXisoCyU0ZoZqDc0qJgO fc8+ddkxINLzcfZaY7IOKJWR01HtKfKqNioRKZU2HDz5Zl8uaNErRGpi3Ll7AlGwvXs5 +WucjWOwJEGFkRhzg1QTmVtzzKUaS8FDtgOx9HcG8GdOZ+/HcBHrqH0L/NtYkw/pFJkh no6G8uL5xip3doyDf0N932T8MjJYFFYV1lYAExv4FrGxF2ci9o+aTD6ETdtctGoSx/bJ Iovg== ARC-Authentication-Results: i=1; mx.google.com; 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 33si3356096plu.169.2018.11.27.01.17.38; Tue, 27 Nov 2018 01:17:53 -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; 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 S1730158AbeK0UML (ORCPT + 99 others); Tue, 27 Nov 2018 15:12:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:44272 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730050AbeK0UMK (ORCPT ); Tue, 27 Nov 2018 15:12:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A8F18ABA1; Tue, 27 Nov 2018 09:14:54 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id F239A1E07ED; Tue, 27 Nov 2018 10:14:53 +0100 (CET) Date: Tue, 27 Nov 2018 10:14:53 +0100 From: Jan Kara To: Pan Bian Cc: Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable Message-ID: <20181127091453.GA16301@quack2.suse.cz> References: <1543202466-68277-1-git-send-email-bianpan2016@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1543202466-68277-1-git-send-email-bianpan2016@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 26-11-18 11:21:06, Pan Bian wrote: > 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") Thanks for the fix! The patch looks good. You can add: Reviewed-by: Jan Kara Honza > --- > 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 > > -- Jan Kara SUSE Labs, CR