• Nikos Tsironis's avatar
    dm clone: Add overflow check for number of regions · cd481c12
    Nikos Tsironis authored
    Add overflow check for clone->nr_regions variable, which holds the
    number of regions of the target.
    
    The overflow can occur with sufficiently large devices, if BITS_PER_LONG
    == 32. E.g., if the region size is 8 sectors (4K), the overflow would
    occur for device sizes > 34359738360 sectors (~16TB).
    
    This could result in multiple device sectors wrongly mapping to the same
    region number, due to the truncation from 64 bits to 32 bits, which
    would lead to data corruption.
    
    Fixes: 7431b783 ("dm: add clone target")
    Cc: stable@vger.kernel.org # v5.4+
    Signed-off-by: default avatarNikos Tsironis <ntsironis@arrikto.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    cd481c12
dm-clone-target.c 55.4 KB