Re: [PATCH 1/2] btrfs-progs: check: Detect file extent end overflow

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

 



On Wed, Feb 19, 2020 at 07:37:02PM +0800, Qu Wenruo wrote:
> >> @@ -1595,6 +1597,8 @@ static int process_file_extent(struct btrfs_root *root,
> >>  		num_bytes = btrfs_file_extent_num_bytes(eb, fi);
> >>  		disk_bytenr = btrfs_file_extent_disk_bytenr(eb, fi);
> >>  		extent_offset = btrfs_file_extent_offset(eb, fi);
> >> +		if (u64_add_overflow(key->offset, num_bytes))
> >> +			rec->errors |= I_ERR_FILE_EXTENT_OVERFLOW;
> >>  		if (num_bytes == 0 || (num_bytes & mask))
> >>  			rec->errors |= I_ERR_BAD_FILE_EXTENT;
> >>  		if (num_bytes + extent_offset >
> >> diff --git a/check/mode-common.h b/check/mode-common.h
> >> index edf9257edaf0..daa5741e1d67 100644
> >> --- a/check/mode-common.h
> >> +++ b/check/mode-common.h
> >> @@ -173,4 +173,11 @@ static inline u32 btrfs_type_to_imode(u8 type)
> >>
> >>  	return imode_by_btrfs_type[(type)];
> >>  }
> >> +
> >> +static inline bool u64_add_overflow(u64 a, u64 b)
> >
> > Rename this to check_add_overflow and use the generic version from the
> > kernel :
> 
> That's also my first idea.
> 
> But I'm not a fan of the 3rd parameter, and there is no other type other
> than u64, so I hesitate to use the generic one.
> 
> However since you mentioned the kernel one, I guess it's time to
> backport it to user space.

Yes please, copying the support code from kernel is ok.



[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