Skip to content

Commit 5d84239

Browse files
ebiggerssmb49
authored andcommitted
blk-crypto: fix check for too-large dun_bytes
BugLink: https://bugs.launchpad.net/bugs/1946788 [ Upstream commit cc40b72 ] 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]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Kelsey Skunberg <[email protected]>
1 parent d5c6b03 commit 5d84239

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-crypto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key,
332332
if (mode->keysize == 0)
333333
return -EINVAL;
334334

335-
if (dun_bytes == 0 || dun_bytes > BLK_CRYPTO_MAX_IV_SIZE)
335+
if (dun_bytes == 0 || dun_bytes > mode->ivsize)
336336
return -EINVAL;
337337

338338
if (!is_power_of_2(data_unit_size))

0 commit comments

Comments
 (0)