Skip to content

Commit f2586d9

Browse files
committed
Merge tag 'tpmdd-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull tpm updates from Jarkko Sakkinen: - Restrict linking of keys to .ima and .evm keyrings based on digitalSignature attribute in the certificate - PowerVM: load machine owner keys into the .machine [1] keyring - PowerVM: load module signing keys into the secondary trusted keyring (keys blessed by the vendor) - tpm_tis_spi: half-duplex transfer mode - tpm_tis: retry corrupted transfers - Apply revocation list (.mokx) to an all system keyrings (e.g. .machine keyring) Link: https://blogs.oracle.com/linux/post/the-machine-keyring [1] * tag 'tpmdd-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: certs: Reference revocation list for all keyrings tpm/tpm_tis_synquacer: Use module_platform_driver macro to simplify the code tpm: remove redundant variable len tpm_tis: Resend command to recover from data transfer errors tpm_tis: Use responseRetry to recover from data transfer errors tpm_tis: Move CRC check to generic send routine tpm_tis_spi: Add hardware wait polling KEYS: Replace all non-returning strlcpy with strscpy integrity: PowerVM support for loading third party code signing keys integrity: PowerVM machine keyring enablement integrity: check whether imputed trust is enabled integrity: remove global variable from machine_keyring.c integrity: ignore keys failing CA restrictions on non-UEFI platform integrity: PowerVM support for loading CA keys on machine keyring integrity: Enforce digitalSignature usage in the ima and evm keyrings KEYS: DigitalSignature link restriction tpm_tis: Revert "tpm_tis: Disable interrupts on ThinkPad T490s"
2 parents 1c59d38 + 218a268 commit f2586d9

File tree

21 files changed

+394
-148
lines changed

21 files changed

+394
-148
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6394,6 +6394,13 @@
63946394
This will guarantee that all the other pcrs
63956395
are saved.
63966396

6397+
tpm_tis.interrupts= [HW,TPM]
6398+
Enable interrupts for the MMIO based physical layer
6399+
for the FIFO interface. By default it is set to false
6400+
(0). For more information about TPM hardware interfaces
6401+
defined by Trusted Computing Group (TCG) see
6402+
https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/
6403+
63976404
tp_printk [FTRACE]
63986405
Have the tracepoints sent to printk as well as the
63996406
tracing ring buffer. This is useful for early boot up

certs/system_keyring.c

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ int restrict_link_by_builtin_trusted(struct key *dest_keyring,
5151
builtin_trusted_keys);
5252
}
5353

