Skip to content

Commit 6b8fdea

Browse files
mbrozgregkh
authored andcommitted
dm crypt: fix crash by adding missing check for auth key size
commit 27c7003 upstream. If dm-crypt uses authenticated mode with separate MAC, there are two concatenated part of the key structure - key(s) for encryption and authentication key. Add a missing check for authenticated key length. If this key length is smaller than actually provided key, dm-crypt now properly fails instead of crashing. Fixes: ef43aa3 ("dm crypt: add cryptographic data integrity protection (authenticated encryption)") Reported-by: Salah Coronya <salahx@yahoo.com> Signed-off-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c808f1d commit 6b8fdea

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/md/dm-crypt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,15 @@ static int crypt_setkey(struct crypt_config *cc)
19541954
/* Ignore extra keys (which are used for IV etc) */
19551955
subkey_size = crypt_subkey_size(cc);
19561956

1957-
if (crypt_integrity_hmac(cc))
1957+
if (crypt_integrity_hmac(cc)) {
1958+
if (subkey_size < cc->key_mac_size)
1959+
return -EINVAL;
1960+
19581961
crypt_copy_authenckey(cc->authenc_key, cc->key,
19591962
subkey_size - cc->key_mac_size,
19601963
cc->key_mac_size);
1964+
}
1965+
19611966
for (i = 0; i < cc->tfms_count; i++) {
19621967
if (crypt_integrity_hmac(cc))
19631968
r = crypto_aead_setkey(cc->cipher_tfm.tfms_aead[i],

0 commit comments

Comments
 (0)