]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/pkey: Check length in pkey_pckmo handler implementation
authorHolger Dengler <dengler@linux.ibm.com>
Wed, 17 Jun 2026 17:06:39 +0000 (19:06 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Fri, 19 Jun 2026 12:51:08 +0000 (14:51 +0200)
Explicitly check the length of the target buffer in the pkey_pckmo
implementation of the key_to_protkey() handler function. The handler
function fails, if the generated output data exceeds the length of the
provided target buffer.

Cc: stable@vger.kernel.org
Fixes: 8fcc231ce3be ("s390/pkey: Introduce pkey base with handler registry and handler modules")
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/crypto/pkey_pckmo.c

index ea774ab8918064c29d51872918ccef1bc3c1a23b..0cc015cc9f6bd3fda910879ea44c6c7c1ea2ca7c 100644 (file)
@@ -257,6 +257,10 @@ static int pckmo_key2protkey(const u8 *key, u32 keylen,
                                goto out;
                        break;
                }
+               if (t->len > *protkeylen) {
+                       rc = -EINVAL;
+                       goto out;
+               }
                memcpy(protkey, t->protkey, t->len);
                *protkeylen = t->len;
                *protkeytype = t->keytype;