Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs@vger.kernel.org, cem@kernel.org, hch@lst.de
Subject: Re: [PATCH 2/2] xfs: add missing cursor stat checks after xfs_btree_delete
Date: Tue, 13 Oct 2026 14:59:51 -0700	[thread overview]
Message-ID: <20261013215951.GG2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20261013211851.641256-3-sandeen@redhat.com>

On Tue, Oct 13, 2026 at 04:07:47PM -0500, Eric Sandeen wrote:
> Three xfs_btree_delete() calls in xfs_ialloc.c fail to check the status
> returns indicating whether a record was actually deleted. If the cursor
> was pointing to something that couldn't be deleted or didn't exist,
> something has gone wrong, so mark the fs as sick and return
> EFSCORRUPTED.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks good too!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_ialloc.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 17699f7c009f..bb6e684f5467 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -1626,12 +1626,20 @@ xfs_dialloc_ag(
>  	 */
>  	rec.ir_free &= ~XFS_INOBT_MASK(offset);
>  	rec.ir_freecount--;
> -	if (rec.ir_freecount)
> +	if (rec.ir_freecount) {
>  		error = xfs_inobt_update(cur, &rec);
> -	else
> +		if (error)
> +			goto error_cur;
> +	} else {
>  		error = xfs_btree_delete(cur, &i);
> -	if (error)
> -		goto error_cur;
> +		if (error)
> +			goto error_cur;
> +		if (XFS_IS_CORRUPT(mp, i != 1)) {
> +			xfs_btree_mark_sick(cur);
> +			error = -EFSCORRUPTED;
> +			goto error_cur;
> +		}
> +	}
>  
>  	/*
>  	 * The finobt has now been updated appropriately. We haven't updated the
> @@ -2164,6 +2172,11 @@ xfs_difree_inobt(
>  				__func__, error);
>  			goto error0;
>  		}
> +		if (XFS_IS_CORRUPT(mp, i != 1)) {
> +			xfs_btree_mark_sick(cur);
> +			error = -EFSCORRUPTED;
> +			goto error0;
> +		}
>  
>  		error = xfs_difree_inode_chunk(tp, pag, &rec);
>  		if (error)
> @@ -2290,7 +2303,11 @@ xfs_difree_finobt(
>  		error = xfs_btree_delete(cur, &i);
>  		if (error)
>  			goto error;
> -		ASSERT(i == 1);
> +		if (XFS_IS_CORRUPT(mp, i != 1)) {
> +			xfs_btree_mark_sick(cur);
> +			error = -EFSCORRUPTED;
> +			goto error;
> +		}
>  	} else {
>  		error = xfs_inobt_update(cur, &rec);
>  		if (error)
> -- 
> 2.55.0
> 
> 

  reply	other threads:[~2026-10-13 21:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 21:07 [PATCH 0/2] xfs: add missing cursor status check after btree ops Eric Sandeen
2026-10-13 21:07 ` [PATCH 1/2] xfs: add missing cursor status check after xfs_get_rec Eric Sandeen
2026-10-13 21:58   ` Darrick J. Wong
2026-10-14  0:16   ` [PATCH 1/2 V2] xfs: add missing cursor status check after xfs_inobt_get_rec Eric Sandeen
2026-10-14 13:20     ` Christoph Hellwig
2026-10-13 21:07 ` [PATCH 2/2] xfs: add missing cursor stat checks after xfs_btree_delete Eric Sandeen
2026-10-13 21:59   ` Darrick J. Wong [this message]
2026-10-14 13:21   ` Christoph Hellwig
2026-10-14  8:28 ` [PATCH 0/2] xfs: add missing cursor status check after btree ops Carlos Maiolino

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=20261013215951.GG2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.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