public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/3] xfs: validity check agbnos on the AGFL
Date: Thu, 1 Jun 2023 07:51:01 -0700	[thread overview]
Message-ID: <20230601145101.GD16865@frogsfrogsfrogs> (raw)
In-Reply-To: <20230529000825.2325477-3-david@fromorbit.com>

On Mon, May 29, 2023 at 10:08:24AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> If the agfl or the indexing in the AGF has been corrupted, getting a
> block form the AGFL could return an invalid block number. If this
> happens, bad things happen. Check the agbno we pull off the AGFL
> and return -EFSCORRUPTED if we find somethign bad.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

This looks like a good addition to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_alloc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index fd3293a8c659..643d17877832 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -2780,6 +2780,9 @@ xfs_alloc_get_freelist(
>  	 */
>  	agfl_bno = xfs_buf_to_agfl_bno(agflbp);
>  	bno = be32_to_cpu(agfl_bno[be32_to_cpu(agf->agf_flfirst)]);
> +	if (XFS_IS_CORRUPT(tp->t_mountp, !xfs_verify_agbno(pag, bno)))
> +		return -EFSCORRUPTED;
> +
>  	be32_add_cpu(&agf->agf_flfirst, 1);
>  	xfs_trans_brelse(tp, agflbp);
>  	if (be32_to_cpu(agf->agf_flfirst) == xfs_agfl_size(mp))
> -- 
> 2.40.1
> 

  parent reply	other threads:[~2023-06-01 14:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29  0:08 [PATCH 0/3] xfs: improve AGF/AGFL verification Dave Chinner
2023-05-29  0:08 ` [PATCH 1/3] xfs: fix agf/agfl verification on v4 filesystems Dave Chinner
2023-05-31  6:06   ` Christoph Hellwig
2023-06-01 14:50   ` Darrick J. Wong
2023-05-29  0:08 ` [PATCH 2/3] xfs: validity check agbnos on the AGFL Dave Chinner
2023-05-31  6:06   ` Christoph Hellwig
2023-06-01 14:51   ` Darrick J. Wong [this message]
2023-05-29  0:08 ` [PATCH 3/3] xfs: validate block number being freed before adding to xefi Dave Chinner
2023-05-31  6:06   ` Christoph Hellwig
2023-06-01 14:51   ` Darrick J. Wong

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=20230601145101.GD16865@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /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