• Wu Bo's avatar
    dm verity: initialize fec io before freeing it · 7be05bdf
    Wu Bo authored
    If BIO error, verity_end_io() can call verity_finish_io() before
    verity_fec_init_io(). Therefore, fec_io->rs is not initialized and
    may crash when doing memory freeing in verity_fec_finish_io().
    
    Crash call stack:
     die+0x90/0x2b8
     __do_kernel_fault+0x260/0x298
     do_bad_area+0x2c/0xdc
     do_translation_fault+0x3c/0x54
     do_mem_abort+0x54/0x118
     el1_abort+0x38/0x5c
     el1h_64_sync_handler+0x50/0x90
     el1h_64_sync+0x64/0x6c
     free_rs+0x18/0xac
     fec_rs_free+0x10/0x24
     mempool_free+0x58/0x148
     verity_fec_finish_io+0x4c/0xb0
     verity_end_io+0xb8/0x150
    
    Cc: stable@vger.kernel.org      # v6.0+
    Fixes: 5721d4e5 ("dm verity: Add optional "try_verify_in_tasklet" feature")
    Signed-off-by: default avatarWu Bo <bo.wu@vivo.com>
    Reviewed-by: default avatarMikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
    7be05bdf
dm-verity-target.c 37.4 KB