@@ -229,12 +229,12 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,
229229 * Verify hash of a metadata block pertaining to the specified data block
230230 * ("block" argument) at a specified level ("level" argument).
231231 *
232- * On successful return, verity_io_want_digest(v, io) contains the hash value
233- * for a lower tree level or for the data block (if we're at the lowest level).
232+ * On successful return, want_digest contains the hash value for a lower tree
233+ * level or for the data block (if we're at the lowest level).
234234 *
235235 * If "skip_unverified" is true, unverified buffer is skipped and 1 is returned.
236236 * If "skip_unverified" is false, unverified buffer is hashed and verified
237- * against current value of verity_io_want_digest(v, io) .
237+ * against current value of want_digest .
238238 */
239239static int verity_verify_level (struct dm_verity * v , struct dm_verity_io * io ,
240240 sector_t block , int level , bool skip_unverified ,
@@ -273,7 +273,7 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
273273 if (IS_ERR (data ))
274274 return r ;
275275 if (verity_fec_decode (v , io , DM_VERITY_BLOCK_TYPE_METADATA ,
276- hash_block , data ) == 0 ) {
276+ want_digest , hash_block , data ) == 0 ) {
277277 aux = dm_bufio_get_aux_data (buf );
278278 aux -> hash_verified = 1 ;
279279 goto release_ok ;
@@ -293,11 +293,11 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
293293 }
294294
295295 r = verity_hash (v , io , data , 1 << v -> hash_dev_block_bits ,
296- verity_io_real_digest ( v , io ) );
296+ io -> tmp_digest );
297297 if (unlikely (r < 0 ))
298298 goto release_ret_r ;
299299
300- if (likely (memcmp (verity_io_real_digest ( v , io ) , want_digest ,
300+ if (likely (memcmp (io -> tmp_digest , want_digest ,
301301 v -> digest_size ) == 0 ))
302302 aux -> hash_verified = 1 ;
303303 else if (static_branch_unlikely (& use_bh_wq_enabled ) && io -> in_bh ) {
@@ -308,7 +308,7 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
308308 r = - EAGAIN ;
309309 goto release_ret_r ;
310310 } else if (verity_fec_decode (v , io , DM_VERITY_BLOCK_TYPE_METADATA ,
311- hash_block , data ) == 0 )
311+ want_digest , hash_block , data ) == 0 )
312312 aux -> hash_verified = 1 ;
313313 else if (verity_handle_err (v ,
314314 DM_VERITY_BLOCK_TYPE_METADATA ,
@@ -372,7 +372,8 @@ int verity_hash_for_block(struct dm_verity *v, struct dm_verity_io *io,
372372}
373373
374374static noinline int verity_recheck (struct dm_verity * v , struct dm_verity_io * io ,
375- sector_t cur_block , u8 * dest )
375+ const u8 * want_digest , sector_t cur_block ,
376+ u8 * dest )
376377{
377378 struct page * page ;
378379 void * buffer ;
@@ -396,12 +397,11 @@ static noinline int verity_recheck(struct dm_verity *v, struct dm_verity_io *io,
396397 goto free_ret ;
397398
398399 r = verity_hash (v , io , buffer , 1 << v -> data_dev_block_bits ,
399- verity_io_real_digest ( v , io ) );
400+ io -> tmp_digest );
400401 if (unlikely (r ))
401402 goto free_ret ;
402403
403- if (memcmp (verity_io_real_digest (v , io ),
404- verity_io_want_digest (v , io ), v -> digest_size )) {
404+ if (memcmp (io -> tmp_digest , want_digest , v -> digest_size )) {
405405 r = - EIO ;
406406 goto free_ret ;
407407 }
@@ -416,8 +416,9 @@ static noinline int verity_recheck(struct dm_verity *v, struct dm_verity_io *io,
416416
417417static int verity_handle_data_hash_mismatch (struct dm_verity * v ,
418418 struct dm_verity_io * io ,
419- struct bio * bio , sector_t blkno ,
420- u8 * data )
419+ struct bio * bio ,
420+ const u8 * want_digest ,
421+ sector_t blkno , u8 * data )
421422{
422423 if (static_branch_unlikely (& use_bh_wq_enabled ) && io -> in_bh ) {
423424 /*
@@ -426,14 +427,14 @@ static int verity_handle_data_hash_mismatch(struct dm_verity *v,
426427 */
427428 return - EAGAIN ;
428429 }
429- if (verity_recheck (v , io , blkno , data ) == 0 ) {
430+ if (verity_recheck (v , io , want_digest , blkno , data ) == 0 ) {
430431 if (v -> validated_blocks )
431432 set_bit (blkno , v -> validated_blocks );
432433 return 0 ;
433434 }
434435#if defined(CONFIG_DM_VERITY_FEC )
435- if (verity_fec_decode (v , io , DM_VERITY_BLOCK_TYPE_DATA , blkno ,
436- data ) == 0 )
436+ if (verity_fec_decode (v , io , DM_VERITY_BLOCK_TYPE_DATA , want_digest ,
437+ blkno , data ) == 0 )
437438 return 0 ;
438439#endif
439440 if (bio -> bi_status )
@@ -525,8 +526,9 @@ static int verity_verify_io(struct dm_verity_io *io)
525526 kunmap_local (data );
526527 continue ;
527528 }
528- r = verity_handle_data_hash_mismatch (v , io , bio , cur_block ,
529- data );
529+ r = verity_handle_data_hash_mismatch (v , io , bio ,
530+ verity_io_want_digest (v , io ),
531+ cur_block , data );
530532 kunmap_local (data );
531533 if (unlikely (r ))
532534 return r ;
0 commit comments