Skip to content

Commit 8203ca3

Browse files
committed
Merge tag 'ipe-pr-20241018' of git://git.kernel.org/pub/scm/linux/kernel/git/wufan/ipe
Pull ipe fixes from Fan Wu: "This addresses several issues identified by Luca when attempting to enable IPE on Debian and systemd: - address issues with IPE policy update errors and policy update version check, improving the clarity of error messages for better understanding by userspace programs. - enable IPE policies to be signed by secondary and platform keyrings, facilitating broader use across general Linux distributions like Debian. - updates the IPE entry in the MAINTAINERS file to reflect the new tree URL and my updated email from kernel.org" * tag 'ipe-pr-20241018' of git://git.kernel.org/pub/scm/linux/kernel/git/wufan/ipe: MAINTAINERS: update IPE tree url and Fan Wu's email ipe: fallback to platform keyring also if key in trusted keyring is rejected ipe: allow secondary and platform keyrings to install/update policies ipe: also reject policy updates with the same version ipe: return -ESTALE instead of -EINVAL on update when new policy has a lower version
2 parents f9e4825 + 917a15c commit 8203ca3

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

Documentation/admin-guide/LSM/ipe.rst

Lines changed: 5 additions & 2 deletions
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" \
@@ -266,7 +269,7 @@ in the kernel. This file is write-only and accepts a PKCS#7 signed
266269
policy. Two checks will always be performed on this policy: First, the
267270
``policy_names`` must match with the updated version and the existing
268271
version. Second the updated policy must have a policy version greater than
269-
or equal to the currently-running version. This is to prevent rollback attacks.
272+
the currently-running version. This is to prevent rollback attacks.
270273

271274
The ``delete`` file is used to remove a policy that is no longer needed.
272275
This file is write-only and accepts a value of ``1`` to delete the policy.

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11283,10 +11283,10 @@ F: security/integrity/
1128311283
F: security/integrity/ima/
1128411284

1128511285
INTEGRITY POLICY ENFORCEMENT (IPE)
11286-
M: Fan Wu <wufan@linux.microsoft.com>
11286+
M: Fan Wu <wufan@kernel.org>
1128711287
1128811288
S: Supported
11289-
T: git https://github.com/microsoft/ipe.git
11289+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/wufan/ipe.git
1129011290
F: Documentation/admin-guide/LSM/ipe.rst
1129111291
F: Documentation/security/ipe.rst
1129211292
F: scripts/ipe/

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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ int ipe_update_policy(struct inode *root, const char *text, size_t textlen,
106106
goto err;
107107
}
108108

109-
if (ver_to_u64(old) > ver_to_u64(new)) {
110-
rc = -EINVAL;
109+
if (ver_to_u64(old) >= ver_to_u64(new)) {
110+
rc = -ESTALE;
111111
goto err;
112112
}
113113

@@ -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 || rc == -EKEYREJECTED)
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)