projects/linux·commit 152d0bcd

dm crypt: Fix reqsize in crypt_iv_eboiv_gen

152d0bcd · Herbert Xu <[email protected]> · 2023-10-06 09:41:55 +08:00

A skcipher_request object is made up of struct skcipher_request
followed by a variable-sized trailer.  The allocation of the
skcipher_request and IV in crypt_iv_eboiv_gen is missing the
memory for struct skcipher_request.  Fix it by adding it to
reqsize.

Fixes: e3023094dffb ("dm crypt: Avoid using MAX_CIPHER_BLOCKSIZE")
Cc: <[email protected]> #6.5+
Reported-by: Tatu Heikkilä <[email protected]>
Reviewed-by: Mike Snitzer <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Commit
152d0bcdf1efcb54a4fa20f694e9c7bbb6d06cbf
Parents
21155620

Changes

1 files changed · +2 −1

FileStatusAddDelContent
drivers/md/dm-crypt.cmodified+2−1View file

drivers/md/dm-crypt.c

View file
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index f2662c2..5315fd2 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -753,7 +753,8 @@ static int crypt_iv_eboiv_gen(struct crypt_config *cc, u8 *iv,
int err;
u8 *buf;
- reqsize = ALIGN(crypto_skcipher_reqsize(tfm), __alignof__(__le64));
+ reqsize = sizeof(*req) + crypto_skcipher_reqsize(tfm);
+ reqsize = ALIGN(reqsize, __alignof__(__le64));
req = kmalloc(reqsize + cc->iv_size, GFP_NOIO);
if (!req)