Skip to contentSkip to conversation

blk-crypto: fix check for too-large dun_bytes

PATCH Applied Eric Biggers 2 participants 2 messages Aug 25, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-crypto: fix check for too-large dun_bytes

From: Eric Biggers <[email protected]>

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 a892c8d52c02 ("block: Inline encryption support for blk-mq")
---
 block/blk-crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-crypto.c +1 -1
index c5bdaafffa29f..103c2e2d50d67 100644
@@ -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))
Signature · 1 line
2.32.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Applied, thanks.

Signature · 1 line
Jens Axboe