Skip to content

Commit 9d8e700

Browse files
committed
Merge tag 'tpmdd-next-v5.18-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull tpm updates from Jarkko Sakkinen: "In order to split the work a bit we've aligned with David Howells more or less that I take more hardware/firmware aligned keyring patches, and he takes care more of the framework aligned patches. For TPM the patches worth of highlighting are the fixes for refcounting provided by Lino Sanfilippo and James Bottomley. Eric B. has done a bunch obvious (but important) fixes but there's one a bit controversial: removal of asym_tpm. It was added in 2018 when TPM1 was already declared as insecure and world had moved on to TPM2. I don't know how this has passed all the filters but I did not have a chance to see the patches when they were out. I simply cannot commit to maintaining this because it was from all angles just wrong to take it in the first place to the mainline kernel. Nobody should use this module really for anything. Finally, there is a new keyring '.machine' to hold MOK keys ('Machine Owner Keys'). In the mok side MokListTrustedRT UEFI variable can be set, from which kernel knows that MOK keys are kernel trusted keys and they are populated to the machine keyring. This keyring linked to the secondary trusted keyring, which means that can be used like any kernel trusted keys. This keyring of course can be used to hold other MOK'ish keys in other platforms in future" * tag 'tpmdd-next-v5.18-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: (24 commits) tpm: use try_get_ops() in tpm-space.c KEYS: asymmetric: properly validate hash_algo and encoding KEYS: asymmetric: enforce that sig algo matches key algo KEYS: remove support for asym_tpm keys tpm: fix reference counting for struct tpm_chip integrity: Only use machine keyring when uefi_check_trust_mok_keys is true integrity: Trust MOK keys if MokListTrustedRT found efi/mokvar: move up init order KEYS: Introduce link restriction for machine keys KEYS: store reference to machine keyring integrity: add new keyring handler for mok keys integrity: Introduce a Linux keyring called machine integrity: Fix warning about missing prototypes KEYS: trusted: Avoid calling null function trusted_key_exit KEYS: trusted: Fix trusted key backends when building as module tpm: xen-tpmfront: Use struct_size() helper KEYS: x509: remove dead code that set ->unsupported_sig KEYS: x509: remove never-set ->unsupported_key flag KEYS: x509: remove unused fields KEYS: x509: clearly distinguish between key and signature algorithms ...
2 parents f443e37 + fb5abce commit 9d8e700

32 files changed

Lines changed: 486 additions & 1273 deletions

certs/system_keyring.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ static struct key *builtin_trusted_keys;
2222
#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
2323
static struct key *secondary_trusted_keys;
2424
#endif
25+
#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
26+
static struct key *machine_trusted_keys;
27+
#endif
2528
#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING
2629
static struct key *platform_trusted_keys;
2730
#endif
@@ -86,11 +89,50 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void
8689
if (!restriction)
8790
panic("Can't allocate secondary trusted keyring restriction\n");
8891

89-
restriction->check = restrict_link_by_builtin_and_secondary_trusted;
92+
if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING))
93+
restriction->check = restrict_link_by_builtin_secondary_and_machine;
94+
else
95+
restriction->check = restrict_link_by_builtin_and_secondary_trusted;
9096

9197
return restriction;
9298
}
9399
#endif
100+
#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
101+
void __init set_machine_trusted_keys(struct key *keyring)
102+
{
103+
machine_trusted_keys = keyring;
104+
105+
if (key_link(secondary_trusted_keys, machine_trusted_keys) < 0)
106+
panic("Can't link (machine) trusted keyrings\n");
107+
}
108+
109+
/**
110+
* restrict_link_by_builtin_secondary_and_machine - Restrict keyring addition.
111+
* @dest_keyring: Keyring being linked to.
112+
* @type: The type of key being added.
113+
* @payload: The payload of the new key.
114+
* @restrict_key: A ring of keys that can be used to vouch for the new cert.
115+
*
116+
* Restrict the addition of keys into a keyring based on the key-to-be-added
117+
* being vouched for by a key in either the built-in, the secondary, or
118+
* the machine keyrings.
119+
*/
120+
int restrict_link_by_builtin_secondary_and_machine(
121+
struct key *dest_keyring,
122+
const struct key_type *type,
123+
const union key_payload *payload,
124+
struct key *restrict_key)
125+
{
126+
if (machine_trusted_keys && type == &key_type_keyring &&
127+
dest_keyring == secondary_trusted_keys &&
128+
payload == &machine_trusted_keys->payload)
129+
/* Allow the machine keyring to be added to the secondary */
130+
return 0;
131+
132+
return restrict_link_by_builtin_and_secondary_trusted(dest_keyring, type,
133+
payload, restrict_key);
134+
}
135+
#endif
94136

95137
/*
96138
* Create the trusted keyrings

crypto/asymmetric_keys/Kconfig

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
2222
appropriate hash algorithms (such as SHA-1) must be available.
2323
ENOPKG will be reported if the requisite algorithm is unavailable.
2424

25-
config ASYMMETRIC_TPM_KEY_SUBTYPE
26-
tristate "Asymmetric TPM backed private key subtype"
27-
depends on TCG_TPM
28-
depends on TRUSTED_KEYS
29-
select CRYPTO_HMAC
30-
select CRYPTO_SHA1
31-
select CRYPTO_HASH_INFO
32-
help
33-
This option provides support for TPM backed private key type handling.
34-
Operations such as sign, verify, encrypt, decrypt are performed by
35-
the TPM after the private key is loaded.
36-
3725
config X509_CERTIFICATE_PARSER
3826
tristate "X.509 certificate parser"
3927
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
@@ -54,15 +42,6 @@ config PKCS8_PRIVATE_KEY_PARSER
5442
private key data and provides the ability to instantiate a crypto key
5543
from that data.
5644

57-
config TPM_KEY_PARSER
58-
tristate "TPM private key parser"
59-
depends on ASYMMETRIC_TPM_KEY_SUBTYPE
60-
select ASN1
61-
help
62-
This option provides support for parsing TPM format blobs for
63-
private key data and provides the ability to instantiate a crypto key
64-
from that data.
65-
6645
config PKCS7_MESSAGE_PARSER
6746
tristate "PKCS#7 message parser"
6847
depends on X509_CERTIFICATE_PARSER

crypto/asymmetric_keys/Makefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ asymmetric_keys-y := \
1111
signature.o
1212

1313
obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
14-
obj-$(CONFIG_ASYMMETRIC_TPM_KEY_SUBTYPE) += asym_tpm.o
1514

1615
#
1716
# X.509 Certificate handling
@@ -75,14 +74,3 @@ verify_signed_pefile-y := \
7574

7675
$(obj)/mscode_parser.o: $(obj)/mscode.asn1.h $(obj)/mscode.asn1.h
7776
$(obj)/mscode.asn1.o: $(obj)/mscode.asn1.c $(obj)/mscode.asn1.h
78-
79-
#
80-
# TPM private key parsing
81-
#
82-
obj-$(CONFIG_TPM_KEY_PARSER) += tpm_key_parser.o
83-
tpm_key_parser-y := \
84-
tpm.asn1.o \
85-
tpm_parser.o
86-
87-
$(obj)/tpm_parser.o: $(obj)/tpm.asn1.h
88-
$(obj)/tpm.asn1.o: $(obj)/tpm.asn1.c $(obj)/tpm.asn1.h

0 commit comments

Comments
 (0)