]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
btrfs: avoid overflow when sector_t is 32 bit
authorGoffredo Baroncelli <kreijack@inwind.it>
Tue, 3 Oct 2017 17:31:10 +0000 (19:31 +0200)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 19 Oct 2017 14:49:12 +0000 (09:49 -0500)
commit0a03422c08534dbd0684870ace632114860ec7ac
tree1749078d5c21f80d47632e7c24a718f6103ed451
parent98a3644a18e02003ddb933e71c8a499db29b4e61
btrfs: avoid overflow when sector_t is 32 bit

BugLink: http://bugs.launchpad.net/bugs/1723145
commit 2d8ce70a08fe033c904115d59276ad86adeaa337 upstream.

Jean-Denis Girard noticed commit c821e7f3 "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: c821e7f3 ("btrfs: pass bytes to btrfs_bio_alloc")
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Tested-by: Jean-Denis Girard <jd.girard@sysnux.pf>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/btrfs/extent_io.c