Skip to content

Commit 02e2f9a

Browse files
blucajxwufan
authored andcommitted
ipe: allow secondary and platform keyrings to install/update policies
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available. This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring. Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade. Add a kconfig each, like dm-verity does, but default to enabled if the dependencies are available. Signed-off-by: Luca Boccassi <[email protected]> Reviewed-by: Serge Hallyn <[email protected]> [FW: fixed some style issues] Signed-off-by: Fan Wu <[email protected]>
1 parent 5ceecb3 commit 02e2f9a

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Documentation/admin-guide/LSM/ipe.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ are signed through the PKCS#7 message format to enforce some level of
223223
authorization of the policies (prohibiting an attacker from gaining
224224
unconstrained root, and deploying an "allow all" policy). These
225225
policies must be signed by a certificate that chains to the
226-
``SYSTEM_TRUSTED_KEYRING``. With openssl, the policy can be signed by::
226+
``SYSTEM_TRUSTED_KEYRING``, or to the secondary and/or platform keyrings if
227+
``CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING`` and/or
228+
``CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING`` are enabled, respectively.
229+
With openssl, the policy can be signed by::
227230

228231
openssl smime -sign \
229232
-in "$MY_POLICY" \

security/ipe/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ config IPE_BOOT_POLICY
3131

3232
If unsure, leave blank.
3333

34+
config IPE_POLICY_SIG_SECONDARY_KEYRING
35+
bool "IPE policy update verification with secondary keyring"
36+
default y
37+
depends on SECONDARY_TRUSTED_KEYRING
38+
help
39+
Also allow the secondary trusted keyring to verify IPE policy
40+
updates.
41+
42+
If unsure, answer Y.
43+
44+
config IPE_POLICY_SIG_PLATFORM_KEYRING
45+
bool "IPE policy update verification with platform keyring"
46+
default y
47+
depends on INTEGRITY_PLATFORM_KEYRING
48+
help
49+
Also allow the platform keyring to verify IPE policy updates.
50+
51+
If unsure, answer Y.
52+
3453
menu "IPE Trust Providers"
3554

3655
config IPE_PROP_DM_VERITY

security/ipe/policy.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,21 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen,
169169
goto err;
170170
}
171171

172-
rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, NULL,
172+
rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len,
173+
#ifdef CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING
174+
VERIFY_USE_SECONDARY_KEYRING,
175+
#else
176+
NULL,
177+
#endif
173178
VERIFYING_UNSPECIFIED_SIGNATURE,
174179
set_pkcs7_data, new);
180+
#ifdef CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING
181+
if (rc == -ENOKEY)
182+
rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len,
183+
VERIFY_USE_PLATFORM_KEYRING,
184+
VERIFYING_UNSPECIFIED_SIGNATURE,
185+
set_pkcs7_data, new);
186+
#endif
175187
if (rc)
176188
goto err;
177189
} else {

0 commit comments

Comments
 (0)