Skip to content

Commit 754e9e4

Browse files
holger-denglerVasily Gorbik
authored andcommitted
pkey: Move keytype check from pkey api to handler
The PKEY_VERIFYPROTK ioctl takes data from user-space and verifies the contained protected key. While checking the integrity of the ioctl request structure is the responsibility of the generic pkey_api code, the verification of the contained protected key is the responsibility of the pkey handler. The keytype verification (based on the calculated bitsize of the key) is part of the protected key verification and therefore the responsibility of the pkey handler (which already verifies it). Therefore the keytype verification is removed from the generic pkey_api code. As the calculation of the key bitsize is currently wrong, the removal of the keytype check in pkey_api also removes this wrong calculation. For this reason, the commit is flagged with the Fixes: tag. Cc: stable@kernel.org # 6.12+ Fixes: 8fcc231 ("s390/pkey: Introduce pkey base with handler registry and handler modules") Reviewed-by: Ingo Franzki <ifranzki@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> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent dc59e4f commit 754e9e4

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

drivers/s390/crypto/pkey_api.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
327327
{
328328
struct pkey_verifyprotk kvp;
329329
struct protaeskeytoken *t;
330-
u32 keytype;
331330
u8 *tmpbuf;
332331
int rc;
333332

@@ -341,14 +340,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
341340
return -EINVAL;
342341
}
343342

344-
keytype = pkey_aes_bitsize_to_keytype(8 * kvp.protkey.len);
345-
if (!keytype) {
346-
PKEY_DBF_ERR("%s unknown/unsupported protkey length %u\n",
347-
__func__, kvp.protkey.len);
348-
memzero_explicit(&kvp, sizeof(kvp));
349-
return -EINVAL;
350-
}
351-
352343
/* build a 'protected key token' from the raw protected key */
353344
tmpbuf = kzalloc(sizeof(*t), GFP_KERNEL);
354345
if (!tmpbuf) {
@@ -358,7 +349,7 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
358349
t = (struct protaeskeytoken *)tmpbuf;
359350
t->type = TOKTYPE_NON_CCA;
360351
t->version = TOKVER_PROTECTED_KEY;
361-
t->keytype = keytype;
352+
t->keytype = kvp.protkey.type;
362353
t->len = kvp.protkey.len;
363354
memcpy(t->protkey, kvp.protkey.protkey, kvp.protkey.len);
364355

0 commit comments

Comments
 (0)