* [PATCH v2 0/1] pkey: Fix for PKEY_VERIFYPROTK ioctl
@ 2026-06-23 10:20 Holger Dengler
2026-06-23 10:20 ` [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl Holger Dengler
0 siblings, 1 reply; 6+ messages in thread
From: Holger Dengler @ 2026-06-23 10:20 UTC (permalink / raw)
To: Harald Freudenberger, Ingo Franzki
Cc: dengler, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev
The PKEY_VERIFYPROTK ioctl is used to verify protected key blobs. The
verification is mainly done y the called handler implementations. The
following patch 1/1 removes the (broken) length check in the generic API
code. The deep-inspection of the key blob is handler-specific.
The v1 of this series has fixed the length calculation for the keysize, so
that the correct keytype can be derived from it. But this is a violation of
the layering in pkey, where only the handlers should have a deep knowledge
of the key blobs. Therefore, v2 now removes the keysize calculation and the
keytype check, as it is always done by the handler.
The v2 has been rebased to the current master, as it adds a missing length
check for the ioctl request structure. This addresses one comment of the
Sashiko AI review.
Changes since v1:
- Remove the keytype check (instead of fix the length calculation)
- Add stable tag
- Rebase to current master
The patch applies to Linus' master branch.
Holger Dengler (1):
pkey: Fix for PKEY_VERIFYPROTK iotl
drivers/s390/crypto/pkey_api.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
base-commit: 502d801f0ab03e4f32f9a33d203154ce84887921
--
2.54.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl
2026-06-23 10:20 [PATCH v2 0/1] pkey: Fix for PKEY_VERIFYPROTK ioctl Holger Dengler
@ 2026-06-23 10:20 ` Holger Dengler
2026-06-23 11:13 ` Alexander Gordeev
2026-06-23 13:28 ` Ingo Franzki
0 siblings, 2 replies; 6+ messages in thread
From: Holger Dengler @ 2026-06-23 10:20 UTC (permalink / raw)
To: Harald Freudenberger, Ingo Franzki
Cc: dengler, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev
Remove the keytype calculation based on key length. The verification,
including the keytype check, is the responsibility of the pkey
handler.
The removal also fixes a bug in the key-length calculation, which is
now no longer required.
Cc: stable@kernel.org # 6.12+
Fixes: 8fcc231ce3be ("s390/pkey: Introduce pkey base with handler registry and handler modules")
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
---
drivers/s390/crypto/pkey_api.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
index 28e1007005f2..5d8f63f390a8 100644
--- a/drivers/s390/crypto/pkey_api.c
+++ b/drivers/s390/crypto/pkey_api.c
@@ -327,7 +327,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
{
struct pkey_verifyprotk kvp;
struct protaeskeytoken *t;
- u32 keytype;
u8 *tmpbuf;
int rc;
@@ -341,14 +340,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
return -EINVAL;
}
- keytype = pkey_aes_bitsize_to_keytype(8 * kvp.protkey.len);
- if (!keytype) {
- PKEY_DBF_ERR("%s unknown/unsupported protkey length %u\n",
- __func__, kvp.protkey.len);
- memzero_explicit(&kvp, sizeof(kvp));
- return -EINVAL;
- }
-
/* build a 'protected key token' from the raw protected key */
tmpbuf = kzalloc(sizeof(*t), GFP_KERNEL);
if (!tmpbuf) {
@@ -358,7 +349,7 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
t = (struct protaeskeytoken *)tmpbuf;
t->type = TOKTYPE_NON_CCA;
t->version = TOKVER_PROTECTED_KEY;
- t->keytype = keytype;
+ t->keytype = kvp.protkey.type;
t->len = kvp.protkey.len;
memcpy(t->protkey, kvp.protkey.protkey, kvp.protkey.len);
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl
2026-06-23 10:20 ` [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl Holger Dengler
@ 2026-06-23 11:13 ` Alexander Gordeev
2026-06-23 13:25 ` Holger Dengler
2026-06-23 13:28 ` Ingo Franzki
1 sibling, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2026-06-23 11:13 UTC (permalink / raw)
To: Holger Dengler
Cc: Harald Freudenberger, Ingo Franzki, linux-s390, Heiko Carstens,
Vasily Gorbik
On Tue, Jun 23, 2026 at 12:20:16PM +0200, Holger Dengler wrote:
> Remove the keytype calculation based on key length. The verification,
> including the keytype check, is the responsibility of the pkey
> handler.
>
> The removal also fixes a bug in the key-length calculation, which is
> now no longer required.
>
> Cc: stable@kernel.org # 6.12+
> Fixes: 8fcc231ce3be ("s390/pkey: Introduce pkey base with handler registry and handler modules")
> Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
> ---
> drivers/s390/crypto/pkey_api.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
The patch description is too indescriptive.
Could you please suggest a more specific one?
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl
2026-06-23 11:13 ` Alexander Gordeev
@ 2026-06-23 13:25 ` Holger Dengler
2026-06-23 13:55 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Holger Dengler @ 2026-06-23 13:25 UTC (permalink / raw)
To: Alexander Gordeev
Cc: Harald Freudenberger, Ingo Franzki, linux-s390, Heiko Carstens,
Vasily Gorbik
On 6/23/26 13:13, Alexander Gordeev wrote:
> On Tue, Jun 23, 2026 at 12:20:16PM +0200, Holger Dengler wrote:
>> Remove the keytype calculation based on key length. The verification,
>> including the keytype check, is the responsibility of the pkey
>> handler.
>>
>> The removal also fixes a bug in the key-length calculation, which is
>> now no longer required.
>>
>> Cc: stable@kernel.org # 6.12+
>> Fixes: 8fcc231ce3be ("s390/pkey: Introduce pkey base with handler registry and handler modules")
>> Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
>> ---
>> drivers/s390/crypto/pkey_api.c | 11 +----------
>> 1 file changed, 1 insertion(+), 10 deletions(-)
>
> The patch description is too indescriptive.
> Could you please suggest a more specific one?
Sure. What about the following:
---
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.
---
>
> Thanks!
--
Mit freundlichen Grüßen / Kind regards
Holger Dengler
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl
2026-06-23 10:20 ` [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl Holger Dengler
2026-06-23 11:13 ` Alexander Gordeev
@ 2026-06-23 13:28 ` Ingo Franzki
1 sibling, 0 replies; 6+ messages in thread
From: Ingo Franzki @ 2026-06-23 13:28 UTC (permalink / raw)
To: Holger Dengler, Harald Freudenberger
Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev
On 23.06.2026 12:20, Holger Dengler wrote:
> Remove the keytype calculation based on key length. The verification,
> including the keytype check, is the responsibility of the pkey
> handler.
>
> The removal also fixes a bug in the key-length calculation, which is
> now no longer required.
>
> Cc: stable@kernel.org # 6.12+
> Fixes: 8fcc231ce3be ("s390/pkey: Introduce pkey base with handler registry and handler modules")
> Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
> ---
> drivers/s390/crypto/pkey_api.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
> index 28e1007005f2..5d8f63f390a8 100644
> --- a/drivers/s390/crypto/pkey_api.c
> +++ b/drivers/s390/crypto/pkey_api.c
> @@ -327,7 +327,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
> {
> struct pkey_verifyprotk kvp;
> struct protaeskeytoken *t;
> - u32 keytype;
> u8 *tmpbuf;
> int rc;
>
> @@ -341,14 +340,6 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
> return -EINVAL;
> }
>
> - keytype = pkey_aes_bitsize_to_keytype(8 * kvp.protkey.len);
> - if (!keytype) {
> - PKEY_DBF_ERR("%s unknown/unsupported protkey length %u\n",
> - __func__, kvp.protkey.len);
> - memzero_explicit(&kvp, sizeof(kvp));
> - return -EINVAL;
> - }
> -
> /* build a 'protected key token' from the raw protected key */
> tmpbuf = kzalloc(sizeof(*t), GFP_KERNEL);
> if (!tmpbuf) {
> @@ -358,7 +349,7 @@ static int pkey_ioctl_verifyprotk(struct pkey_verifyprotk __user *uvp)
> t = (struct protaeskeytoken *)tmpbuf;
> t->type = TOKTYPE_NON_CCA;
> t->version = TOKVER_PROTECTED_KEY;
> - t->keytype = keytype;
> + t->keytype = kvp.protkey.type;
> t->len = kvp.protkey.len;
> memcpy(t->protkey, kvp.protkey.protkey, kvp.protkey.len);
>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
I like your new commit description proposal!
--
Ingo Franzki
eMail: ifranzki@linux.ibm.com
Linux on IBM Z Development
IBM Campus 1, 71139 Ehningen, Germany
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Ehningen / Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM DATA Privacy Statement: https://www.ibm.com/privacy/us/en/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl
2026-06-23 13:25 ` Holger Dengler
@ 2026-06-23 13:55 ` Alexander Gordeev
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Gordeev @ 2026-06-23 13:55 UTC (permalink / raw)
To: Holger Dengler
Cc: Harald Freudenberger, Ingo Franzki, linux-s390, Heiko Carstens,
Vasily Gorbik
On Tue, Jun 23, 2026 at 03:25:51PM +0200, Holger Dengler wrote:
> > The patch description is too indescriptive.
> > Could you please suggest a more specific one?
>
> Sure. What about the following:
...
I rather meant the Subject Line description, but at least Ingo
likes the new commit message better :) Could you send v3, please?
Thanks!
> Mit freundlichen Grüßen / Kind regards
> Holger Dengler
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-23 13:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 10:20 [PATCH v2 0/1] pkey: Fix for PKEY_VERIFYPROTK ioctl Holger Dengler
2026-06-23 10:20 ` [PATCH v2 1/1] pkey: Fix for PKEY_VERIFYPROTK iotl Holger Dengler
2026-06-23 11:13 ` Alexander Gordeev
2026-06-23 13:25 ` Holger Dengler
2026-06-23 13:55 ` Alexander Gordeev
2026-06-23 13:28 ` Ingo Franzki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.