linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Pan Bian <bianpan2016@163.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable
Date: Tue, 27 Nov 2018 10:14:53 +0100	[thread overview]
Message-ID: <20181127091453.GA16301@quack2.suse.cz> (raw)
In-Reply-To: <1543202466-68277-1-git-send-email-bianpan2016@163.com>

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 <bianpan2016@163.com>
> 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 <jack@suse.cz>

								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 <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2018-11-27 20:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26  3:21 [PATCH] ext4: fix possible use after free in ext4_quota_enable Pan Bian
2018-11-27  9:14 ` Jan Kara [this message]
2018-12-04  4:33   ` Theodore Y. Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181127091453.GA16301@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=bianpan2016@163.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).