Skip to contentSkip to conversation

zcrypt crt and me fixes

PATCH Applied Harald Freudenberger 4 participants 5 messages Aug 25 – Aug 26

Subsystems (2)
lore
Share & tools
lore

Harald Freudenberger

author maintainer
#0 lore raw

cover zcrypt crt and me fixes

Fixes related to type50 and type6 with RSA CRT and ME.

Changelog:
v0: Just one patch fixes an AI finding with padding when a CRT
CPRB for CCA cards is constructed. Details see patch header.

Harald Freudenberger (1):
s390/zcrypt: Fix uninitialized padding in CRT key structure

 drivers/s390/crypto/zcrypt_cca_key.h | 1 +
 1 file changed, 1 insertion(+)

--
2.43.0

author maintainer
#1 lore raw

PATCH 1/1 s390/zcrypt: Fix uninitialized padding in CRT key structure

The zcrypt_type6_crt_key() function leaves padding bytes uninitialized between key components and the modulus in the CCA CRT key token. These padding bytes are sent to the crypto card, potentially leaking kernel memory contents.

The initial memset() only zeros fixed structure fields, not the flexible array member key_parts[] where the padding resides. While key components are properly copied from userspace, the calculated pad_len bytes between them remain uninitialized.

Fix by explicitly zeroing the padding bytes after copying the CRT key components.

---
 drivers/s390/crypto/zcrypt_cca_key.h | 1 +
 1 file changed, 1 insertion(+)
drivers/s390/crypto/zcrypt_cca_key.h +1 -0
index f5907b67db29..8a69eed75040 100644
@@ -219,6 +219,7 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p)
 	    copy_from_user(key->key_parts + 2 * long_len + 2 * short_len,
 			   crt->u_mult_inv, long_len))
 		return -EFAULT;
+	memset(key->key_parts + 3 * long_len + 2 * short_len, 0, pad_len);
 	memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len,
 	       0xff, crt->inputdatalength);
 	pub = (struct cca_public_sec *)(key->key_parts + key_len);
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v1 1/1] s390/zcrypt: Fix uninitialized padding in CRT key structure

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines

The zcrypt_type6_crt_key() function leaves padding bytes uninitialized between key components and the modulus in the CCA CRT key token. These padding bytes are sent to the crypto card, potentially leaking kernel memory contents.

The initial memset() only zeros fixed structure fields, not the flexible array member key_parts[] where the padding resides. While key components are properly copied from userspace, the calculated pad_len bytes between them remain uninitialized.

Quoted 4 lines

Fix by explicitly zeroing the padding bytes after copying the CRT key components.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH v1 1/1] s390/zcrypt: Fix uninitialized padding in CRT key structure

In reply to Harald Freudenberger
Quoted 18 lines · Harald Freudenberger

The zcrypt_type6_crt_key() function leaves padding bytes uninitialized between key components and the modulus in the CCA CRT key token. These padding bytes are sent to the crypto card, potentially leaking kernel memory contents.

The initial memset() only zeros fixed structure fields, not the flexible array member key_parts[] where the padding resides. While key components are properly copied from userspace, the calculated pad_len bytes between them remain uninitialized.

Fix by explicitly zeroing the padding bytes after copying the CRT key components.

---
  drivers/s390/crypto/zcrypt_cca_key.h | 1 +
  1 file changed, 1 insertion(+)

[ snip ]

maintainer Applied
#4 lore raw
In reply to Harald Freudenberger
Quoted 11 lines · Harald Freudenberger

Fixes related to type50 and type6 with RSA CRT and ME.

Changelog:
v0: Just one patch fixes an AI finding with padding when a CRT
CPRB for CCA cards is constructed. Details see patch header.

Harald Freudenberger (1):
s390/zcrypt: Fix uninitialized padding in CRT key structure

 drivers/s390/crypto/zcrypt_cca_key.h | 1 +
 1 file changed, 1 insertion(+)

Applied, thank you!