Skip to content

Commit

Permalink
blk-crypto: fix check for too-large dun_bytes
Browse files Browse the repository at this point in the history
dun_bytes needs to be less than or equal to the IV size of the
encryption mode, not just less than or equal to BLK_CRYPTO_MAX_IV_SIZE.

Currently this doesn't matter since blk_crypto_init_key() is never
actually passed invalid values, but we might as well fix this.

Fixes: a892c8d ("block: Inline encryption support for blk-mq")
Signed-off-by: Eric Biggers <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
ebiggers authored and axboe committed Aug 25, 2021
1 parent 4d643b6 commit cc40b72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/blk-crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key,
if (mode->keysize == 0)
return -EINVAL;

if (dun_bytes == 0 || dun_bytes > BLK_CRYPTO_MAX_IV_SIZE)
if (dun_bytes == 0 || dun_bytes > mode->ivsize)
return -EINVAL;

if (!is_power_of_2(data_unit_size))
Expand Down

0 comments on commit cc40b72

Please sign in to comment.