Re: [PATCH 3/3] xfs: scrub inode mode properly

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

 



On Tue, Nov 28, 2017 at 09:40:09AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> Since we've used up all the bits in i_mode, the existing mode check
> doesn't actually do anything useful.  However, we've not used all the
> bit values in the format portion of i_mode, so we /do/ need to test
> that for bad values.
> 
> Fixes: 80e4e1268 ("xfs: scrub inodes")
> Fixes-coverity-id: 1423992
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> ---

Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>

>  fs/xfs/scrub/inode.c |   14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
> index 637b7a8..f120fb2 100644
> --- a/fs/xfs/scrub/inode.c
> +++ b/fs/xfs/scrub/inode.c
> @@ -318,8 +318,20 @@ xfs_scrub_dinode(
>  
>  	/* di_mode */
>  	mode = be16_to_cpu(dip->di_mode);
> -	if (mode & ~(S_IALLUGO | S_IFMT))
> +	switch (mode & S_IFMT) {
> +	case S_IFLNK:
> +	case S_IFREG:
> +	case S_IFDIR:
> +	case S_IFCHR:
> +	case S_IFBLK:
> +	case S_IFIFO:
> +	case S_IFSOCK:
> +		/* mode is recognized */
> +		break;
> +	default:
>  		xfs_scrub_ino_set_corrupt(sc, ino, bp);
> +		break;
> +	}
>  
>  	/* v1/v2 fields */
>  	switch (dip->di_version) {
> 
> --
> 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