fixup! s390/zcrypt: Rework cca findcard() implementation and callers
Subsystems (2)
Harald Freudenberger
maintainerPATCH 1/1 fixup! s390/zcrypt: Rework cca findcard() implementation and callers
Ci run of the night showed that a CCA secure key which maches to an old MK on the HSM is not correctly verified. The code builds up an array with a given apqn array with a fixed arraysize and calls findcard2() for the CURRENT MK which fails as expected. So next attempt is made with trying to match the OLD MK with same apqn array and same arraysize variable. But the previous call hat set this arraysize variable to 0 and so the 2nd invocation finds a valid apqn but the arraysize variable tells there is no space in the array. Fixed and tested.
--- drivers/s390/crypto/pkey_cca.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/crypto/pkey_cca.c +2 -0
@@ -487,6 +487,7 @@ static int cca_verifykey(const u8 *key, u32 keylen,if (!rc) *flags =PKEY_FLAGS_MATCH_CUR_MKVP ;if (rc == -ENODEV ) { + nr_apqns =ARRAY_SIZE (apqns); rc =cca_findcard2 (apqns, &nr_apqns, *card, *dom,ZCRYPT_CEX3C ,AES_MK_SET ,0 , t->mkvp, xflags);
@@ -520,6 +521,7 @@ static int cca_verifykey(const u8 *key, u32 keylen,if (!rc) *flags =PKEY_FLAGS_MATCH_CUR_MKVP ;if (rc == -ENODEV ) { + nr_apqns =ARRAY_SIZE (apqns); rc =cca_findcard2 (apqns, &nr_apqns, *card, *dom,ZCRYPT_CEX6 ,AES_MK_SET ,0 , t->mkvp0, xflags);
Signature · 1 line
2.43.0
Quoted 10 lines · Harald Freudenberger
Ci run of the night showed that a CCA secure key which maches to an old MK on the HSM is not correctly verified. The code builds up an array with a given apqn array with a fixed arraysize and calls
findcard2()for the CURRENT MK which fails as expected. So next attempt is made with trying to match the OLD MK with same apqn array and same arraysize variable. But the previous call hat set this arraysize variable to 0 and so the 2nd invocation finds a valid apqn but the arraysize variable tells there is no space in the array. Fixed and tested.
Quoted 5 lines
Signed-off-by Harald Freudenberger <[email protected]>Reported-by Ingo Franzki [email protected]--- drivers/s390/crypto/pkey_cca.c | 2 ++ 1 file changed, 2 insertions(+)
Merged into your previous patch. Thanks!