• Mikulas Patocka's avatar
    dm-integrity: fix a race condition when accessing recalc_sector · f8e1ca92
    Mikulas Patocka authored
    There's a race condition when accessing the variable
    ic->sb->recalc_sector. The function integrity_recalc writes to this
    variable when it makes some progress and the function
    dm_integrity_map_continue may read this variable concurrently.
    
    One problem is that on 32-bit architectures the 64-bit variable is not
    read and written atomically - it may be possible to read garbage if read
    races with write.
    
    Another problem is that memory accesses to this variable are not guarded
    with memory barriers.
    
    This commit fixes the race - it moves reading ic->sb->recalc_sector to an
    earlier place where we hold &ic->endio_wait.lock.
    Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
    Cc: stable@vger.kernel.org
    f8e1ca92
dm-integrity.c 147 KB