asymmetric_keys: check asymmetric_key_ids() for NULL before dereference
Subsystems (4)
PATCH v2 1/1 asymmetric_keys: check asymmetric_key_ids() for NULL before dereference
asymmetric_key_ids() returns key->payload.data[asym_key_ids], which can be NULL for keys parsed by the PKCS#8 parser (pkcs8_parser.c explicitly stores NULL in prep->payload.data[asym_key_ids]).
key_or_keyring_common() in restrict.c and find_asymmetric_key() in asymmetric_type.c both dereference this return value without checking for NULL. An unprivileged user can trigger a NULL pointer dereference in key_or_keyring_common() by creating a PKCS#8 key, restricting a keyring with key_or_keyring:<pkcs8_serial>, and adding an X.509 cert to the restricted keyring. CONFIG_PKCS8_PRIVATE_KEY_PARSER=y is required.
The following bash script can reproduce the issue:
#!/bin/bash
modprobe pkcs8_key_parser 2>/dev/null
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:1024 \
-out /tmp/poc.pem 2>/dev/null
openssl pkcs8 -topk8 -nocrypt -in /tmp/poc.pem \
-outform DER -out /tmp/poc.p8
openssl req -new -x509 -key /tmp/poc.pem -outform DER \
-out /tmp/poc.der -days 365 -subj "/CN=Test" \
-addext "subjectKeyIdentifier=hash" \
-addext "authorityKeyIdentifier=keyid:always" 2>/dev/null
PKCS8_ID=$(keyctl padd asymmetric pkcs8key @s < /tmp/poc.p8)
KR=$(keyctl newring test_kr @s)
keyctl restrict_keyring $KR asymmetric "key_or_keyring:$PKCS8_ID"
keyctl padd asymmetric trigger $KR < /tmp/poc.der
rm -f /tmp/poc.pem /tmp/poc.p8 /tmp/poc.derOops: general protection fault, probably for non-canonical address 0xdffffc0000000000 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:key_or_keyring_common (crypto/asymmetric_keys/restrict.c:205 crypto/asymmetric_keys/restrict.c:279) Call Trace: <TASK> __key_create_or_update (security/keys/key.c:884) key_create_or_update (security/keys/key.c:1021) __do_sys_add_key (security/keys/keyctl.c:134) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) </TASK> Kernel panic - not syncing: Fatal exception
Add a NULL check in find_asymmetric_key(), mirroring the existing pattern in asymmetric_match_key_ids() and asymmetric_key_describe(). In key_or_keyring_common(), skip the trusted key matching when it has no key IDs and fall through to the check_dest path.
---
v2: add bash reproducer to commit message (Ignat)
crypto/asymmetric_keys/asymmetric_type.c | 2 ++ crypto/asymmetric_keys/restrict.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
crypto/asymmetric_keys/asymmetric_type.c +2 -0
@@ -109,6 +109,8 @@ struct key *find_asymmetric_key(struct key *keyring,if (id_0 && id_1) {const struct asymmetric_key_ids *kids =asymmetric_key_ids (key); +if (!kids) + goto reject;if (!kids->id[1 ]) {pr_debug ("First ID matches, but second is missing\n" ); goto reject;
crypto/asymmetric_keys/restrict.c +7 -2
@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key)) key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) + goto skip_trusted; + + signer_ids = (const struct asymmetric_key_id **)kids->id;/* * The auth_ids come from the candidate key (the
@@ -290,6 +294,7 @@ static int key_or_keyring_common(struct key *dest_keyring, } } +skip_trusted:if (check_dest && !key) {/* See if the destination has a key that signed this one. */ key = find_asymmetric_key(dest_keyring, sig->auth_ids[0],
Signature · 1 line
2.43.0
Herbert Xu
maintainerQuoted 51 lines · Weiming Shi
asymmetric_key_ids()returns key->payload.data[asym_key_ids], which can be NULL for keys parsed by the PKCS#8 parser (pkcs8_parser.cexplicitly stores NULL in prep->payload.data[asym_key_ids]).
key_or_keyring_common()inrestrict.candfind_asymmetric_key()inasymmetric_type.cboth dereference this return value without checking for NULL. An unprivileged user can trigger a NULL pointer dereference inkey_or_keyring_common()by creating a PKCS#8 key, restricting a keyring with key_or_keyring:<pkcs8_serial>, and adding an X.509 cert to the restricted keyring.CONFIG_PKCS8_PRIVATE_KEY_PARSER=yis required.The following bash script can reproduce the issue:
#!/bin/bash modprobe pkcs8_key_parser 2>/dev/null openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:1024 \ -out /tmp/poc.pem 2>/dev/null openssl pkcs8 -topk8 -nocrypt -in /tmp/poc.pem \ -outform DER -out /tmp/poc.p8 openssl req -new -x509 -key /tmp/poc.pem -outform DER \ -out /tmp/poc.der -days 365 -subj "/CN=Test" \ -addext "subjectKeyIdentifier=hash" \ -addext "authorityKeyIdentifier=keyid:always" 2>/dev/null PKCS8_ID=$(keyctl padd asymmetric pkcs8key @s < /tmp/poc.p8) KR=$(keyctl newring test_kr @s) keyctl restrict_keyring $KR asymmetric "key_or_keyring:$PKCS8_ID" keyctl padd asymmetric trigger $KR < /tmp/poc.der rm -f /tmp/poc.pem /tmp/poc.p8 /tmp/poc.derOops: general protection fault, probably for non-canonical address 0xdffffc0000000000 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:key_or_keyring_common (crypto/asymmetric_keys/restrict.c:205 crypto/asymmetric_keys/restrict.c:279) Call Trace: <TASK> __key_create_or_update (security/keys/key.c:884) key_create_or_update (security/keys/key.c:1021) __do_sys_add_key (security/keys/keyctl.c:134) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) </TASK> Kernel panic - not syncing: Fatal exceptionAdd a NULL check in
find_asymmetric_key(), mirroring the existing pattern inasymmetric_match_key_ids()andasymmetric_key_describe(). Inkey_or_keyring_common(), skip the trusted key matching when it has no key IDs and fall through to thecheck_destpath.Fixes 7d30198ee24f ("keys: X.509 public key issuer lookup without AKID")Reported-by Xiang Mei <[email protected]>Signed-off-by Weiming Shi <[email protected]>
Quoted 6 lines
---
v2: add bash reproducer to commit message (Ignat)crypto/asymmetric_keys/asymmetric_type.c | 2 ++ crypto/asymmetric_keys/restrict.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainercrypto/asymmetric_keys/asymmetric_type.c struct key *find_asymmetric_key(struct key *keyring, · line 113
Quoted 11 lines · Weiming Shi
crypto/asymmetric_keys/asymmetric_type.c +2
-0@@ -109,6 +109,8 @@ struct key *find_asymmetric_key(struct key *keyring,if (id_0 && id_1) {const struct asymmetric_key_ids *kids =asymmetric_key_ids (key); +if (!kids) + goto reject;
This check is actually unnecessary because we've already matched the key against the kid so it must be present.
I'd get rid of this check or perhaps add a comment instead.
Quoted 9 lines
crypto/asymmetric_keys/asymmetric_type.c +0
-0if (!kids->id[1 ]) {pr_debug ("First ID matches, but second is missing\n" ); goto reject;crypto/asymmetric_keys/restrict.c +0
-0@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key))
crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 251
Quoted 10 lines
crypto/asymmetric_keys/restrict.c +4
-2key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) + goto skip_trusted;
Yes this is definitely buggy.
I think it was introduced by these two commits:
commit 3c58b2362ba828ee2970c66c6a6fd7b04fde4413
Author: David Howells <[email protected]> Date: Tue Oct 9 17:47:46 2018 +0100
KEYS: Implement PKCS#8 RSA Private Key parser [ver #2]
and
commit 7e3c4d22083f6e7316c5229b6197ca2d5335aa35
Author: Mat Martineau <[email protected]> Date: Mon Jun 27 16:45:16 2016 -0700
KEYS: Restrict asymmetric key linkage using a specific keychain
So the Fixes header should point to them.
crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 300
Quoted 8 lines
crypto/asymmetric_keys/restrict.c +1
-0@@ -290,6 +294,7 @@ static int key_or_keyring_common(struct key *dest_keyring, } } +skip_trusted:if (check_dest && !key) {/* See if the destination has a key that signed this one. */ key = find_asymmetric_key(dest_keyring, sig->auth_ids[0],
I'm not sure continuing here is a good idea. Having a private key here makes no sense whatsoever and we should just bail out right away.
I would recommend returning an error of some sort if kids is NULL.
David/Lukas/Ignat, any opinions?
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Jarkko Sakkinen
maintainerQuoted 10 lines · Herbert Xu
Quoted 9 lines · Weiming Shi
crypto/asymmetric_keys/asymmetric_type.c +0
-0@@ -109,6 +109,8 @@ struct key *find_asymmetric_key(struct key *keyring,if (id_0 && id_1) {const struct asymmetric_key_ids *kids =asymmetric_key_ids (key);
Quoted 7 lines
crypto/asymmetric_keys/asymmetric_type.c struct key *find_asymmetric_key(struct key *keyring, · line 113
Quoted 2 lines
crypto/asymmetric_keys/asymmetric_type.c +2
-0+if (!kids) + goto reject;This check is actually unnecessary because we've already matched the key against the kid so it must be present.
I'd get rid of this check or perhaps add a comment instead.
+1
Quoted 33 lines
Quoted 10 lines
crypto/asymmetric_keys/asymmetric_type.c +0
-0if (!kids->id[1 ]) {pr_debug ("First ID matches, but second is missing\n" ); goto reject;crypto/asymmetric_keys/restrict.c +0
-0@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key))crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 251
Quoted 10 lines
crypto/asymmetric_keys/restrict.c +4
-2key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) + goto skip_trusted;Yes this is definitely buggy.
I think it was introduced by these two commits:
commit
3c58b2362ba828ee2970c66c6a6fd7b04fde4413Author: David Howells <[email protected]> Date: Tue Oct 9 17:47:46 2018 +0100KEYS: Implement PKCS#8 RSA Private Key parser [ver #2]
and
Quoted 7 lines
commit
7e3c4d22083f6e7316c5229b6197ca2d5335aa35Author: Mat Martineau <[email protected]> Date: Mon Jun 27 16:45:16 2016 -0700KEYS: Restrict asymmetric key linkage using a specific keychain
So the Fixes header should point to them.
+1
Quoted 14 lines
crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 300
Quoted 9 lines
crypto/asymmetric_keys/restrict.c +1
-0@@ -290,6 +294,7 @@ static int key_or_keyring_common(struct key *dest_keyring, } } +skip_trusted:if (check_dest && !key) {/* See if the destination has a key that signed this one. */ key = find_asymmetric_key(dest_keyring, sig->auth_ids[0],I'm not sure continuing here is a good idea. Having a private key here makes no sense whatsoever and we should just bail out right away.
Quoted 3 lines
I would recommend returning an error of some sort if kids is NULL.
David/Lukas/Ignat, any opinions?
I think with a quick skim that you are right. I'll work on this area for the next version.
Quoted 6 lines
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Thanks for the review!
BR, Jarkko
Ignat Korchagin
maintainerQuoted 59 lines · Jarkko Sakkinen
Quoted 10 lines · Herbert Xu
Quoted 9 lines · Weiming Shi
crypto/asymmetric_keys/asymmetric_type.c +0
-0@@ -109,6 +109,8 @@ struct key *find_asymmetric_key(struct key *keyring,if (id_0 && id_1) {const struct asymmetric_key_ids *kids =asymmetric_key_ids (key);Quoted 7 lines
crypto/asymmetric_keys/asymmetric_type.c struct key *find_asymmetric_key(struct key *keyring, · line 113
Quoted 2 lines
crypto/asymmetric_keys/asymmetric_type.c +2
-0+if (!kids) + goto reject;This check is actually unnecessary because we've already matched the key against the kid so it must be present.
I'd get rid of this check or perhaps add a comment instead.
+1
Quoted 37 lines
Quoted 10 lines
crypto/asymmetric_keys/asymmetric_type.c +0
-0if (!kids->id[1 ]) {pr_debug ("First ID matches, but second is missing\n" ); goto reject;crypto/asymmetric_keys/restrict.c +0
-0@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key))crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 251
Quoted 10 lines
crypto/asymmetric_keys/restrict.c +4
-2key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) + goto skip_trusted;Yes this is definitely buggy.
I think it was introduced by these two commits:
commit
3c58b2362ba828ee2970c66c6a6fd7b04fde4413Author: David Howells <[email protected]> Date: Tue Oct 9 17:47:46 2018 +0100KEYS: Implement PKCS#8 RSA Private Key parser [ver #2]
and
commit
7e3c4d22083f6e7316c5229b6197ca2d5335aa35Author: Mat Martineau <[email protected]> Date: Mon Jun 27 16:45:16 2016 -0700
Quoted 23 lines
Quoted 3 lines
KEYS: Restrict asymmetric key linkage using a specific keychain
So the Fixes header should point to them.
+1
Quoted 17 lines
crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 300
Quoted 9 lines
crypto/asymmetric_keys/restrict.c +1
-0@@ -290,6 +294,7 @@ static int key_or_keyring_common(struct key *dest_keyring, } } +skip_trusted:if (check_dest && !key) {/* See if the destination has a key that signed this one. */ key = find_asymmetric_key(dest_keyring, sig->auth_ids[0],I'm not sure continuing here is a good idea. Having a private key here makes no sense whatsoever and we should just bail out right away.
I would recommend returning an error of some sort if kids is NULL.
David/Lukas/Ignat, any opinions?
As I reread the original submission (somehow I never got the V2) it seems we're restricting a keyring with a private key?! Which indeed does not make sense.
Quoted 15 lines
I think with a quick skim that you are right. I'll work on this area for the next version.
Quoted 6 lines
Thanks,
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtThanks for the review!
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 80 lines · Ignat Korchagin
Quoted 79 lines · Jarkko Sakkinen
Quoted 10 lines · Herbert Xu
Quoted 9 lines · Weiming Shi
crypto/asymmetric_keys/asymmetric_type.c +0
-0@@ -109,6 +109,8 @@ struct key *find_asymmetric_key(struct key *keyring,if (id_0 && id_1) {const struct asymmetric_key_ids *kids =asymmetric_key_ids (key);Quoted 7 lines
crypto/asymmetric_keys/asymmetric_type.c struct key *find_asymmetric_key(struct key *keyring, · line 113
Quoted 2 lines
crypto/asymmetric_keys/asymmetric_type.c +2
-0+if (!kids) + goto reject;This check is actually unnecessary because we've already matched the key against the kid so it must be present.
I'd get rid of this check or perhaps add a comment instead.
+1
Quoted 33 lines
Quoted 10 lines
crypto/asymmetric_keys/asymmetric_type.c +0
-0if (!kids->id[1 ]) {pr_debug ("First ID matches, but second is missing\n" ); goto reject;crypto/asymmetric_keys/restrict.c +0
-0@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key))crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 251
Quoted 10 lines
crypto/asymmetric_keys/restrict.c +4
-2key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) + goto skip_trusted;Yes this is definitely buggy.
I think it was introduced by these two commits:
commit
3c58b2362ba828ee2970c66c6a6fd7b04fde4413Author: David Howells <[email protected]> Date: Tue Oct 9 17:47:46 2018 +0100KEYS: Implement PKCS#8 RSA Private Key parser [ver #2]
and
Quoted 7 lines
commit
7e3c4d22083f6e7316c5229b6197ca2d5335aa35Author: Mat Martineau <[email protected]> Date: Mon Jun 27 16:45:16 2016 -0700KEYS: Restrict asymmetric key linkage using a specific keychain
So the Fixes header should point to them.
+1
Quoted 14 lines
crypto/asymmetric_keys/restrict.c static int key_or_keyring_common(struct key *dest_keyring, · line 300
Quoted 9 lines
crypto/asymmetric_keys/restrict.c +1
-0@@ -290,6 +294,7 @@ static int key_or_keyring_common(struct key *dest_keyring, } } +skip_trusted:if (check_dest && !key) {/* See if the destination has a key that signed this one. */ key = find_asymmetric_key(dest_keyring, sig->auth_ids[0],I'm not sure continuing here is a good idea. Having a private key here makes no sense whatsoever and we should just bail out right away.
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
I would recommend returning an error of some sort if kids is NULL.
David/Lukas/Ignat, any opinions?
As I reread the original submission (somehow I never got the V2) it seems we're restricting a keyring with a private key?! Which indeed does not make sense.
Quoted 2 lines
I think with a quick skim that you are right. I'll work on this area for the next version.
BTW I was writing two emails simulatenously this last sentence was for private email discussion.
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Thanks,
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtThanks for the review!
And this.
Quoted 4 lines
Quoted 4 lines
BR, Jarkko
+1's were for the discussion. Sorry, I should not multitask with emails...
BR, Jarkko
PATCH v3 1/1 asymmetric_keys: reject trust keys without IDs
In reply to Weiming ShiThe PKCS#8 parser deliberately leaves the asym_key_ids payload slot empty. key_or_keyring_common() unconditionally dereferences that slot when a PKCS#8 key is supplied to a key_or_keyring restriction. Both the plain and :chain forms reach this branch, allowing an unprivileged caller to trigger a NULL pointer dereference through KEYCTL_RESTRICT_KEYRING followed by add_key().
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:key_or_keyring_common (crypto/asymmetric_keys/restrict.c:205 crypto/asymmetric_keys/restrict.c:279) Call Trace: <TASK> __key_create_or_update (security/keys/key.c:884) key_create_or_update (security/keys/key.c:1021) __do_sys_add_key (security/keys/keyctl.c:134) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) </TASK> Kernel panic - not syncing: Fatal exception
Reject an asymmetric restriction key without key IDs. A PKCS#8 private key cannot identify the signer of a candidate certificate and is not a valid trust anchor.
---
Changes in v3:
- Drop the unnecessary find_asymmetric_key() check.
- Reject a trust key without IDs instead of continuing the chain lookup.
- Use the PKCS#8 parser commit as the Fixes target.
crypto/asymmetric_keys/restrict.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
crypto/asymmetric_keys/restrict.c +6 -2
@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key)) key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) +return -ENOKEY ; + + signer_ids = (const struct asymmetric_key_id **)kids->id;/* * The auth_ids come from the candidate key (the
Signature · 1 line
2.55.0
Herbert Xu
maintainerRe: [PATCH v3] asymmetric_keys: reject trust keys without IDs
Quoted 30 lines · Weiming Shi
The PKCS#8 parser deliberately leaves the
asym_key_idspayload slot empty.key_or_keyring_common()unconditionally dereferences that slot when a PKCS#8 key is supplied to akey_or_keyringrestriction. Both the plain and :chain forms reach this branch, allowing an unprivileged caller to trigger a NULL pointer dereference throughKEYCTL_RESTRICT_KEYRINGfollowed byadd_key().Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:key_or_keyring_common (crypto/asymmetric_keys/restrict.c:205 crypto/asymmetric_keys/restrict.c:279) Call Trace: <TASK> __key_create_or_update (security/keys/key.c:884) key_create_or_update (security/keys/key.c:1021) __do_sys_add_key (security/keys/keyctl.c:134) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) </TASK> Kernel panic - not syncing: Fatal exceptionReject an asymmetric restriction key without key IDs. A PKCS#8 private key cannot identify the signer of a candidate certificate and is not a valid trust anchor.
Fixes 3c58b2362ba8 ("KEYS: Implement PKCS#8 RSA Private Key parser [ver #2]")Reported-by Xiang Mei <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Weiming Shi <[email protected]>
Quoted 8 lines
---
Changes in v3:
- Drop the unnecessaryfind_asymmetric_key()check.
- Reject a trust key without IDs instead of continuing the chain lookup.
- Use the PKCS#8 parser commit as the Fixes target.crypto/asymmetric_keys/restrict.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt