[PATCH dm] dm-crypt: reject integrity_key_size with non-authenc AEAD ciphers
From: xietangxin
Date: Sat Oct 31 2026 - 03:16:13 EST
When integrity_key_size parameter is paired with a pure AEAD cipher that
is not an authenc composite, crypt_ctr_auth_cipher() returns 0 early
without allocating cc->authenc_key, but cc->key_mac_size remains
non-zero because CRYPT_KEY_MAC_SIZE_SET was set during option parsing.
As a result crypt_copy_authenckey() dereferences NULL crashes the kernel.
Reject the contradictory configuration explicitly instead of silently
returning 0, so userspace gets a clear -EINVAL.
Fixes: 4441686b24a1 ("dm-crypt: Allow to specify the integrity key size as option")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: syzbot+ff132cb52bce4f44ecc9@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=ff132cb52bce4f44ecc9
Assisted-by: LLM
Signed-off-by: xietangxin <xietangxin@xxxxxxxxxxxxxx>
---
drivers/md/dm-crypt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 045face6924b..1cab614884b7 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2847,8 +2847,11 @@ static int crypt_ctr_auth_cipher(struct crypt_config *cc, char *cipher_api)
char *start, *end, *mac_alg = NULL;
struct crypto_ahash *mac;
- if (!strstarts(cipher_api, "authenc("))
+ if (!strstarts(cipher_api, "authenc(")) {
+ if (test_bit(CRYPT_KEY_MAC_SIZE_SET, &cc->cipher_flags))
+ return -EINVAL;
return 0;
+ }
start = strchr(cipher_api, '(');
end = strchr(cipher_api, ',');
--
2.43.0