54+
/**
55+
* restrict_link_by_digsig_builtin - Restrict digitalSignature key additions by the built-in keyring
56+
* @dest_keyring: Keyring being linked to.
57+
* @type: The type of key being added.
58+
* @payload: The payload of the new key.
59+
* @restriction_key: A ring of keys that can be used to vouch for the new cert.
60+
*
61+
* Restrict the addition of keys into a keyring based on the key-to-be-added
62+
* being vouched for by a key in the built in system keyring. The new key
63+
* must have the digitalSignature usage field set.
64+
*/
65+
int restrict_link_by_digsig_builtin(struct key *dest_keyring,
66+
const struct key_type *type,
67+
const union key_payload *payload,
68+
struct key *restriction_key)
69+
{
70+
return restrict_link_by_digsig(dest_keyring, type, payload,
71+
builtin_trusted_keys);
72+
}
73+
5474
#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
5575
/**
5676
* restrict_link_by_builtin_and_secondary_trusted - Restrict keyring
@@ -83,6 +103,35 @@ int restrict_link_by_builtin_and_secondary_trusted(
83103
secondary_trusted_keys);
84104
}
85105

106+
/**
107+
* restrict_link_by_digsig_builtin_and_secondary - Restrict by digitalSignature.
108+
* @dest_keyring: Keyring being linked to.
109+
* @type: The type of key being added.
110+
* @payload: The payload of the new key.
111+
* @restrict_key: A ring of keys that can be used to vouch for the new cert.
112+
*
113+
* Restrict the addition of keys into a keyring based on the key-to-be-added
114+
* being vouched for by a key in either the built-in or the secondary system
115+
* keyrings. The new key must have the digitalSignature usage field set.
116+
*/
117+
int restrict_link_by_digsig_builtin_and_secondary(struct key *dest_keyring,
118+
const struct key_type *type,
119+
const union key_payload *payload,
120+
struct key *restrict_key)
121+
{
122+
/* If we have a secondary trusted keyring, then that contains a link
123+
* through to the builtin keyring and the search will follow that link.
124+
*/
125+
if (type == &key_type_keyring &&
126+
dest_keyring == secondary_trusted_keys &&
127+
payload == &builtin_trusted_keys->payload)
128+
/* Allow the builtin keyring to be added to the secondary */
129+
return 0;
130+
131+
return restrict_link_by_digsig(dest_keyring, type, payload,
132+
secondary_trusted_keys);
133+
}
134+
86135
/*
87136
* Allocate a struct key_restriction for the "builtin and secondary trust"
88137
* keyring. Only for use in system_trusted_keyring_init().
@@ -103,6 +152,36 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void
103152

104153
return restriction;
105154
}
155+
156+
/**
157+
* add_to_secondary_keyring - Add to secondary keyring.
158+
* @source: Source of key
159+
* @data: The blob holding the key
160+
* @len: The length of the data blob
161+
*
162+
* Add a key to the secondary keyring. The key must be vouched for by a key in the builtin,
163+
* machine or secondary keyring itself.
164+
*/
165+
void __init add_to_secondary_keyring(const char *source, const void *data, size_t len)
166+
{
167+
key_ref_t key;
168+
key_perm_t perm;
169+
170+
perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW;
171+
172+
key = key_create_or_update(make_key_ref(secondary_trusted_keys, 1),
173+
"asymmetric",
174+
NULL, data, len, perm,
175+
KEY_ALLOC_NOT_IN_QUOTA);
176+
if (IS_ERR(key)) {
177+
pr_err("Problem loading X.509 certificate from %s to secondary keyring %ld\n",
178+
source, PTR_ERR(key));
179+
return;
180+
}
181+
182+
pr_notice("Loaded X.509 cert '%s'\n", key_ref_to_ptr(key)->description);
183+
key_ref_put(key);
184+
}
106185
#endif
107186
#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
108187
void __init set_machine_trusted_keys(struct key *keyring)
@@ -251,6 +330,12 @@ int verify_pkcs7_message_sig(const void *data, size_t len,
251330
if (ret < 0)
252331
goto error;
253332

333+
ret = is_key_on_revocation_list(pkcs7);
334+
if (ret != -ENOKEY) {
335+
pr_devel("PKCS#7 key is on revocation list\n");
336+
goto error;
337+
}
338+
254339
if (!trusted_keys) {
255340
trusted_keys = builtin_trusted_keys;
256341
} else if (trusted_keys == VERIFY_USE_SECONDARY_KEYRING) {
@@ -270,12 +355,6 @@ int verify_pkcs7_message_sig(const void *data, size_t len,
270355
pr_devel("PKCS#7 platform keyring is not available\n");
271356
goto error;
272357
}
273-
274-
ret = is_key_on_revocation_list(pkcs7);
275-
if (ret != -ENOKEY) {
276-
pr_devel("PKCS#7 platform key is on revocation list\n");
277-
goto error;
278-
}
279358
}
280359
ret = pkcs7_validate_trust(pkcs7, trusted_keys);
281360
if (ret < 0) {

crypto/asymmetric_keys/restrict.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,50 @@ int restrict_link_by_ca(struct key *dest_keyring,
148148
return 0;
149149
}
150150

151+
/**
152+
* restrict_link_by_digsig - Restrict additions to a ring of digsig keys
153+
* @dest_keyring: Keyring being linked to.
154+
* @type: The type of key being added.
155+
* @payload: The payload of the new key.
156+
* @trust_keyring: A ring of keys that can be used to vouch for the new cert.
157+
*
158+
* Check if the new certificate has digitalSignature usage set. If it is,
159+
* then mark the new certificate as being ok to link. Afterwards verify
160+
* the new certificate against the ones in the trust_keyring.
161+
*
162+
* Returns 0 if the new certificate was accepted, -ENOKEY if the
163+
* certificate is not a digsig. -ENOPKG if the signature uses unsupported
164+
* crypto, or some other error if there is a matching certificate but
165+
* the signature check cannot be performed.
166+
*/
167+
int restrict_link_by_digsig(struct key *dest_keyring,
168+
const struct key_type *type,
169+
const union key_payload *payload,
170+
struct key *trust_keyring)
171+
{
172+
const struct public_key *pkey;
173+
174+
if (type != &key_type_asymmetric)
175+
return -EOPNOTSUPP;
176+
177+
pkey = payload->data[asym_crypto];
178+
179+
if (!pkey)
180+
return -ENOPKG;
181+
182+
if (!test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
183+
return -ENOKEY;
184+
185+
if (test_bit(KEY_EFLAG_CA, &pkey->key_eflags))
186+
return -ENOKEY;
187+
188+
if (test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
189+
return -ENOKEY;
190+
191+
return restrict_link_by_signature(dest_keyring, type, payload,
192+
trust_keyring);
193+
}
194+
151195
static bool match_either_id(const struct asymmetric_key_id **pair,
152196
const struct asymmetric_key_id *single)
153197
{

drivers/char/tpm/eventlog/tpm1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ static int tpm1_binary_bios_measurements_show(struct seq_file *m, void *v)
251251

252252
static int tpm1_ascii_bios_measurements_show(struct seq_file *m, void *v)
253253
{
254-
int len = 0;
255254
char *eventname;
256255
struct tcpa_event *event = v;
257256
unsigned char *event_entry =
@@ -273,7 +272,7 @@ static int tpm1_ascii_bios_measurements_show(struct seq_file *m, void *v)
273272
/* 3rd: event type identifier */
274273
seq_printf(m, " %02x", do_endian_conversion(event->event_type));
275274

276-
len += get_event_name(eventname, event, event_entry);
275+
get_event_name(eventname, event, event_entry);
277276

278277
/* 4th: eventname <= max + \'0' delimiter */
279278
seq_printf(m, " %s\n", eventname);

drivers/char/tpm/tpm_tis.c

Lines changed: 2 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/of.h>
2828
#include <linux/of_device.h>
2929
#include <linux/kernel.h>
30-
#include <linux/dmi.h>
3130
#include "tpm.h"
3231
#include "tpm_tis_core.h"
3332

@@ -89,8 +88,8 @@ static inline void tpm_tis_iowrite32(u32 b, void __iomem *iobase, u32 addr)
8988
tpm_tis_flush(iobase);
9089
}
9190

92-
static int interrupts;
93-
module_param(interrupts, int, 0444);
91+
static bool interrupts;
92+
module_param(interrupts, bool, 0444);
9493
MODULE_PARM_DESC(interrupts, "Enable interrupts");
9594

9695
static bool itpm;
@@ -103,92 +102,6 @@ module_param(force, bool, 0444);
103102
MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
104103
#endif
105104

106-
static int tpm_tis_disable_irq(const struct dmi_system_id *d)
107-
{
108-
if (interrupts == -1) {
109-
pr_notice("tpm_tis: %s detected: disabling interrupts.\n", d->ident);
110-
interrupts = 0;
111-
}
112-
113-
return 0;
114-
}
115-
116-
static const struct dmi_system_id tpm_tis_dmi_table[] = {
117-
{
118-
.callback = tpm_tis_disable_irq,
119-
.ident = "Framework Laptop (12th Gen Intel Core)",
120-
.matches = {
121-
DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
122-
DMI_MATCH(DMI_PRODUCT_NAME, "Laptop (12th Gen Intel Core)"),
123-
},
124-
},
125-
{
126-
.callback = tpm_tis_disable_irq,
127-
.ident = "Framework Laptop (13th Gen Intel Core)",
128-
.matches = {
129-
DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
130-
DMI_MATCH(DMI_PRODUCT_NAME, "Laptop (13th Gen Intel Core)"),
131-
},
132-
},
133-
{
134-
.callback = tpm_tis_disable_irq,
135-
.ident = "ThinkPad T490s",
136-
.matches = {
137-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
138-
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
139-
},
140-
},
141-
{
142-
.callback = tpm_tis_disable_irq,
143-
.ident = "ThinkStation P360 Tiny",
144-
.matches = {
145-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
146-
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkStation P360 Tiny"),
147-
},
148-
},
149-
{
150-
.callback = tpm_tis_disable_irq,
151-
.ident = "ThinkPad L490",
152-
.matches = {
153-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
154-
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L490"),
155-
},
156-
},
157-
{
158-
.callback = tpm_tis_disable_irq,
159-
.ident = "ThinkPad L590",
160-
.matches = {
161-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
162-
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L590"),
163-
},
164-
},
165-
{
166-
.callback = tpm_tis_disable_irq,
167-
.ident = "ThinkStation P620",
168-
.matches = {
169-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
170-
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkStation P620"),
171-
},
172-
},
173-
{
174-
.callback = tpm_tis_disable_irq,
175-
.ident = "TUXEDO InfinityBook S 15/17 Gen7",
176-
.matches = {
177-
DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
178-
DMI_MATCH(DMI_PRODUCT_NAME, "TUXEDO InfinityBook S 15/17 Gen7"),
179-
},
180-
},
181-
{
182-
.callback = tpm_tis_disable_irq,
183-
.ident = "UPX-TGL",
184-
.matches = {
185-
DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
186-
DMI_MATCH(DMI_PRODUCT_NAME, "UPX-TGL01"),
187-
},
188-
},
189-
{}
190-
};
191-
192105
#if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
193106
static int has_hid(struct acpi_device *dev, const char *hid)
194107
{
@@ -312,8 +225,6 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)
312225
int irq = -1;
313226
int rc;
314227

315-
dmi_check_system(tpm_tis_dmi_table);
316-
317228
rc = check_acpi_tpm2(dev);
318229
if (rc)
319230
return rc;

0 commit comments

Comments
 (0)