Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btrfs: avoid overflow when sector_t is 32 bit
Jean-Denis Girard noticed commit c821e7f "pass bytes to btrfs_bio_alloc" (https://patchwork.kernel.org/patch/9763081/) introduces a regression on 32 bit machines. When CONFIG_LBDAF is _not_ defined (CONFIG_LBDAF == Support for large (2TB+) block devices and files) sector_t is 32 bit on 32bit machines. In the function submit_extent_page, 'sector' (which is sector_t type) is multiplied by 512 to convert it from sectors to bytes, leading to an overflow when the disk is bigger than 4GB (!). I added a cast to u64 to avoid overflow. Fixes: c821e7f ("btrfs: pass bytes to btrfs_bio_alloc") CC: [email protected] # 4.13+ Signed-off-by: Goffredo Baroncelli <[email protected]> Tested-by: Jean-Denis Girard <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
- Loading branch information