mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 09:55:19 +02:00
BACKPORT: FROMLIST: dm-verity: move data hash mismatch handling into its own function
Move the code that handles mismatches of data block hashes into its own function so that it doesn't clutter up verity_verify_io(). Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Eric Biggers <ebiggers@google.com> Bug: 330611177 Link: https://lore.kernel.org/r/20240621165922.77672-9-ebiggers@kernel.org (resolved conflict due to missing the upstream commit "dm-verity: Convert from tasklet to BH workqueue", which is hard to cherry-pick because it depends on workqueue subsystem changes) Change-Id: I891196793e7a0fb136dbc339b520e553ea17869b Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
parent
76fed9f013
commit
7958bb4e87
|
@ -543,6 +543,38 @@ free_ret:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int verity_handle_data_hash_mismatch(struct dm_verity *v,
|
||||||
|
struct dm_verity_io *io,
|
||||||
|
struct bio *bio, sector_t blkno,
|
||||||
|
struct bvec_iter *start)
|
||||||
|
{
|
||||||
|
if (static_branch_unlikely(&use_tasklet_enabled) && io->in_tasklet) {
|
||||||
|
/*
|
||||||
|
* Error handling code (FEC included) cannot be run in a
|
||||||
|
* tasklet since it may sleep, so fallback to work-queue.
|
||||||
|
*/
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
if (verity_recheck(v, io, *start, blkno) == 0) {
|
||||||
|
if (v->validated_blocks)
|
||||||
|
set_bit(blkno, v->validated_blocks);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#if defined(CONFIG_DM_VERITY_FEC)
|
||||||
|
if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA, blkno,
|
||||||
|
NULL, start) == 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
if (bio->bi_status)
|
||||||
|
return -EIO; /* Error correction failed; Just return error */
|
||||||
|
|
||||||
|
if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA, blkno)) {
|
||||||
|
dm_audit_log_bio(DM_MSG_PREFIX, "verify-data", bio, blkno, 0);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int verity_bv_zero(struct dm_verity *v, struct dm_verity_io *io,
|
static int verity_bv_zero(struct dm_verity *v, struct dm_verity_io *io,
|
||||||
u8 *data, size_t len)
|
u8 *data, size_t len)
|
||||||
{
|
{
|
||||||
|
@ -635,36 +667,11 @@ static int verity_verify_io(struct dm_verity_io *io)
|
||||||
if (v->validated_blocks)
|
if (v->validated_blocks)
|
||||||
set_bit(cur_block, v->validated_blocks);
|
set_bit(cur_block, v->validated_blocks);
|
||||||
continue;
|
continue;
|
||||||
} else if (static_branch_unlikely(&use_tasklet_enabled) &&
|
|
||||||
io->in_tasklet) {
|
|
||||||
/*
|
|
||||||
* Error handling code (FEC included) cannot be run in a
|
|
||||||
* tasklet since it may sleep, so fallback to work-queue.
|
|
||||||
*/
|
|
||||||
return -EAGAIN;
|
|
||||||
} else if (verity_recheck(v, io, start, cur_block) == 0) {
|
|
||||||
if (v->validated_blocks)
|
|
||||||
set_bit(cur_block, v->validated_blocks);
|
|
||||||
continue;
|
|
||||||
#if defined(CONFIG_DM_VERITY_FEC)
|
|
||||||
} else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA,
|
|
||||||
cur_block, NULL, &start) == 0) {
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
if (bio->bi_status) {
|
|
||||||
/*
|
|
||||||
* Error correction failed; Just return error
|
|
||||||
*/
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
|
|
||||||
cur_block)) {
|
|
||||||
dm_audit_log_bio(DM_MSG_PREFIX, "verify-data",
|
|
||||||
bio, cur_block, 0);
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
r = verity_handle_data_hash_mismatch(v, io, bio, cur_block,
|
||||||
|
&start);
|
||||||
|
if (unlikely(r))
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user