From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] xfs: check owner of dir3 data blocks
Date: Wed, 11 Mar 2020 16:51:21 +1100 [thread overview]
Message-ID: <20200311055121.GZ10776@dread.disaster.area> (raw)
In-Reply-To: <158388767279.939165.8430173747192985972.stgit@magnolia>
On Tue, Mar 10, 2020 at 05:47:52PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Check the owner field of dir3 data block headers. If it's corrupt,
> release the buffer and return EFSCORRUPTED. All callers handle this
> properly.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/libxfs/xfs_dir2_data.c | 31 ++++++++++++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
> index b9eba8213180..8de9611387e5 100644
> --- a/fs/xfs/libxfs/xfs_dir2_data.c
> +++ b/fs/xfs/libxfs/xfs_dir2_data.c
> @@ -394,6 +394,22 @@ static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = {
> .verify_write = xfs_dir3_data_write_verify,
> };
>
> +static xfs_failaddr_t
> +xfs_dir3_data_header_check(
> + struct xfs_inode *dp,
> + struct xfs_buf *bp)
> +{
> + struct xfs_mount *mp = dp->i_mount;
> +
> + if (xfs_sb_version_hascrc(&mp->m_sb)) {
> + struct xfs_dir3_data_hdr *hdr3 = bp->b_addr;
> +
> + if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
> + return __this_address;
> + }
> +
> + return NULL;
> +}
>
> int
> xfs_dir3_data_read(
> @@ -403,11 +419,24 @@ xfs_dir3_data_read(
> unsigned int flags,
> struct xfs_buf **bpp)
> {
> + xfs_failaddr_t fa;
> int err;
>
> err = xfs_da_read_buf(tp, dp, bno, flags, bpp, XFS_DATA_FORK,
> &xfs_dir3_data_buf_ops);
> - if (!err && tp && *bpp)
> + if (err || !*bpp)
> + return err;
> +
> + /* Check things that we can't do in the verifier. */
> + fa = xfs_dir3_data_header_check(dp, *bpp);
> + if (fa) {
> + __xfs_buf_mark_corrupt(*bpp, fa);
> + xfs_trans_brelse(tp, *bpp);
> + *bpp = NULL;
> + return -EFSCORRUPTED;
> + }
> +
> + if (tp)
> xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
xfs_trans_buf_set_type() handles a null tp just fine.
Otherwise OK.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2020-03-11 5:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 0:47 [PATCH v2 0/7] xfs: fix errors in various verifiers Darrick J. Wong
2020-03-11 0:47 ` [PATCH 1/7] xfs: add a function to deal with corrupt buffers post-verifiers Darrick J. Wong
2020-03-11 5:35 ` Dave Chinner
2020-03-11 16:42 ` Darrick J. Wong
2020-03-11 18:25 ` [PATCH v2 " Darrick J. Wong
2020-03-12 4:37 ` Dave Chinner
2020-03-12 4:55 ` Darrick J. Wong
2020-03-11 0:47 ` [PATCH 2/7] xfs: xfs_buf_corruption_error should take __this_address Darrick J. Wong
2020-03-11 5:36 ` Dave Chinner
2020-03-11 0:47 ` [PATCH 3/7] xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Darrick J. Wong
2020-03-11 5:39 ` Dave Chinner
2020-03-11 0:47 ` [PATCH 4/7] xfs: don't ever return a stale pointer from __xfs_dir3_free_read Darrick J. Wong
2020-03-11 5:47 ` Dave Chinner
2020-03-11 0:47 ` [PATCH 5/7] xfs: check owner of dir3 free blocks Darrick J. Wong
2020-03-11 5:47 ` Dave Chinner
2020-03-11 0:47 ` [PATCH 6/7] xfs: check owner of dir3 data blocks Darrick J. Wong
2020-03-11 5:51 ` Dave Chinner [this message]
2020-03-11 0:47 ` [PATCH 7/7] xfs: check owner of dir3 blocks Darrick J. Wong
2020-03-11 5:52 ` Dave Chinner
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=20200311055121.GZ10776@dread.disaster.area \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.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