Re: [PATCH V3] xfs: enhance dinode verifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/13/18 10:54 AM, Eric Sandeen wrote:
> Add several more validations to xfs_dinode_verify:
> 
> - For LOCAL data fork formats, di_nextents must be 0.
> - For LOCAL attr fork formats, di_anextents must be 0.
> - For inodes with no attr fork offset,
>   - format must be XFS_DINODE_FMT_EXTENTS if set at all
>   - di_anextents must be 0.
> 
> Thanks to dchinner for pointing out a couple related checks I had
> forgotten to add.

Darrick, maybe also add:

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199377

If you still can

-Eric

> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---
> 
> V2: due credit 
> V3: clarify the no-offset / no-format cases in a comment
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index ef68b1d..ee8ed90 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -466,6 +466,8 @@
>  				return __this_address;
>  			if (di_size > XFS_DFORK_DSIZE(dip, mp))
>  				return __this_address;
> +			if (dip->di_nextents)
> +				return __this_address;
>  			/* fall through */
>  		case XFS_DINODE_FMT_EXTENTS:
>  		case XFS_DINODE_FMT_BTREE:
> @@ -484,12 +486,31 @@
>  	if (XFS_DFORK_Q(dip)) {
>  		switch (dip->di_aformat) {
>  		case XFS_DINODE_FMT_LOCAL:
> +			if (dip->di_anextents)
> +				return __this_address;
> +		/* fall through */
>  		case XFS_DINODE_FMT_EXTENTS:
>  		case XFS_DINODE_FMT_BTREE:
>  			break;
>  		default:
>  			return __this_address;
>  		}
> +	} else {
> +		/*
> +		 * If there is no fork offset, this may be a freshly-made inode
> +		 * in a new disk cluster, in which case di_aformat is zeroed.
> +		 * Otherwise, such an inode must be in EXTENTS format; this goes
> +		 * for freed inodes as well.
> +		 */
> +		switch (dip->di_aformat) {
> +		case 0:
> +		case XFS_DINODE_FMT_EXTENTS:
> +			break;
> +		default:
> +			return __this_address;
> +		}
> +		if (dip->di_anextents)
> +			return __this_address;
>  	}
>  
>  	/* only version 3 or greater inodes are extensively verified here */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux