FAILED: patch "[PATCH] s390/zcrypt: Fix buffer over-read in cca_cipher2protkey" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 36b230835b8a008266aad22168ca52afacc8a58d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080522-available-anatomy-75bd@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 36b230835b8a008266aad22168ca52afacc8a58d Mon Sep 17 00:00:00 2001
From: Harald Freudenberger <[email protected]>
Date: Wed, 29 Jul 2026 13:40:09 +0200
Subject: [PATCH] s390/zcrypt: Fix buffer over-read in cca_cipher2protkey
Add validation of both the actual key buffer size and token length fields in all the cca_check_sec*token() functions. Additionally check in cca_gencipherkey() for possible underflow with returned key size.
The CCA token structures contain user-controlled len fields that were used in operations without proper validation against both the actual buffer size and minimum token structure size. An attacker could set this field larger than the actual buffer size, leading to reading beyond buffer boundaries. This may result in a kernel crash or exposure of memory via sending this as part of a request down to the crypto card. Also an attacker could have used a very small len value and thus enforce a buffer under-run which may produce similar effects as a over-read.
So now a key must
- key buf length must be at least sizeof the token struct
- the key len field inside the token must fit into the range of sizeof key token struct ... key buf length
drivers/s390/crypto/pkey_cca.c +5 -10
@@ -236,22 +236,16 @@ static int cca_key2protkey(const struct pkey_apqn *apqns, size_t nr_apqns,if (hdr->type ==TOKTYPE_CCA_INTERNAL && hdr->version ==TOKVER_CCA_AES ) {/* CCA AES data key */ -if (keylen <sizeof (struct secaeskeytoken )) -return -EINVAL ; -if (cca_check_secaeskeytoken (pkey_dbf_info,3 , key,0 )) +if (cca_check_secaeskeytoken (pkey_dbf_info,3 , key, keylen,0 ))return -EINVAL ; }else if (hdr->type ==TOKTYPE_CCA_INTERNAL && hdr->version ==TOKVER_CCA_VLSC ) {/* CCA AES cipher key */ -if (keylen < hdr->len) -return -EINVAL ;if (cca_check_secaescipherkey (pkey_dbf_info, -3 , key,0 ,1 )) +3 , key, keylen,0 ,1 ))return -EINVAL ; }else if (hdr->type ==TOKTYPE_CCA_INTERNAL_PKA ) {/* CCA ECC (private) key */ -if (keylen <sizeof (struct eccprivkeytoken )) -return -EINVAL ;if (cca_check_sececckeytoken (pkey_dbf_info,3 , key, keylen,1 ))return -EINVAL ; }else {
@@ -484,7 +478,7 @@ static int cca_verifykey(const u8 *key, u32 keylen, hdr->version == TOKVER_CCA_AES) {struct secaeskeytoken *t = (struct secaeskeytoken *)key; - rc =cca_check_secaeskeytoken (pkey_dbf_info,3 , key,0 ); + rc =cca_check_secaeskeytoken (pkey_dbf_info,3 , key, keylen,0 );if (rc) goto out; *keytype =PKEY_TYPE_CCA_DATA ;
@@ -512,7 +506,8 @@ static int cca_verifykey(const u8 *key, u32 keylen, hdr->version == TOKVER_CCA_VLSC) {struct cipherkeytoken *t = (struct cipherkeytoken *)key; - rc =cca_check_secaescipherkey (pkey_dbf_info,3 , key,0 ,1 ); + rc =cca_check_secaescipherkey (pkey_dbf_info,3 , + key, keylen,0 ,1 );if (rc) goto out; *keytype =PKEY_TYPE_CCA_CIPHER ;
drivers/s390/crypto/zcrypt_ccamisc.c +54 -10
141 lines not on this page · raw message
drivers/s390/crypto/zcrypt_ccamisc.h +3 -3
@@ -136,7 +136,7 @@ struct eccprivkeytoken {* also checked. Returns 0 on success or errno value on failure. */ int cca_check_secaeskeytoken (debug_info_t *dbg,int dbflvl, -const u8 *token,int keybitsize); +const u8 *token,u32 keysize,int keybitsize);/* * Simple check if the token is a valid CCA secure AES cipher key
@@ -146,8 +146,8 @@ int cca_check_secaeskeytoken(debug_info_t *dbg, int dbflvl,* Returns 0 on success or errno value on failure. */ int cca_check_secaescipherkey (debug_info_t *dbg,int dbflvl, -const u8 *token,int keybitsize, -int checkcpacfexport); +const u8 *token,u32 keysize, +int keybitsize,int checkcpacfexport);/* * Simple check if the token is a valid CCA secure ECC private