]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix defrag 32-bit integer overflow
authorJustin Maggard <jmaggard10@gmail.com>
Tue, 21 Jan 2014 19:18:29 +0000 (11:18 -0800)
committerChris Mason <clm@fb.com>
Tue, 28 Jan 2014 21:20:43 +0000 (13:20 -0800)
commit58cf43f541fcb9b35e1e144ea09989d9c1634135
tree899a43d2fe64b55478215fbb061f963cd87cf549
parentc2562ce6f06d1a0db9704c67cdb6e6d7837594ab
btrfs: fix defrag 32-bit integer overflow

When defragging a very large file, the cluster variable can wrap its 32-bit
signed int type and become negative, which eventually gets passed to
btrfs_force_ra() as a very large unsigned long value.  On 32-bit platforms,
this eventually results in an Oops from the SLAB allocator.

Change the cluster and max_cluster signed int variables to unsigned long to
match the readahead functions.  This also allows the min() comparison in
btrfs_defrag_file() to work as intended.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ioctl.c