public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Zhang Yi <yi.zhang@huawei.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
	adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com
Subject: Re: [PATCH v2 2/2] ext4: check and assert if marking an no_delete evicting inode dirty
Date: Wed, 29 Jun 2022 12:21:03 +0200	[thread overview]
Message-ID: <20220629102103.y3nmymc26m6qp4jj@quack3> (raw)
In-Reply-To: <20220629022940.2855538-2-yi.zhang@huawei.com>

On Wed 29-06-22 10:29:40, Zhang Yi wrote:
> In ext4_evict_inode(), if we evicting an inode in the 'no_delete' path,
> it cannot be raced by another mark_inode_dirty(). If it happens,
> someone else may accidentally dirty it without holding inode refcount
> and probably cause use-after-free issues in the writeback procedure.
> It's indiscoverable and hard to debug, so add an ASSERT to check and
> detect this issue in advance.
> 
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
>  fs/ext4/inode.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 702cc208689a..2ba74412aa89 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -333,6 +333,12 @@ void ext4_evict_inode(struct inode *inode)
>  	ext4_xattr_inode_array_free(ea_inode_array);
>  	return;
>  no_delete:
> +	/*
> +	 * Check out some where else accidentally dirty the evicting inode,
> +	 * which may probably cause inode use-after-free issues later.
> +	 */
> +	ASSERT(list_empty_careful(&inode->i_io_list));

ASSERT() is harsh as it will take the kernel down. Just use WARN_ON_ONCE()
to notify us of the coming problems :).

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2022-06-29 10:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  2:29 [PATCH v2 1/2] ext4: silence the warning when evicting inode with dioread_nolock Zhang Yi
2022-06-29  2:29 ` [PATCH v2 2/2] ext4: check and assert if marking an no_delete evicting inode dirty Zhang Yi
2022-06-29 10:21   ` Jan Kara [this message]
2022-06-29 10:17 ` [PATCH v2 1/2] ext4: silence the warning when evicting inode with dioread_nolock Jan Kara

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=20220629102103.y3nmymc26m6qp4jj@quack3 \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /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