diff mbox series

[18/18] xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify

Message ID 20220509004138.762556-19-david@fromorbit.com (mailing list archive)
State Accepted, archived
Headers show
Series XFS: LARP state machine and recovery rework | expand

Commit Message

Dave Chinner May 9, 2022, 12:41 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

xfs_repair flags these as a corruption error, so the verifier should
catch software bugs that result in empty leaf blocks being written
to disk, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Allison Henderson May 10, 2022, 10:31 p.m. UTC | #1
On Mon, 2022-05-09 at 10:41 +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> xfs_repair flags these as a corruption error, so the verifier should
> catch software bugs that result in empty leaf blocks being written
> to disk, too.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
Ok, looks good
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c
> b/fs/xfs/libxfs/xfs_attr_leaf.c
> index d15e92858bf0..15a990409463 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -310,6 +310,15 @@ xfs_attr3_leaf_verify(
>  	if (fa)
>  		return fa;
>  
> +	/*
> +	 * Empty leaf blocks should never occur;  they imply the
> existence of a
> +	 * software bug that needs fixing. xfs_repair also flags them
> as a
> +	 * corruption that needs fixing, so we should never let these
> go to
> +	 * disk.
> +	 */
> +	if (ichdr.count == 0)
> +		return __this_address;
> +
>  	/*
>  	 * firstused is the block offset of the first name info
> structure.
>  	 * Make sure it doesn't go off the block or crash into the
> header.
Darrick J. Wong May 10, 2022, 11:54 p.m. UTC | #2
On Mon, May 09, 2022 at 10:41:38AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> xfs_repair flags these as a corruption error, so the verifier should
> catch software bugs that result in empty leaf blocks being written
> to disk, too.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index d15e92858bf0..15a990409463 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -310,6 +310,15 @@ xfs_attr3_leaf_verify(
>  	if (fa)
>  		return fa;
>  
> +	/*
> +	 * Empty leaf blocks should never occur;  they imply the existence of a
> +	 * software bug that needs fixing. xfs_repair also flags them as a
> +	 * corruption that needs fixing, so we should never let these go to
> +	 * disk.
> +	 */
> +	if (ichdr.count == 0)
> +		return __this_address;
> +
>  	/*
>  	 * firstused is the block offset of the first name info structure.
>  	 * Make sure it doesn't go off the block or crash into the header.
> -- 
> 2.35.1
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index d15e92858bf0..15a990409463 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -310,6 +310,15 @@  xfs_attr3_leaf_verify(
 	if (fa)
 		return fa;
 
+	/*
+	 * Empty leaf blocks should never occur;  they imply the existence of a
+	 * software bug that needs fixing. xfs_repair also flags them as a
+	 * corruption that needs fixing, so we should never let these go to
+	 * disk.
+	 */
+	if (ichdr.count == 0)
+		return __this_address;
+
 	/*
 	 * firstused is the block offset of the first name info structure.
 	 * Make sure it doesn't go off the block or crash into the header.