• Justin Maggard's avatar
    btrfs: fix defrag 32-bit integer overflow · c41570c9
    Justin Maggard authored
    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: default avatarJosef Bacik <jbacik@fb.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    c41570c9
ioctl.c 115 KB