Re: [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for compressed extent without csum

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

 




On 05/14/2018 03:03 PM, Qu Wenruo wrote:
> There is one report of compressed extent happens in btrfs, but has no
> csum and then leads to possible decompress error screwing up kernel
> memory.
> 
> Although it's a kernel bug, and won't cause problem until compressed
> data get corrupted, let's catch such problem in advance.
> 
> This patch will catch any unexpected compressed extent with:
> 
> 1) 0 or less than expected csum
> 
> 2) nodatasum flag set in the inode item
> 
> This is for lowmem mode.
> 
> Reported-by: James Harvey <jamespharvey20@xxxxxxxxx>
> Issue: #134
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>

Reviewed-by: Su Yue <suy.fnst@xxxxxxxxxxxxxx>

> ---
>  check/mode-lowmem.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index dac3201b7d99..8e6d5e8de12a 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -1543,6 +1543,24 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_key *fkey,
>  			      csum_found);
>  		}
>  	}
> +	/*
> +	 * Extra check for compressed extents.
> +	 * Btrfs doesn't allow NODATASUM and compressed extent co-exist, thus
> +	 * all compressed extent should have csum.
> +	 */
> +	if (compressed && csum_found < search_len) {
> +		error(
> +"root %llu EXTENT_DATA[%llu %llu] compressed extent must have csum, but only %llu bytes has csum, expect %llu",
> +		      root->objectid, fkey->objectid, fkey->offset, csum_found,
> +		      search_len);
> +		err |= CSUM_ITEM_MISSING;
> +	}
> +	if (compressed && nodatasum) {
> +		error(
> +"root %llu EXTENT_DATA[%llu %llu] is compressed, but inode flag doesn't allow it",
> +		      root->objectid, fkey->objectid, fkey->offset);
> +		err |= FILE_EXTENT_ERROR;
> +	}
>  
>  	/* Check EXTENT_DATA hole */
>  	if (!no_holes && *end != fkey->offset) {
> 


Attachment: pEpkey.asc
Description: application/pgp-keys


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux