Clavis LSM
Subsystems (11)
Eric Snowberg
reviewerv3 cover Clavis LSM
Motivation:
Each end-user has their own security threat model. What is important to one end-user may not be important to another. There is not a right or wrong threat model.
A common request made when adding new kernel changes that could impact the threat model around system kernel keys is to add additional Kconfig options. As kernel developers, it is challenging to both add and keep track of all the Kconfig options around security features that may limit or restrict system key usage. It is also difficult for a general purpose distro to take advantage of some of these features, since it may prevent some users from executing their workload.
It is the author's belief that it is better left up to the end-user on how kernel keys should be used within their system.
Throughout the Linux kernel, key usage is tracked when doing signature verification with keys contained within one of the system keyrings; however, there isn't a way for the end-user to enforce this usage. This series gives the end-user the ability to configure key usage based on their threat model. Having the ability to enforce key usage also improves security by reducing the attack surface should a system key be compromised. It allows new features to be added without the need for additional Kconfig options for fear of changing the end-user's threat model. It also allows a distro to build a kernel that suits various end-user's needs without resorting to selecting Kconfig options with the least restrictive security options.
Solution:
This series introduces a new LSM called Clavis (Latin word meaning key). This LSM leaves it up to the end-user to determine what system keys they want to use and for what purpose.
The Clavis LSM adds the ability to do access control for all system keys. When enabled, until an ACL entry is added for a specific key, none of the system keys may be used for any type of verification purpose. When the kernel is built, typically kernel modules are signed with an ephemeral key, an ACL entry for the ephemeral key is pre-loaded, allowing the kernel modules to load during boot. At build time other ACL entries may also be included.
The Clavis LSM requires the end-user to have their own public key infrastructure (PKI). In order for a Clavis ACL entry to be added, the ACL must be signed by what is being called the Clavis key. The Clavis key is owned by the end-user. The Clavis public key can be contained within the machine keyring, or it can be added after the machine boots.
Not only is there a new Clavis key being introduced, but there is also a new .clavis keyring. The .clavis keyring contains a single Clavis key. It also contains any number of ACL entries that are signed by the Clavis key.
It is believed that the most common setup would be to have the Clavis key contained within the machine keyring. Enabling the Clavis LSM during boot is accomplished by passing in the asymmetric key id for the Clavis key within a new "clavis=" boot param. The asymmetric key id must match one already contained within any of the system keyrings. If a match is found, a link is created into the new .clavis keyring. This Clavis key shall be used as the root of trust for any keyring ACL updates afterwards.
On UEFI systems the "clavis" boot param is mirrored into a new UEFI variable within the EFI stub code. This variable will persist until the next reboot. This same type of functionality is done within shim. Since this variable is created before ExitBootServices (EBS) it will not have the NVRAM bit set, signifying it was created during the Boot Services phase. This is being used so the "clavis" boot param can not be changed via kexec, thereby preventing a pivot of the root of trust.
As mentioned earlier, this LSM introduces a new .clavis keyring. Following boot, no new keys can be added to this keyring and only the key designated via the initial boot param may be used. If the clavis boot param was not used, the LSM can be enabled afterwards using the keyctl command. The end-user may add their Clavis key into the .clavis keyring and the Clavis LSM shall be enabled.
The .clavis keyring also holds the access control list for system keys. A new key type called clavis_key_acl is being introduced. This contains the usage followed by the asymmetric key id. To be added to the clavis keyring, the clavis_key_acl must be S/MIME signed by the Clavis key. New ACL additions to the .clavis keyring may be added at any time.
Currently this LSM does not require new changes or modifications to any user space tools. It also does not have a securityfs interface. Everything is done using the existing keyctl tool through the new .clavis keyring. The S/MIME signing can be done with a simple OpenSSL command. If additions or updates need to be added in the future, new ACL key types could be created. With this approach, maintainability should not be an issue in the future if missing items are identified.
Clavis must be configured at build time with CONFIG_SECURITY_CLAVIS=y. The list of security modules enabled by default is set with CONFIG_LSM. The kernel configuration must contain CONFIG_LSM=[...],clavis with [...] as the list of other security modules for the running system.
For setup and usage instructions, a clavis admin-guide has been included in Documentation/admin-guide/LSM/clavis.rst.
Future enhancements to this LSM could include:
1. Subsystems that currently use system keys with VERIFYING_UNSPECIFIED_SIGNATURE could be updated with their specific usage type. For example, a usage type for IMA, BPF, etc could be added.
2. Having the ability to allow platform keys to be on par with all other system keys when using this LSM. This would be useful for a user that controls their entire UEFI SB DB key chain and doesn't want to use MOK keys. This could also potentially remove the need for the machine keyring all together.
3. Some of the Kconfig options around key usage and types could be deprecated.
I would appreciate any feedback on this approach. Thanks.
Changes in v3:
Rebased to 6.12-rc3
Added Kunit test code
Preload an ACL in the clavis keyring with the ephemeral module signing key Preload user defined ACL data into the clavis keyring with build time data Changes to the second patch recommended by Jarkko
Reordered patches recommended by Mimi
Documentation improvements recommended by Randy
Changes in v2:
Rebased to 6.10-rc1
Various cleanup in the first patch recommended by Jarkko Documentation improvements recommended by Randy Fixed lint warnings
Other cleanup
Eric Snowberg (13):
certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
certs: Introduce ability to link to a system key
clavis: Introduce a new system keyring called clavis
keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
clavis: Introduce a new key type called clavis_key_acl
clavis: Populate clavis keyring acl with kernel module signature
keys: Add ability to track intended usage of the public key
clavis: Introduce new LSM called clavis
clavis: Allow user to define acl at build time
efi: Make clavis boot param persist across kexec
clavis: Prevent boot param change during kexec
clavis: Add function redirection for Kunit support
clavis: Kunit support
Documentation/admin-guide/LSM/clavis.rst | 191 ++++++ .../admin-guide/kernel-parameters.txt | 6 + MAINTAINERS | 7 + certs/.gitignore | 1 + certs/Makefile | 20 + certs/blacklist.c | 3 + certs/clavis_module_acl.c | 7 + certs/system_keyring.c | 36 +- crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_trust.c | 20 + crypto/asymmetric_keys/pkcs7_verify.c | 5 + crypto/asymmetric_keys/signature.c | 4 + drivers/firmware/efi/Kconfig | 12 + drivers/firmware/efi/libstub/Makefile | 1 + drivers/firmware/efi/libstub/clavis.c | 33 + .../firmware/efi/libstub/efi-stub-helper.c | 2 + drivers/firmware/efi/libstub/efi-stub.c | 2 + drivers/firmware/efi/libstub/efistub.h | 8 + drivers/firmware/efi/libstub/x86-stub.c | 2 + include/crypto/pkcs7.h | 3 + include/crypto/public_key.h | 4 + include/keys/system_keyring.h | 7 +- include/linux/efi.h | 1 + include/linux/integrity.h | 8 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/linux/verification.h | 2 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 11 +- security/Makefile | 1 + security/clavis/.gitignore | 2 + security/clavis/.kunitconfig | 4 + security/clavis/Kconfig | 37 ++ security/clavis/Makefile | 156 +++++ security/clavis/clavis.c | 26 + security/clavis/clavis.h | 62 ++ security/clavis/clavis_builtin_acl.c | 7 + security/clavis/clavis_efi.c | 50 ++ security/clavis/clavis_keyring.c | 426 +++++++++++++ security/clavis/clavis_test.c | 566 ++++++++++++++++++ security/integrity/iint.c | 2 + security/security.c | 13 + .../selftests/lsm/lsm_list_modules_test.c | 3 + 44 files changed, 1757 insertions(+), 13 deletions(-) create mode 100644 Documentation/admin-guide/LSM/clavis.rst create mode 100644 certs/clavis_module_acl.c create mode 100644 drivers/firmware/efi/libstub/clavis.c create mode 100644 security/clavis/.gitignore create mode 100644 security/clavis/.kunitconfig create mode 100644 security/clavis/Kconfig create mode 100644 security/clavis/Makefile create mode 100644 security/clavis/clavis.c create mode 100644 security/clavis/clavis.h create mode 100644 security/clavis/clavis_builtin_acl.c create mode 100644 security/clavis/clavis_efi.c create mode 100644 security/clavis/clavis_keyring.c create mode 100644 security/clavis/clavis_test.c
base-commit: 8e929cb546ee42c9a61d24fae60605e9e3192354
Signature · 1 line
2.45.0
Eric Snowberg
reviewerRFC PATCH v3 1/13 certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
Remove the CONFIG_INTEGRITY_PLATFORM_KEYRING ifdef check so this pattern does not need to be repeated with new code.
--- certs/system_keyring.c | 6 ------ 1 file changed, 6 deletions(-)
certs/system_keyring.c +0 -6
@@ -24,9 +24,7 @@ static struct key *secondary_trusted_keys;#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;#endif -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys; -#endif extern __initconst const u8 system_certificate_list[];extern __initconst const unsigned long system_certificate_list_size;
@@ -345,11 +343,7 @@ int verify_pkcs7_message_sig(const void *data, size_t len, trusted_keys = builtin_trusted_keys;#endif }else if (trusted_keys ==VERIFY_USE_PLATFORM_KEYRING ) { -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING trusted_keys = platform_trusted_keys; -#else - trusted_keys =NULL ; -#endif if (!trusted_keys) { ret = -ENOKEY ;pr_devel ("PKCS#7 platform keyring is not available\n" );
Signature · 1 line
2.45.0
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 01/13] certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
Quoted 34 lines · Eric Snowberg
Remove the
CONFIG_INTEGRITY_PLATFORM_KEYRINGifdef check so this pattern does not need to be repeated with new code.Signed-off-by Eric Snowberg <[email protected]>---
certs/system_keyring.c | 6 ------1 file changed, 6 deletions(-)certs/system_keyring.c +0
-2@@ -24,9 +24,7 @@ static struct key *secondary_trusted_keys; #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys; #endif -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys; -#endif
extern__initconstconst u8 system_certificate_list[]; extern__initconstconst unsigned longsystem_certificate_list_size;certs/system_keyring.c +0
-4@@ -345,11 +343,7 @@ int verify_pkcs7_message_sig(const void *data,size_t len, trusted_keys = builtin_trusted_keys; #endif } else if (trusted_keys == VERIFY_USE_PLATFORM_KEYRING) { -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING trusted_keys = platform_trusted_keys; -#else - trusted_keys =NULL ; -#endif if (!trusted_keys) { ret = -ENOKEY;
Quoted 2 lines
pr_devel("PKCS#7 platform keyring is not available\n");
Just to check with the argument that any commit should bring the Git tree to another "good state". Why this was flagged? What would be the collateral damage if only this commit was picked and put to a pull request? No intentions to do that, this more like forming a better understanding what is at stake here.
I.e. I get that you need this for subsequent commits but I think the commit message should also have like explanation why this is a legit change otherwise.
I mean, less flagging better if it does not cause harm is already great without higher level goals.
BR, Jarkko
Eric Snowberg
reviewerRe: [RFC PATCH v3 01/13] certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
Quoted 47 lines · Jarkko Sakkinen
Quoted 34 lines · Eric Snowberg
Remove the
CONFIG_INTEGRITY_PLATFORM_KEYRINGifdef check so this pattern does not need to be repeated with new code.Signed-off-by Eric Snowberg <[email protected]>--- certs/system_keyring.c | 6 ------ 1 file changed, 6 deletions(-)certs/system_keyring.c +0
-6@@ -24,9 +24,7 @@ static struct key *secondary_trusted_keys;#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;#endif -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys; -#endif extern __initconst const u8 system_certificate_list[];extern __initconst const unsigned long system_certificate_list_size;@@ -345,11 +343,7 @@ int verify_pkcs7_message_sig(const void *data,size_t len, trusted_keys = builtin_trusted_keys;#endif }else if (trusted_keys ==VERIFY_USE_PLATFORM_KEYRING ) { -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING trusted_keys = platform_trusted_keys; -#else - trusted_keys =NULL ; -#endif if (!trusted_keys) { ret = -ENOKEY ;Quoted 2 lines
pr_devel("PKCS#7 platform keyring is not
available\n");Just to check with the argument that any commit should bring the Git tree to another "good state". Why this was flagged? What would be the collateral damage if only this commit was picked and put to a pull request? No intentions to do that, this more like forming a better understanding what is at stake here.
Quoted 3 lines
I.e. I get that you need this for subsequent commits but I think the commit message should also have like explanation why this is a legit change otherwise.
Thanks for taking a look at this, I will add a better explanation in the next round.
Re: [RFC PATCH v3 01/13] certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
In reply to Eric SnowbergHi Eric,
Quoted 4 lines · Eric Snowberg
Remove the
CONFIG_INTEGRITY_PLATFORM_KEYRINGifdef check so this pattern does not need to be repeated with new code.Signed-off-by Eric Snowberg <[email protected]>
Ok. The reason why testing the Kconfig is unnecessary should be included in the patch description. For example,
Commit 219a3e8676f3 ("integrity, KEYS: add a reference to platform keyring") unnecessarily added the Kconfig test. As platform_trusted_keys is already initialized, simply use it.
Quoted 30 lines
--- certs/system_keyring.c | 6 ------ 1 file changed, 6 deletions(-)certs/system_keyring.c +0
-6@@ -24,9 +24,7 @@ static struct key *secondary_trusted_keys;#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;#endif -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys; -#endif extern __initconst const u8 system_certificate_list[];extern __initconst const unsigned long system_certificate_list_size;@@ -345,11 +343,7 @@ int verify_pkcs7_message_sig(const void *data, size_t len, trusted_keys = builtin_trusted_keys;#endif }else if (trusted_keys ==VERIFY_USE_PLATFORM_KEYRING ) { -#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING trusted_keys = platform_trusted_keys; -#else - trusted_keys =NULL ; -#endif if (!trusted_keys) { ret = -ENOKEY ;pr_devel ("PKCS#7 platform keyring is not available\n" );
Eric Snowberg
reviewerRe: [RFC PATCH v3 01/13] certs: Remove CONFIG_INTEGRITY_PLATFORM_KEYRING check
Quoted 10 lines · Mimi Zohar
Hi Eric,
Quoted 3 lines · Eric Snowberg
Remove the
CONFIG_INTEGRITY_PLATFORM_KEYRINGifdef check so this pattern does not need to be repeated with new code.
Quoted 8 lines
Quoted 1 line
Signed-off-by Eric Snowberg <[email protected]>Ok. The reason why testing the
Kconfigis unnecessary should be included in the patch description. For example,Commit
219a3e8676f3("integrity, KEYS: add a reference to platform keyring") unnecessarily added theKconfigtest. Asplatform_trusted_keysis already initialized, simply use it.
Thanks, I'll add that in the next round.
Quoted 1 line
Reviewed-by Mimi Zohar <[email protected]>
Eric Snowberg
reviewerRFC PATCH v3 2/13 certs: Introduce ability to link to a system key
In reply to Eric SnowbergIntroduce system_key_link(), a new function to allow a keyring to link to a key contained within one of the system keyrings (builtin, secondary, or platform). Depending on how the kernel is built, if the machine keyring is available, it will be checked as well, since it is linked to the secondary keyring. If the asymmetric key id matches a key within one of these system keyrings, the matching key is linked into the passed in keyring.
--- certs/system_keyring.c | 30 ++++++++++++++++++++++++++++++ include/keys/system_keyring.h | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-)
certs/system_keyring.c +30 -0
@@ -20,6 +20,9 @@static struct key *builtin_trusted_keys;#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys; +#define system_trusted_keys secondary_trusted_keys +#else +#define system_trusted_keys builtin_trusted_keys#endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;
@@ -420,3 +423,30 @@ void __init set_platform_trusted_keys(struct key *keyring) platform_trusted_keys = keyring; }#endif + +/** +* system_key_link - Link to a system key +* @keyring: The keyring to link into +* @id: The asymmetric key id to look for in the system keyring +* +* Search the system keyrings to see if one of them contains a matching "id". +* If there is a match, link the key into "keyring". System keyrings always +* includes the builtin. If any of the following keyrings are enabled: +* secondary, machine, and platform they are searched as well. +*/ +int system_key_link (struct key *keyring,struct asymmetric_key_id *id) +{ +struct key *key; + + key =find_asymmetric_key (system_trusted_keys, id,NULL ,NULL , false); +if (!IS_ERR (key)) +return key_link (keyring, key); + +if (platform_trusted_keys) { + key =find_asymmetric_key (platform_trusted_keys, id,NULL ,NULL , false); +if (!IS_ERR (key)) +return key_link (keyring, key); + } + +return -ENOKEY ; +}
include/keys/system_keyring.h +6 -1
@@ -9,6 +9,7 @@#define _KEYS_SYSTEM_KEYRING_H#include <linux/key.h> +struct asymmetric_key_id ;enum blacklist_hash_type {/* TBSCertificate hash */
@@ -28,7 +29,7 @@ int restrict_link_by_digsig_builtin(struct key *dest_keyring,const union key_payload *payload, struct key *restriction_key);extern __init int load_module_cert (struct key *keyring); - +extern int system_key_link (struct key *keyring,struct asymmetric_key_id *id);#else #define restrict_link_by_builtin_trusted restrict_link_reject#define restrict_link_by_digsig_builtin restrict_link_reject
@@ -38,6 +39,10 @@ static inline __init int load_module_cert(struct key *keyring) return 0; } +static inline int system_key_link (struct key *keyring,struct asymmetric_key_id *id) +{ +return 0 ; +}#endif #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
Signature · 1 line
2.45.0
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 02/13] certs: Introduce ability to link to a system key
Quoted 24 lines · Eric Snowberg
Introduce
system_key_link(), a new function to allow a keyring to link
to a key contained within one of the system keyrings (builtin, secondary,
or platform). Depending on how the kernel is built, if the machine keyring is available, it will be checked as well, since it is linked to
the secondary keyring. If the asymmetric key id matches a key within one
of these system keyrings, the matching key is linked into the passed in
keyring.Signed-off-by Eric Snowberg <[email protected]>---
certs/system_keyring.c | 30 ++++++++++++++++++++++++++++++include/keys/system_keyring.h| 7 ++++++-2 files changed, 36 insertions(+), 1 deletion(-)certs/system_keyring.c +0
-0
certs/system_keyring.c line 22
Quoted 3 lines
certs/system_keyring.c +0
-0@@ -20,6 +20,9 @@ static struct key *builtin_trusted_keys; #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys;
/*
* Explain system_trusted_keys (nothing too detailed, only the gist) */
certs/system_keyring.c line 28
Quoted 6 lines
certs/system_keyring.c +3
-0+#define system_trusted_keys secondary_trusted_keys +#else +#define system_trusted_keys builtin_trusted_keys #endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;
We have enough these to make this quite convoluted so let's put some helpful reminders. I would forget this in no time ;-) So if it comes down to that, please put something because I have a goldfish memory.
BR, Jarkko
Eric Snowberg
reviewerRe: [RFC PATCH v3 02/13] certs: Introduce ability to link to a system key
Quoted 37 lines · Jarkko Sakkinen
Quoted 24 lines · Eric Snowberg
Introduce
system_key_link(), a new function to allow a keyring to link
to a key contained within one of the system keyrings (builtin, secondary,
or platform). Depending on how the kernel is built, if the machine keyring is available, it will be checked as well, since it is linked to
the secondary keyring. If the asymmetric key id matches a key within one
of these system keyrings, the matching key is linked into the passed in
keyring.Signed-off-by Eric Snowberg <[email protected]>--- certs/system_keyring.c | 30 ++++++++++++++++++++++++++++++ include/keys/system_keyring.h | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-)certs/system_keyring.c +0
-0certs/system_keyring.c line 22
Quoted 3 lines
certs/system_keyring.c +0
-0@@ -20,6 +20,9 @@static struct key *builtin_trusted_keys;#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys;/*
* Explainsystem_trusted_keys(nothing too detailed, only the gist) */
Quoted 10 lines
certs/system_keyring.c line 28
Quoted 6 lines
certs/system_keyring.c +3
-0+#define system_trusted_keys secondary_trusted_keys +#else +#define system_trusted_keys builtin_trusted_keys#endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;We have enough these to make this quite convoluted so let's put some helpful reminders. I would forget this in no time ;-) So if it comes down to that, please put something because I have a goldfish memory.
I'll add a comment explaining this in the next round, thanks.
Re: [RFC PATCH v3 02/13] certs: Introduce ability to link to a system key
In reply to Eric SnowbergQuoted 9 lines · Eric Snowberg
Introduce
system_key_link(), a new function to allow a keyring to link to a key contained within one of the system keyrings (builtin, secondary, or platform). Depending on how the kernel is built, if the machine keyring is available, it will be checked as well, since it is linked to the secondary keyring. If the asymmetric key id matches a key within one of these system keyrings, the matching key is linked into the passed in keyring.Signed-off-by Eric Snowberg <[email protected]>
Quoted 82 lines
--- certs/system_keyring.c | 30 ++++++++++++++++++++++++++++++ include/keys/system_keyring.h | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-)certs/system_keyring.c +30
-0@@ -20,6 +20,9 @@static struct key *builtin_trusted_keys;#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys; +#define system_trusted_keys secondary_trusted_keys +#else +#define system_trusted_keys builtin_trusted_keys#endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING static struct key *machine_trusted_keys;@@ -420,3 +423,30 @@ void __init set_platform_trusted_keys(struct key *keyring) platform_trusted_keys = keyring; }#endif + +/** +* system_key_link - Link to a system key +* @keyring: The keyring to link into +* @id: The asymmetric key id to look for in the system keyring +* +* Search the system keyrings to see if one of them contains a matching "id". +* If there is a match, link the key into "keyring". System keyrings always +* includes the builtin. If any of the following keyrings are enabled: +* secondary, machine, and platform they are searched as well. +*/ +int system_key_link (struct key *keyring,struct asymmetric_key_id *id) +{ +struct key *key; + + key =find_asymmetric_key (system_trusted_keys, id,NULL ,NULL , false); +if (!IS_ERR (key)) +return key_link (keyring, key); + +if (platform_trusted_keys) { + key =find_asymmetric_key (platform_trusted_keys, id,NULL ,NULL , false); +if (!IS_ERR (key)) +return key_link (keyring, key); + } + +return -ENOKEY ; +}include/keys/system_keyring.h +6
-1@@ -9,6 +9,7 @@#define _KEYS_SYSTEM_KEYRING_H#include <linux/key.h> +struct asymmetric_key_id ;enum blacklist_hash_type {/* TBSCertificate hash */ @@ -28,7 +29,7 @@ int restrict_link_by_digsig_builtin(struct key *dest_keyring,const union key_payload *payload, struct key *restriction_key);extern __init int load_module_cert (struct key *keyring); - +extern int system_key_link (struct key *keyring,struct asymmetric_key_id *id);#else #define restrict_link_by_builtin_trusted restrict_link_reject#define restrict_link_by_digsig_builtin restrict_link_reject@@ -38,6 +39,10 @@ static inline __init int load_module_cert(struct key *keyring) return 0; } +static inline int system_key_link (struct key *keyring,struct asymmetric_key_id *id) +{ +return 0 ; +}#endif #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
Eric Snowberg
reviewerRFC PATCH v3 3/13 clavis: Introduce a new system keyring called clavis
In reply to Eric SnowbergIntroduce a new system keyring called clavis. This keyring shall contain a single asymmetric key. This key may be a linked to a key already contained in one of the system keyrings (builtin, secondary, or platform). One way to add this key into this keyring is during boot by passing in the asymmetric key id within the new "clavis=" boot param. If a matching key is found in one of the system keyrings, a link shall be created. This keyring will be used in the future by the new Clavis LSM.
--- .../admin-guide/kernel-parameters.txt | 6 + include/linux/integrity.h | 8 ++ security/Kconfig | 1 + security/Makefile | 1 + security/clavis/Kconfig | 11 ++ security/clavis/Makefile | 3 + security/clavis/clavis.h | 13 ++ security/clavis/clavis_keyring.c | 115 ++++++++++++++++++ security/integrity/iint.c | 2 + 9 files changed, 160 insertions(+) create mode 100644 security/clavis/Kconfig create mode 100644 security/clavis/Makefile create mode 100644 security/clavis/clavis.h create mode 100644 security/clavis/clavis_keyring.c
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -645,6 +645,12 @@ cio_ignore= [S390] See Documentation/arch/s390/common_io.rst for details. + clavis= [SECURITY,EARLY] + Identifies a specific key contained in one of the system + keyrings (builtin, secondary, or platform) to be used as + the Clavis root of trust. + Format: { <keyid> } + clearcpuid=X[,X...] [X86] Disable CPUID feature X for the kernel. See arch/x86/include/asm/cpufeatures.h for the valid bit
include/linux/integrity.h +8 -0
@@ -23,6 +23,14 @@ enum integrity_status {#ifdef CONFIG_INTEGRITY extern void __init integrity_load_keys (void ); +#ifdef CONFIG_SECURITY_CLAVIS +void __init late_init_clavis_setup (void ); +#else +static inline void late_init_clavis_setup (void ) +{ +} +#endif +#else static inline void integrity_load_keys (void ) {
security/Kconfig +1 -0
@@ -225,6 +225,7 @@ source "security/safesetid/Kconfig" source "security/lockdown/Kconfig" source "security/landlock/Kconfig" source "security/ipe/Kconfig" +source "security/clavis/Kconfig" source "security/integrity/Kconfig"
security/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_CGROUPS) += device_cgroup.o obj-$(CONFIG_BPF_LSM) += bpf/ obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/ obj-$(CONFIG_SECURITY_IPE) += ipe/ +obj-$(CONFIG_SECURITY_CLAVIS) += clavis/ # Object integrity file lists obj-$(CONFIG_INTEGRITY) += integrity/
security/clavis/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +config SECURITY_CLAVIS + bool "Clavis keyring" + depends on SECURITY + select SYSTEM_DATA_VERIFICATION + select CRYPTO_SHA256 + help + Enable the clavis keyring. This keyring shall contain a single asymmetric key. + This key shall be linked to a key already contained in one of the system + keyrings (builtin, secondary, or platform). One way to add this key + is during boot by passing in the asymmetric key id within the "clavis=" boot + param. This keyring is required by the Clavis LSM.
security/clavis/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.o
security/clavis/clavis.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SECURITY_CLAVIS_H_ +#define _SECURITY_CLAVIS_H_ +#include <keys/asymmetric-type.h> + +/* Max length for the asymmetric key id contained on the boot param */ +#define CLAVIS_BIN_KID_MAX 32 + +struct asymmetric_setup_kid { +struct asymmetric_key_id id; +unsigned char data[CLAVIS_BIN_KID_MAX ]; +}; +#endif /* _SECURITY_CLAVIS_H_ */
security/clavis/clavis_keyring.c new file +115 -0
115 lines not on this page · raw message
security/integrity/iint.c +2 -0
@@ -36,6 +36,8 @@ int integrity_kernel_read(struct file *file, loff_t offset,*/ void __init integrity_load_keys (void ) { +late_init_clavis_setup (); +ima_load_x509 ();if (!IS_ENABLED (CONFIG_IMA_LOAD_X509 ))
Signature · 1 line
2.45.0
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
security/clavis/clavis_keyring.c line 42
Quoted 11 lines · Eric Snowberg
+static struct
asymmetric_key_id*clavis_parse_boot_param(char *kid, structasymmetric_key_id*akid,(quoted diff) +1
-0+ int
akid_max_len)security/clavis/clavis_keyring.c new file +7
-0+{ +int error, hex_len; + +if (!kid) +return 0 ; + + hex_len =strlen (kid) /2 ;
Hmmm... I'd consider sanity checking this:
size_t len;
/* ... */
len = strlen(kid);
if (len % 2) {
pr_err("Clavis key id has invalid length %lu\n", len);
return 0;
}
hex_len = len / 2;BR, Jarkko
Eric Snowberg
reviewerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
Quoted 23 lines · Jarkko Sakkinen
security/clavis/clavis_keyring.c line 42
Quoted 11 lines · Eric Snowberg
+static struct
asymmetric_key_id*clavis_parse_boot_param(char *kid, structasymmetric_key_id*akid,
+ intakid_max_len)security/clavis/clavis_keyring.c new file +7
-0+{ +int error, hex_len; + +if (!kid) +return 0 ; + + hex_len =strlen (kid) /2 ;Hmmm... I'd consider sanity checking this:
size_tlen;/* ... */
Quoted 8 lines
len = strlen(kid);
if (len % 2) {pr_err("Clavis key id has invalid length %lu\n", len); return 0;
}
hex_len= len / 2;
Good catch, I will include this in the next round. I have also added a kunit test for this as well. Thanks.
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
Quoted 31 lines · Eric Snowberg
Quoted 31 lines
On Oct 17, 2024, at 10:50 AM, Jarkko Sakkinen <[email protected]> wrote:
security/clavis/clavis_keyring.c line 42
Quoted 12 lines · Eric Snowberg
+static struct
asymmetric_key_id*clavis_parse_boot_param(char *kid,
structasymmetric_key_id*akid,
+ intakid_max_len)security/clavis/clavis_keyring.c new file +7
-0+{ +int error, hex_len; + +if (!kid) +return 0 ; + + hex_len =strlen (kid) /2 ;Hmmm... I'd consider sanity checking this:
size_tlen;/* ... */
len = strlen(kid);
if (len % 2) {pr_err("Clavis key id has invalid length %lu\n", len); return 0;
}
Quoted 6 lines
Quoted 2 lines
hex_len= len / 2;Good catch, I will include this in the next round. I have also added a kunit test
for this as well. Thanks.
I guess hex2bin() would eventually catch this issue, i.e. not an actual bug, but I still think that you are better off doing also check here and get an appropriate message to klog if that ever happens :-)
BR, Jarkko
Mimi Zohar
maintainerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
In reply to Eric SnowbergQuoted 3 lines · Eric Snowberg
Introduce a new system keyring called clavis. This keyring shall contain a single asymmetric key. This key may be a linked to a key already contained in one of the system keyrings (builtin, secondary, or platform).
Although "This key may be a linked to ..." is might be correct. Being introduced in this patch is only the ability of loading a key by specifying it on the boot command line. In this case, the key must be on one of the system keyrings.
Quoted 27 lines
One way to add this key into this keyring is during boot by passing in the asymmetric key id within the new "clavis=" boot param. If a matching key is found in one of the system keyrings, a link shall be created. This keyring will be used in the future by the new Clavis LSM.
Signed-off-by Eric Snowberg <[email protected]>--- .../admin-guide/kernel-parameters.txt | 6 + include/linux/integrity.h | 8 ++ security/Kconfig | 1 + security/Makefile | 1 + security/clavis/Kconfig | 11 ++ security/clavis/Makefile | 3 + security/clavis/clavis.h | 13 ++ security/clavis/clavis_keyring.c | 115 ++++++++++++++++++ security/integrity/iint.c | 2 + 9 files changed, 160 insertions(+) create mode 100644 security/clavis/Kconfig create mode 100644 security/clavis/Makefile create mode 100644 security/clavis/clavis.h create mode 100644 security/clavis/clavis_keyring.cDocumentation/admin-guide/kernel-parameters.txt +0
-0
Documentation/admin-guide/kernel-parameters.txt line 652
Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -645,6 +645,12 @@ cio_ignore= [S390] See Documentation/arch/s390/common_io.rst for details. + clavis= [SECURITY,EARLY] + Identifies a specific key contained in one of the system + keyrings (builtin, secondary, or platform) to be used as + the Clavis root of trust. + Format: { <keyid> }
Include .machine keyring here.
Quoted 53 lines
Documentation/admin-guide/kernel-parameters.txt +1
-0+ clearcpuid=X[,X...] [X86] Disable CPUID feature X for the kernel. See arch/x86/include/asm/cpufeatures.h for the valid bitinclude/linux/integrity.h +8
-0@@ -23,6 +23,14 @@ enum integrity_status {#ifdef CONFIG_INTEGRITY extern void __init integrity_load_keys (void ); +#ifdef CONFIG_SECURITY_CLAVIS +void __init late_init_clavis_setup (void ); +#else +static inline void late_init_clavis_setup (void ) +{ +} +#endif +#else static inline void integrity_load_keys (void ) {security/Kconfig +1
-0@@ -225,6 +225,7 @@ source "security/safesetid/Kconfig" source "security/lockdown/Kconfig" source "security/landlock/Kconfig" source "security/ipe/Kconfig" +source "security/clavis/Kconfig" source "security/integrity/Kconfig"security/Makefile +1
-0@@ -26,6 +26,7 @@ obj-$(CONFIG_CGROUPS) += device_cgroup.o obj-$(CONFIG_BPF_LSM) += bpf/ obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/ obj-$(CONFIG_SECURITY_IPE) += ipe/ +obj-$(CONFIG_SECURITY_CLAVIS) += clavis/ # Object integrity file lists obj-$(CONFIG_INTEGRITY) += integrity/security/clavis/Kconfig new file +0
-0
security/clavis/Kconfig line 2
Quoted 2 lines
security/clavis/Kconfig new file +2
-0@@ -0,0 +1,11 @@ +config SECURITY_CLAVIS + bool "Clavis keyring"
Isn't SECURITY_CLAVIS the new LSM? Why is the bool defined as just "Clavis keyring"?
security/clavis/Kconfig line 11
Quoted 9 lines
security/clavis/Kconfig new file +9
-0+ depends on SECURITY + select SYSTEM_DATA_VERIFICATION + select CRYPTO_SHA256 + help + Enable the clavis keyring. This keyring shall contain a single asymmetric key. + This key shall be linked to a key already contained in one of the system + keyrings (builtin, secondary, or platform). One way to add this key + is during boot by passing in the asymmetric key id within the "clavis=" boot + param. This keyring is required by the Clavis LSM.
If SECURITY_CLAVIS is a new LSM, the 'help' shouldn't be limited to just the clavis keyring, but written at a higher level describing the new LSM. For example,
This option enables the Clavis LSM, which provides the ability to configure and enforce the usage of keys contained on the system keyrings - .builtin_trusted_keys, .secondary_trusted_keys, .machine, and .platform keyrings. The clavis LSM defines a keyring named "clavis", which contains a single asymmetric key and the key usage rules.
The single asymmetric key may be specified on the boot command line ...
[The patch that introduces the key usage rules would add additional info here.]
[The patch that adds the Documentatoin would add a reference here.]
Quoted 41 lines
security/clavis/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.osecurity/clavis/clavis.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SECURITY_CLAVIS_H_ +#define _SECURITY_CLAVIS_H_ +#include <keys/asymmetric-type.h> + +/* Max length for the asymmetric key id contained on the boot param */ +#define CLAVIS_BIN_KID_MAX 32 + +struct asymmetric_setup_kid { +struct asymmetric_key_id id; +unsigned char data[CLAVIS_BIN_KID_MAX ]; +}; +#endif /* _SECURITY_CLAVIS_H_ */ security/clavis/clavis_keyring.c new file +7
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/security.h> +#include <linux/integrity.h> +#include <keys/asymmetric-type.h> +#include <keys/system_keyring.h> +#include "clavis.h"
security/clavis/clavis_keyring.c line 17
Quoted 10 lines
security/clavis/clavis_keyring.c new file +10
-0+ +static struct key *clavis_keyring; +static struct asymmetric_key_id *clavis_boot_akid; +static struct asymmetric_setup_kid clavis_setup_akid; +static bool clavis_enforced; + +static bool clavis_acl_enforced (void ) +{ +return clavis_enforced; +}
Add blank line between functions.
Mimi
Quoted 111 lines
security/clavis/clavis_keyring.c new file +98
-0+static int restrict_link_for_clavis (struct key *dest_keyring,const struct key_type *type, +const union key_payload *payload,struct key *restrict_key) +{ +/* +* Allow a single asymmetric key into this keyring. This key is used as the +* root of trust for anything added afterwards. +*/ +if (type == &key_type_asymmetric && dest_keyring == clavis_keyring && + !clavis_acl_enforced ()) { + clavis_enforced = true; +return 0 ; + } + +return -EOPNOTSUPP ; +} + +static struct asymmetric_key_id *clavis_parse_boot_param (char *kid,struct asymmetric_key_id *akid, +int akid_max_len) +{ +int error, hex_len; + +if (!kid) +return 0 ; + + hex_len =strlen (kid) /2 ; + +if (hex_len > akid_max_len) +return 0 ; + + akid->len = hex_len; + error =hex2bin (akid->data, kid, akid->len); + +if (error <0 ) { +pr_err ("Unparsable clavis key id\n" ); +return 0 ; + } + +return akid; +} + +static int __init clavis_param (char *kid) +{ + clavis_boot_akid =clavis_parse_boot_param (kid, &clavis_setup_akid.id, +ARRAY_SIZE (clavis_setup_akid.data)); + +return 1 ; +} + +__setup ("clavis=" , clavis_param); + +static struct key *clavis_keyring_alloc (const char *desc,struct key_restriction *restriction) +{ +struct key *keyring; + + keyring =keyring_alloc (desc,GLOBAL_ROOT_UID ,GLOBAL_ROOT_GID ,current_cred (), +KEY_POS_VIEW |KEY_POS_READ |KEY_POS_SEARCH |KEY_POS_WRITE | +KEY_USR_VIEW |KEY_USR_READ |KEY_USR_SEARCH |KEY_USR_WRITE , +KEY_ALLOC_NOT_IN_QUOTA |KEY_ALLOC_SET_KEEP , + restriction,NULL ); +return keyring; +} + +static struct key_restriction *clavis_restriction_alloc (key_restrict_link_func_t check_func) +{ +struct key_restriction *restriction; + + restriction =kzalloc (sizeof (*restriction),GFP_KERNEL ); + +if (restriction) + restriction->check = check_func; + +return restriction; +} + +static int __init clavis_keyring_init (void ) +{ +struct key_restriction *restriction; + + restriction =clavis_restriction_alloc (restrict_link_for_clavis); +if (!restriction) +panic ("Can't allocate clavis keyring restriction\n" ); + + clavis_keyring =clavis_keyring_alloc (".clavis" , restriction); +if (IS_ERR (clavis_keyring)) +panic ("Can't allocate clavis keyring\n" ); + +return 0 ; +} + +void __init late_init_clavis_setup (void ) +{ +clavis_keyring_init (); + +if (!clavis_boot_akid) +return ; + +system_key_link (clavis_keyring, clavis_boot_akid); +}security/integrity/iint.c +2
-0@@ -36,6 +36,8 @@ int integrity_kernel_read(struct file *file, loff_t offset,*/ void __init integrity_load_keys (void ) { +late_init_clavis_setup (); +ima_load_x509 ();if (!IS_ENABLED (CONFIG_IMA_LOAD_X509 ))
Eric Snowberg
reviewerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
Quoted 13 lines · Mimi Zohar
Quoted 3 lines · Eric Snowberg
Introduce a new system keyring called clavis. This keyring shall contain a single asymmetric key. This key may be a linked to a key already contained in one of the system keyrings (builtin, secondary, or platform).
Although "This key may be a linked to ..." is might be correct. Being introduced in this patch is only the ability of loading a key by specifying it on the boot command line. In this case, the key must be on one of the system keyrings.
I'll reword this
Quoted 30 lines
Quoted 30 lines
One way to add this key into this keyring is during boot by passing in the asymmetric key id within the new "clavis=" boot param. If a matching key is found in one of the system keyrings, a link shall be created. This keyring will be used in the future by the new Clavis LSM.
Signed-off-by Eric Snowberg <[email protected]>---
.../admin-guide/kernel-parameters.txt | 6 + include/linux/integrity.h | 8 ++ security/Kconfig | 1 + security/Makefile | 1 + security/clavis/Kconfig | 11 ++ security/clavis/Makefile | 3 + security/clavis/clavis.h | 13 ++ security/clavis/clavis_keyring.c | 115 ++++++++++++++++++ security/integrity/iint.c | 2 + 9 files changed, 160 insertions(+)create mode 100644
security/clavis/Kconfigcreate mode 100644security/clavis/Makefilecreate mode 100644security/clavis/clavis.hcreate mode 100644security/clavis/clavis_keyring.cDocumentation/admin-guide/kernel-parameters.txt +0
-0@@ -645,6 +645,12 @@cio_ignore= [S390]
SeeDocumentation/arch/s390/common_io.rstfor details.
Quoted 7 lines
Quoted 5 lines
+ clavis= [SECURITY,EARLY]
+ Identifies a specific key contained in one of the system
+ keyrings (builtin, secondary, or platform) to be used as
+ the Clavis root of trust.
+ Format: { <keyid> }Include .machine keyring here.
and I'll add this too.
Quoted 79 lines
Quoted 53 lines
+
clearcpuid=X[,X...] [X86]
Disable CPUID feature X for the kernel. Seearch/x86/include/asm/cpufeatures.hfor the valid bitinclude/linux/integrity.h +8
-0@@ -23,6 +23,14 @@ enum integrity_status {#ifdef CONFIG_INTEGRITY extern void __init integrity_load_keys (void ); +#ifdef CONFIG_SECURITY_CLAVIS +void __init late_init_clavis_setup (void ); +#else +static inline void late_init_clavis_setup (void ) +{ +} +#endif +#else static inline void integrity_load_keys (void ) {security/Kconfig +0
-0@@ -225,6 +225,7 @@ source "security/safesetid/Kconfig"source "
security/lockdown/Kconfig"
source "security/landlock/Kconfig"
source "security/ipe/Kconfig"
+source "security/clavis/Kconfig"source "
security/integrity/Kconfig"security/Makefile +0
-0@@ -26,6 +26,7 @@ obj-$(CONFIG_CGROUPS) += device_cgroup.oobj-$(CONFIG_BPF_LSM) += bpf/
obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/
obj-$(CONFIG_SECURITY_IPE) += ipe/
+obj-$(CONFIG_SECURITY_CLAVIS) += clavis/# Object integrity file lists
obj-$(CONFIG_INTEGRITY) += integrity/security/clavis/Kconfig new file +0
-0security/clavis/Kconfig line 2
Quoted 2 lines
security/clavis/Kconfig new file +2
-0@@ -0,0 +1,11 @@ +config SECURITY_CLAVIS + bool "Clavis keyring"Isn't
SECURITY_CLAVISthe new LSM? Why is the bool defined as just "Clavis keyring"?security/clavis/Kconfig line 11
Quoted 9 lines
security/clavis/Kconfig new file +9
-0+ depends on SECURITY + select SYSTEM_DATA_VERIFICATION + select CRYPTO_SHA256 + help + Enable the clavis keyring. This keyring shall contain a single asymmetric key. + This key shall be linked to a key already contained in one of the system + keyrings (builtin, secondary, or platform). One way to add this key + is during boot by passing in the asymmetric key id within the "clavis=" boot + param. This keyring is required by the Clavis LSM.If
SECURITY_CLAVISis a new LSM, the 'help' shouldn't be limited to just the clavis keyring, but written at a higher level describing the new LSM. For example,This option enables the Clavis LSM, which provides the ability to configure and enforce the usage of keys contained on the system keyrings - .builtin_trusted_keys, .secondary_trusted_keys, .machine, and .platform keyrings. The clavis LSM defines a keyring named "clavis", which contains a single asymmetric key and the key usage rules.
Quoted 5 lines
The single asymmetric key may be specified on the boot command line ...
[The patch that introduces the key usage rules would add additional info here.]
[The patch that adds the Documentatoin would add a reference here.]
I went the route of creating the keyring in this patch and then introducing the LSM which uses it in a later patch. My reasoning was it can be tested independently. Also, I thought it would make it easier to review, since everything isn't contained within a single patch. I could look at combining them together if you think that would be better.
Quoted 46 lines
Quoted 46 lines
security/clavis/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.osecurity/clavis/clavis.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SECURITY_CLAVIS_H_ +#define _SECURITY_CLAVIS_H_ +#include <keys/asymmetric-type.h> + +/* Max length for the asymmetric key id contained on the boot param */ +#define CLAVIS_BIN_KID_MAX 32 + +struct asymmetric_setup_kid { +struct asymmetric_key_id id; +unsigned char data[CLAVIS_BIN_KID_MAX ]; +}; +#endif /* _SECURITY_CLAVIS_H_ */ security/clavis/clavis_keyring.c new file +11
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/security.h> +#include <linux/integrity.h> +#include <keys/asymmetric-type.h> +#include <keys/system_keyring.h> +#include "clavis.h" + +static struct key *clavis_keyring; +static struct asymmetric_key_id *clavis_boot_akid; +static struct asymmetric_setup_kid clavis_setup_akid;
Quoted 8 lines
security/clavis/clavis_keyring.c line 17
Quoted 6 lines
security/clavis/clavis_keyring.c new file +6
-0+static bool clavis_enforced; + +static bool clavis_acl_enforced (void ) +{ +return clavis_enforced; +}Add blank line between functions.
I'll add the blank line in the next round. Thanks.
Mimi Zohar
maintainerRe: [RFC PATCH v3 03/13] clavis: Introduce a new system keyring called clavis
Hi Eric,
Quoted 30 lines · Eric Snowberg
Quoted 30 lines
Quoted 2 lines
+config
SECURITY_CLAVIS
+ bool "Clavis keyring"Isn't
SECURITY_CLAVISthe new LSM? Why is the bool defined as just "Clavis keyring"?Quoted 9 lines
+ depends on SECURITY
+ selectSYSTEM_DATA_VERIFICATION
+ selectCRYPTO_SHA256
+ help
+ Enable the clavis keyring. This keyring shall contain a single asymmetric key. + This key shall be linked to a key already contained in one of the system + keyrings (builtin, secondary, or platform). One way to add this key + is during boot by passing in the asymmetric key id within the "clavis=" boot + param. This keyring is required by the Clavis LSM.If
SECURITY_CLAVISis a new LSM, the 'help' shouldn't be limited to just the clavis keyring, but written at a higher level describing the new LSM. For example,This option enables the Clavis LSM, which provides the ability to configure and enforce the usage of keys contained on the system keyrings - .builtin_trusted_keys, .secondary_trusted_keys, .machine, and .platform keyrings. The clavis LSM defines a keyring named "clavis", which contains a single asymmetric key and the key usage rules.
The single asymmetric key may be specified on the boot command line ...
[The patch that introduces the key usage rules would add additional info here.]
Quoted 7 lines
Quoted 1 line
[The patch that adds the Documentatoin would add a reference here.]
I went the route of creating the keyring in this patch and then introducing the LSM which uses it in a later patch. My reasoning was it can be tested independently. Also, I thought it would make it easier to review, since everything isn't contained within a single patch. I could look at combining them together if you think that would be better.
SECURITY_CLAVIS is not just about the CLAVIS keyring, right? The Kconfig can be defined and used here, but eventually the SECURITY_CLAVIS "help" needs to be updated to describe the new LSM.
thanks,
Mimi
Eric Snowberg
reviewerRFC PATCH v3 4/13 keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
In reply to Eric SnowbergAdd a new verification type called VERIFYING_CLAVIS_SIGNATURE. This new usage will be used for validating keys added to the new clavis LSM keyring. This will be introduced in a follow-on patch.
--- crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_verify.c | 1 + include/linux/verification.h | 2 ++ 3 files changed, 4 insertions(+)
crypto/asymmetric_keys/asymmetric_type.c +1 -0
@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , };EXPORT_SYMBOL_GPL (key_being_used_for);
crypto/asymmetric_keys/pkcs7_verify.c +1 -0
@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, }/* Authattr presence checked in parser */ break ; +case VERIFYING_CLAVIS_SIGNATURE :case VERIFYING_UNSPECIFIED_SIGNATURE :if (pkcs7->data_type != OID_data) {pr_warn ("Invalid unspecified sig (not pkcs7-data)\n" );
include/linux/verification.h +2 -0
@@ -36,6 +36,8 @@ enum key_being_used_for {VERIFYING_KEY_SIGNATURE ,VERIFYING_KEY_SELF_SIGNATURE ,VERIFYING_UNSPECIFIED_SIGNATURE , +/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at the end. */ +VERIFYING_CLAVIS_SIGNATURE , NR__KEY_BEING_USED_FOR };extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR ];
Signature · 1 line
2.45.0
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
Quoted 53 lines · Eric Snowberg
Add a new verification type called VERIFYING_CLAVIS_SIGNATURE. This new
usage will be used for validating keys added to the new clavis LSM keyring.
This will be introduced in a follow-on patch.Signed-off-by Eric Snowberg <[email protected]>---
crypto/asymmetric_keys/asymmetric_type.c | 1 +
crypto/asymmetric_keys/pkcs7_verify.c | 1 +
include/linux/verification.h | 2 ++3 files changed, 4 insertions(+)crypto/asymmetric_keys/asymmetric_type.c +1
-0@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , }; EXPORT_SYMBOL_GPL(key_being_used_for);crypto/asymmetric_keys/pkcs7_verify.c +1
-0@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, } /* Authattr presence checked in parser */ break; +case VERIFYING_CLAVIS_SIGNATURE :case
VERIFYING_UNSPECIFIED_SIGNATURE:
if (pkcs7->data_type!=OID_data) {pr_warn("Invalid unspecified sig (not pkcs7- data)\n");include/linux/verification.h +1
-0@@ -36,6 +36,8 @@ enum key_being_used_for { VERIFYING_KEY_SIGNATURE, VERIFYING_KEY_SELF_SIGNATURE, VERIFYING_UNSPECIFIED_SIGNATURE, +/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at the end. */
include/linux/verification.h +1
-0+ VERIFYING_CLAVIS_SIGNATURE,
Quoted 3 lines
NR__KEY_BEING_USED_FOR
};
extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
This looks as good as it can get. Just wondering that does this Clavis thing connect with the TPM2 asymmetric keys that I've been working on? I.e. can they be used in tandem. I should really update that patch set (latest from April).
BR, Jarkko
Eric Snowberg
reviewerRe: [RFC PATCH v3 04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
Quoted 58 lines · Jarkko Sakkinen
Quoted 53 lines · Eric Snowberg
Add a new verification type called
VERIFYING_CLAVIS_SIGNATURE. This new
usage will be used for validating keys added to the new clavis LSM keyring.
This will be introduced in a follow-on patch.Signed-off-by Eric Snowberg <[email protected]>--- crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_verify.c | 1 + include/linux/verification.h | 2 ++ 3 files changed, 4 insertions(+)crypto/asymmetric_keys/asymmetric_type.c +1
-0@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , };EXPORT_SYMBOL_GPL (key_being_used_for);crypto/asymmetric_keys/pkcs7_verify.c +1
-0@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, }/* Authattr presence checked in parser */ break ; +case VERIFYING_CLAVIS_SIGNATURE :case VERIFYING_UNSPECIFIED_SIGNATURE :if (pkcs7->data_type != OID_data) { pr_warn("Invalid unspecified sig (not pkcs7-data)\n");
include/linux/verification.h +1
-0@@ -36,6 +36,8 @@ enum key_being_used_for {VERIFYING_KEY_SIGNATURE ,VERIFYING_KEY_SELF_SIGNATURE , VERIFYING_UNSPECIFIED_SIGNATURE, +/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at the end. */
+VERIFYING_CLAVIS_SIGNATURE,
Quoted 8 lines
Quoted 3 lines
NR__KEY_BEING_USED_FOR
};
extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];This looks as good as it can get. Just wondering that does this Clavis thing connect with the TPM2 asymmetric keys that I've been working on? I.e. can they be used in tandem. I should really update that patch set (latest from April).
With some changes, I think they could be used in tandem. If I'm looking at the correct series, tpm2_key_rsa_describe would need to be changed to return a unique identifier, instead of "TPM2/RSA". This identifier could be used instead of the skid when creating a Clavis ACL. There would probably also need to be a new system kernel keyring containing these TPM keys. Similar to the builtin, secondary, machine, etc.
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
Quoted 74 lines · Eric Snowberg
Quoted 66 lines
On Oct 17, 2024, at 1:20 PM, Jarkko Sakkinen <[email protected]> wrote:
Quoted 53 lines · Eric Snowberg
Add a new verification type called
VERIFYING_CLAVIS_SIGNATURE. This
new
usage will be used for validating keys added to the new clavis LSM
keyring.
This will be introduced in a follow-on patch.Signed-off-by Eric Snowberg <[email protected]>---
crypto/asymmetric_keys/asymmetric_type.c | 1 +
crypto/asymmetric_keys/pkcs7_verify.c | 1 +
include/linux/verification.h | 2 ++3 files changed, 4 insertions(+)crypto/asymmetric_keys/asymmetric_type.c +1
-0@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , }; EXPORT_SYMBOL_GPL(key_being_used_for);crypto/asymmetric_keys/pkcs7_verify.c +1
-0@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, } /* Authattr presence checked in parser */ break; +case VERIFYING_CLAVIS_SIGNATURE :case
VERIFYING_UNSPECIFIED_SIGNATURE:
if (pkcs7->data_type!=OID_data) {
pr_warn("Invalid unspecified sig (not pkcs7-
data)\n");include/linux/verification.h +1
-0@@ -36,6 +36,8 @@ enum key_being_used_for { VERIFYING_KEY_SIGNATURE, VERIFYING_KEY_SELF_SIGNATURE, VERIFYING_UNSPECIFIED_SIGNATURE, +/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at Quoted 6 lines
the end. */
+VERIFYING_CLAVIS_SIGNATURE,
NR__KEY_BEING_USED_FOR
};
extern const char *const
key_being_used_for[NR__KEY_BEING_USED_FOR];Quoted 7 lines
This looks as good as it can get. Just wondering that does this Clavis
thing connect with the TPM2 asymmetric keys that I've been working on?
I.e. can they be used in tandem. I should really update that patch set
(latest from April).
Quoted 10 lines
With some changes, I think they could be used in tandem. If I'm looking at
the correct series,tpm2_key_rsa_describewould need to be changed to return a unique identifier, instead of "TPM2/RSA". This identifier could be
used instead of the skid when creating a Clavis ACL. There would probably
also need to be a new system kernel keyring containing these TPM keys.
Similar to the builtin, secondary, machine, etc.
I think when I finally get into working on this again I focus on purely to get ECDSA right. Thanks for the tip, most likely this revamp will happen post your patch set. I'm still busy fixing corner cases with the bus encryption that James Bottomley contributed.
BR, Jarkko
Mimi Zohar
maintainerRe: [RFC PATCH v3 04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
In reply to Eric SnowbergQuoted 28 lines · Eric Snowberg
Add a new verification type called
VERIFYING_CLAVIS_SIGNATURE. This new usage will be used for validating keys added to the new clavis LSM keyring. This will be introduced in a follow-on patch.Signed-off-by Eric Snowberg <[email protected]>--- crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_verify.c | 1 + include/linux/verification.h | 2 ++ 3 files changed, 4 insertions(+)crypto/asymmetric_keys/asymmetric_type.c +1
-0@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , };EXPORT_SYMBOL_GPL (key_being_used_for);crypto/asymmetric_keys/pkcs7_verify.c +0
-0
crypto/asymmetric_keys/pkcs7_verify.c int pkcs7_verify(struct pkcs7_message *pkcs7, · line 431
Quoted 4 lines
crypto/asymmetric_keys/pkcs7_verify.c +1
-0@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, }/* Authattr presence checked in parser */ break ; +case VERIFYING_CLAVIS_SIGNATURE :
Add "fallthrough;"
Quoted 16 lines
crypto/asymmetric_keys/pkcs7_verify.c +0
-0case VERIFYING_UNSPECIFIED_SIGNATURE :if (pkcs7->data_type != OID_data) {pr_warn ("Invalid unspecified sig (not pkcs7-data)\n" );include/linux/verification.h +2
-0@@ -36,6 +36,8 @@ enum key_being_used_for {VERIFYING_KEY_SIGNATURE ,VERIFYING_KEY_SELF_SIGNATURE ,VERIFYING_UNSPECIFIED_SIGNATURE , +/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at the end. */ +VERIFYING_CLAVIS_SIGNATURE , NR__KEY_BEING_USED_FOR };extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR ];
Eric Snowberg
reviewerRe: [RFC PATCH v3 04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
Quoted 40 lines · Mimi Zohar
Quoted 28 lines · Eric Snowberg
Add a new verification type called
VERIFYING_CLAVIS_SIGNATURE. This new usage will be used for validating keys added to the new clavis LSM keyring. This will be introduced in a follow-on patch.Signed-off-by Eric Snowberg <[email protected]>---
crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_verify.c | 1 + include/linux/verification.h | 2 ++ 3 files changed, 4 insertions(+)crypto/asymmetric_keys/asymmetric_type.c +1
-0@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_KEY_SIGNATURE] = "key sig", [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig", [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig", + [VERIFYING_CLAVIS_SIGNATURE ] ="clavis sig" , };EXPORT_SYMBOL_GPL (key_being_used_for);crypto/asymmetric_keys/pkcs7_verify.c +0
-0crypto/asymmetric_keys/pkcs7_verify.c int pkcs7_verify(struct pkcs7_message *pkcs7, · line 431
Quoted 4 lines
crypto/asymmetric_keys/pkcs7_verify.c +1
-0@@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, }/* Authattr presence checked in parser */ break ; +case VERIFYING_CLAVIS_SIGNATURE :Add "fallthrough;"
Quoted 2 lines
I'll add the fallthrough in the next round, thanks.
Eric Snowberg
reviewerRFC PATCH v3 5/13 clavis: Introduce a new key type called clavis_key_acl
In reply to Eric SnowbergIntroduce a new key type for keyring access control. The new key type is called clavis_key_acl. The clavis_key_acl contains the subject key identifier along with the allowed usage type for the key.
The format is as follows:
XX:YYYYYYYYYYY
XX - Single byte of the key type
VERIFYING_MODULE_SIGNATURE 00 VERIFYING_FIRMWARE_SIGNATURE 01 VERIFYING_KEXEC_PE_SIGNATURE 02 VERIFYING_KEY_SIGNATURE 03 VERIFYING_KEY_SELF_SIGNATURE 04 VERIFYING_UNSPECIFIED_SIGNATURE 05
: - ASCII colon
YY - Even number of hexadecimal characters representing the key id
This key type will be used in the clavis keyring for access control. To be added to the clavis keyring, the clavis_key_acl must be S/MIME signed by the sole asymmetric key contained within it.
Below is an example of how this could be used. Within the example, the key (b360d113c848ace3f1e6a80060b43d1206f0487d) is already in the machine keyring. The intended usage for this key is to validate a signed kernel for kexec:
echo "02:b360d113c848ace3f1e6a80060b43d1206f0487d" > kernel-acl.txt
The next step is to sign it:
openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in \ kernel-acl.txt -out kernel-acl.pkcs7 -binary -outform DER \ -nodetach -noattr
The final step is how to add the acl to the .clavis keyring:
keyctl padd clavis_key_acl "" %:.clavis < kernel-acl.pkcs7
Afterwards the new clavis_key_acl can be seen in the .clavis keyring:
keyctl show %:.clavis
Keyring
keyring: .clavis
\_ asymmetric: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 \_ clavis_key_acl: 02:b360d113c848ace3f1e6a80060b43d1206f0487d
--- security/clavis/clavis.h | 1 + security/clavis/clavis_keyring.c | 173 +++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+)
security/clavis/clavis.h +1 -0
@@ -5,6 +5,7 @@/* Max length for the asymmetric key id contained on the boot param */ #define CLAVIS_BIN_KID_MAX 32 +#define CLAVIS_ASCII_KID_MAX 64struct asymmetric_setup_kid {struct asymmetric_key_id id;
security/clavis/clavis_keyring.c +173 -0
203 lines not on this page · raw message
Signature · 1 line
2.45.0
Re: [RFC PATCH v3 05/13] clavis: Introduce a new key type called clavis_key_acl
Quoted 9 lines · Eric Snowberg
Introduce a new key type for keyring access control. The new key type is called
clavis_key_acl. Theclavis_key_aclcontains the subject key identifier along with the allowed usage type for the key.The format is as follows:
XX:YYYYYYYYYYY
XX - Single byte of the key type
Quoted 8 lines
VERIFYING_MODULE_SIGNATURE 00 VERIFYING_FIRMWARE_SIGNATURE 01 VERIFYING_KEXEC_PE_SIGNATURE 02 VERIFYING_KEY_SIGNATURE 03 VERIFYING_KEY_SELF_SIGNATURE 04 VERIFYING_UNSPECIFIED_SIGNATURE 05: - ASCII colon
YY - Even number of hexadecimal characters representing the key id
This is expected to be *lowercase* hexadecimal characters in the code; can that restriction please be documented? (Coming back here, there is a tolower pass performed when copying from userspace, so this seems to be an internal requirement, not userspace. Might be worth documenting somewhere in case the kernel wants to make such a key internally.)
I also see a 32-byte (64 hex characters) limit in the code; that should also be documented somewhere.
Quoted 21 lines
This key type will be used in the clavis keyring for access control. To be added to the clavis keyring, the
clavis_key_aclmust be S/MIME signed by the sole asymmetric key contained within it.Below is an example of how this could be used. Within the example, the key (
b360d113c848ace3f1e6a80060b43d1206f0487d) is already in the machine keyring. The intended usage for this key is to validate a signed kernel for kexec:echo "02:b360d113c848ace3f1e6a80060b43d1206f0487d" > kernel-acl.txt
The next step is to sign it:
openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in \ kernel-acl.txt -out kernel-acl.pkcs7 -binary -outform DER \ -nodetach -noattrThe final step is how to add the acl to the .clavis keyring:
keyctl padd
clavis_key_acl"" %:.clavis < kernel-acl.pkcs7
Quoted 7 lines
Afterwards the new
clavis_key_aclcan be seen in the .clavis keyring:keyctl show %:.clavis
Keyring
keyring: .clavis
\_ asymmetric: Clavis LSM key:4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8\_clavis_key_acl: 02:b360d113c848ace3f1e6a80060b43d1206f0487d
Can this be committed to Documentation/ and not just the Git history please?
Code comments inline below.
Quoted 45 lines
Signed-off-by Eric Snowberg <[email protected]>--- security/clavis/clavis.h | 1 + security/clavis/clavis_keyring.c | 173 +++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+)security/clavis/clavis.h +1
-0@@ -5,6 +5,7 @@/* Max length for the asymmetric key id contained on the boot param */ #define CLAVIS_BIN_KID_MAX 32 +#define CLAVIS_ASCII_KID_MAX 64struct asymmetric_setup_kid {struct asymmetric_key_id id;security/clavis/clavis_keyring.c +10
-0@@ -2,8 +2,12 @@#include <linux/security.h> #include <linux/integrity.h> +#include <linux/ctype.h> #include <keys/asymmetric-type.h> +#include <keys/asymmetric-subtype.h> #include <keys/system_keyring.h> +#include <keys/user-type.h> +#include <crypto/pkcs7.h> #include "clavis.h" static struct key *clavis_keyring;@@ -11,10 +15,173 @@ static struct asymmetric_key_id *clavis_boot_akid;static struct asymmetric_setup_kid clavis_setup_akid;static bool clavis_enforced; +static int pkcs7_preparse_content (void *ctx,const void *data,size_t len,size_t asn1hdrlen) +{ +struct key_preparsed_payload *prep = ctx; +const void *saved_prep_data; +size_t saved_prep_datalen; +char *desc;
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 33
Quoted 10 lines
security/clavis/clavis_keyring.c +10
-0+int ret, i; + +/* key_acl_free_preparse will free this */ + desc =kmemdup (data, len,GFP_KERNEL ); +if (!desc) +return -ENOMEM ; + +/* Copy the user supplied contents and remove any white space. */ +for (i =0 ; i < len; i++) { + desc[i] =tolower (desc[i]);
Ah, looking here it seems that userspace can provide upper or lowercase. THat this is being performed should be added to the comment here.
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 35
Quoted 2 lines
security/clavis/clavis_keyring.c +2
-0+if (isspace (desc[i])) + desc[i] =0 ;
How is setting a space to 0 *removing* it? Surely the isxdigit check internally is going to reject this. Perhaps you meant to have two indices into desc, one read and one write and to stall the write index as long as we're reading whitespace?
Also, that whitespace is stripped is a userspace-relevant detail that should be documented.
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 108
Quoted 11 lines
security/clavis/clavis_keyring.c +11
-0+static void key_acl_destroy (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("destroy clavis_key_acl denied\n" ); +} + +static void key_acl_revoke (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("revoke clavis_key_acl denied\n" ); +}
These keys cannot be destroyed or revoked? This seems…novel to me. What if there's a timeout on the key? If such keys are immortal, timeouts should also be refused?
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 123
Quoted 9 lines
security/clavis/clavis_keyring.c +9
-0+static int key_acl_vet_description (const char *desc) +{ +int i, desc_len; +s16 ktype; + +if (!desc) + goto invalid; + + desc_len =sizeof (desc);
This should be strlen, no?
Quoted 29 lines
security/clavis/clavis_keyring.c +29
-0+/* +* clavis_acl format: +* xx:yyyy... +* +* xx - Single byte of the key type +* : - Ascii colon +* yyyy.. - Even number of hexadecimal characters representing the keyid +*/ + +/* The min clavis acl is 7 characters. */ +if (desc_len <7 ) + goto invalid; + +/* Check the first byte is a valid key type. */ +if (sscanf (desc,"%2hx" , &ktype) !=1 ) + goto invalid; + +if (ktype >=VERIFYING_CLAVIS_SIGNATURE ) + goto invalid; + +/* Check that there is a colon following the key type */ +if (desc[2 ] !=':' ) + goto invalid; + +/* Move past the colon. */ + desc +=3 ; + +for (i =0 ; *desc && i <CLAVIS_ASCII_KID_MAX ; desc++, i++) { +/* Check if lowercase hex number */
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 163
Quoted 10 lines
security/clavis/clavis_keyring.c +10
-0+if (!isxdigit (*desc) ||isupper (*desc)) + goto invalid; + } + +/* Check if the has is greater than CLAVIS_ASCII_KID_MAX. */ +if (*desc) + goto invalid; + +/* Check for even number of hex characters. */ +if (i ==0 || i &1 )
FWIW< the i == 0 is impossible due to the desc_len < 7 check above (well, once strlen is used…).
Thanks,
--Ben
Eric Snowberg
reviewerRe: [RFC PATCH v3 05/13] clavis: Introduce a new key type called clavis_key_acl
Quoted 23 lines · Ben Boeckel
Quoted 9 lines · Eric Snowberg
Introduce a new key type for keyring access control. The new key type is called
clavis_key_acl. Theclavis_key_aclcontains the subject key identifier along with the allowed usage type for the key.The format is as follows:
XX:YYYYYYYYYYY
XX - Single byte of the key type
Quoted 8 lines
VERIFYING_MODULE_SIGNATURE 00 VERIFYING_FIRMWARE_SIGNATURE 01 VERIFYING_KEXEC_PE_SIGNATURE 02 VERIFYING_KEY_SIGNATURE 03 VERIFYING_KEY_SELF_SIGNATURE 04 VERIFYING_UNSPECIFIED_SIGNATURE 05: - ASCII colon
YY - Even number of hexadecimal characters representing the key id
Quoted 4 lines
This is expected to be *lowercase* hexadecimal characters in the code; can that restriction please be documented? (Coming back here, there is a
tolowerpass performed when copying from userspace, so this seems to be an internal requirement, not userspace.
Correct
Quoted 5 lines
Might be worth documenting
somewhere in case the kernel wants to make such a key internally.)I also see a 32-byte (64 hex characters) limit in the code; that should also be documented somewhere.
I didn't want to burden the end-user with getting everything in lowercase, since OpenSSL typically returns the result in uppercase. I will add some comments as you suggested incase the kernel wants to make such a key internally.
Quoted 23 lines
Quoted 23 lines
This key type will be used in the clavis keyring for access control. To be added to the clavis keyring, the
clavis_key_aclmust be S/MIME signed by the sole asymmetric key contained within it.Below is an example of how this could be used. Within the example, the key (
b360d113c848ace3f1e6a80060b43d1206f0487d) is already in the machine keyring. The intended usage for this key is to validate a signed kernel for kexec:echo "02:b360d113c848ace3f1e6a80060b43d1206f0487d" > kernel-acl.txt
The next step is to sign it:
openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in \
kernel-acl.txt -out kernel-acl.pkcs7 -binary -outform DER \
-nodetach -noattrThe final step is how to add the acl to the .clavis keyring:
keyctl padd
clavis_key_acl"" %:.clavis < kernel-acl.pkcs7Afterwards the new
clavis_key_aclcan be seen in the .clavis keyring:
Quoted 8 lines
Quoted 5 lines
keyctl show %:.clavis
Keyring
keyring: .clavis
\_ asymmetric: Clavis LSM key:4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8\_clavis_key_acl: 02:b360d113c848ace3f1e6a80060b43d1206f0487dCan this be committed to
Documentation/and not just the Git history please?
This is documented, but it doesn't come in until the 8th patch in the series. Hopefully that is not an issue.
Quoted 52 lines
Code comments inline below.
Quoted 50 lines
Signed-off-by Eric Snowberg <[email protected]>---
security/clavis/clavis.h| 1 +security/clavis/clavis_keyring.c| 173 +++++++++++++++++++++++++++++++2 files changed, 174 insertions(+)security/clavis/clavis.h +1
-0@@ -5,6 +5,7 @@/* Max length for the asymmetric key id contained on the boot param */ #define CLAVIS_BIN_KID_MAX 32 +#define CLAVIS_ASCII_KID_MAX 64struct asymmetric_setup_kid {struct asymmetric_key_id id;security/clavis/clavis_keyring.c +15
-0@@ -2,8 +2,12 @@#include <linux/security.h> #include <linux/integrity.h> +#include <linux/ctype.h> #include <keys/asymmetric-type.h> +#include <keys/asymmetric-subtype.h> #include <keys/system_keyring.h> +#include <keys/user-type.h> +#include <crypto/pkcs7.h> #include "clavis.h" static struct key *clavis_keyring;@@ -11,10 +15,173 @@ static struct asymmetric_key_id *clavis_boot_akid;static struct asymmetric_setup_kid clavis_setup_akid;static bool clavis_enforced; +static int pkcs7_preparse_content (void *ctx,const void *data,size_t len,size_t asn1hdrlen) +{ +struct key_preparsed_payload *prep = ctx; +const void *saved_prep_data; +size_t saved_prep_datalen; +char *desc; +int ret, i; + +/* key_acl_free_preparse will free this */ + desc =kmemdup (data, len,GFP_KERNEL ); +if (!desc)
Quoted 8 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 33
Quoted 5 lines
security/clavis/clavis_keyring.c +5
-0+return -ENOMEM ; + +/* Copy the user supplied contents and remove any white space. */ +for (i =0 ; i < len; i++) { + desc[i] =tolower (desc[i]);Ah, looking here it seems that userspace can provide upper or lowercase. THat this is being performed should be added to the comment here.
I'll update the comment.
Quoted 11 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 35
Quoted 3 lines
security/clavis/clavis_keyring.c +2
-0+if (isspace (desc[i])) + desc[i] =0 ;How is setting a space to
0*removing* it? Surely theisxdigitcheck internally is going to reject this. Perhaps you meant to have two indices intodesc, one read and one write and to stall the write index as long as we're reading whitespace?Also, that whitespace is stripped is a userspace-relevant detail that should be documented.
This was done incase the end-user has a trailing carriage return at the end of their ACL. I have updated the comment as follows:
+ /*
+ * Copy the user supplied contents, if uppercase is used, convert it to + * lowercase. Also if the end of the ACL contains any whitespace, strip + * it out. + */
Quoted 16 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 108
Quoted 12 lines
security/clavis/clavis_keyring.c +11
-0+static void key_acl_destroy (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("destroy clavis_key_acl denied\n" ); +} + +static void key_acl_revoke (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("revoke clavis_key_acl denied\n" ); +}These keys cannot be destroyed or revoked? This seems…novel to me. What if there's a timeout on the key? If such keys are immortal, timeouts should also be refused?
All the system kernel keyrings work this way. But now that you bring this up, neither of these functions are really necessary, so I will remove them in the next round.
Quoted 11 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 123
Quoted 9 lines
security/clavis/clavis_keyring.c +9
-0+static int key_acl_vet_description (const char *desc) +{ +int i, desc_len; +s16 ktype; + +if (!desc) + goto invalid; + + desc_len =sizeof (desc);This should be
strlen, no?
I will change this to strlen
Quoted 34 lines
Quoted 34 lines
security/clavis/clavis_keyring.c +34
-0+/* +* clavis_acl format: +* xx:yyyy... +* +* xx - Single byte of the key type +* : - Ascii colon +* yyyy.. - Even number of hexadecimal characters representing the keyid +*/ + +/* The min clavis acl is 7 characters. */ +if (desc_len <7 ) + goto invalid; + +/* Check the first byte is a valid key type. */ +if (sscanf (desc,"%2hx" , &ktype) !=1 ) + goto invalid; + +if (ktype >=VERIFYING_CLAVIS_SIGNATURE ) + goto invalid; + +/* Check that there is a colon following the key type */ +if (desc[2 ] !=':' ) + goto invalid; + +/* Move past the colon. */ + desc +=3 ; + +for (i =0 ; *desc && i <CLAVIS_ASCII_KID_MAX ; desc++, i++) { +/* Check if lowercase hex number */ +if (!isxdigit (*desc) ||isupper (*desc)) + goto invalid; + } + +/* Check if the has is greater than CLAVIS_ASCII_KID_MAX. */
Quoted 8 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 163
Quoted 5 lines
security/clavis/clavis_keyring.c +5
-0+if (*desc) + goto invalid; + +/* Check for even number of hex characters. */ +if (i ==0 || i &1 )FWIW< the
i == 0is impossible due to thedesc_len < 7check above (well, oncestrlenis used…).
and remove the unnecessary check. Thanks for your review.
Re: [RFC PATCH v3 05/13] clavis: Introduce a new key type called clavis_key_acl
Quoted 6 lines · Eric Snowberg
Quoted 3 lines · Ben Boeckel
Can this be committed to
Documentation/and not just the Git history please?This is documented, but it doesn't come in until the 8th patch in the series. Hopefully that is not an issue.
Ah, I'll look there, thanks.
Quoted 14 lines
Quoted 10 lines
Quoted 2 lines
+ if (
isspace(desc[i]))
+ desc[i] = 0;How is setting a space to
0*removing* it? Surely theisxdigitcheck internally is going to reject this. Perhaps you meant to have two indices intodesc, one read and one write and to stall the write index as long as we're reading whitespace?Also, that whitespace is stripped is a userspace-relevant detail that should be documented.
This was done incase the end-user has a trailing carriage return at the end of their ACL. I have updated the comment as follows:
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* + * Copy the user supplied contents, if uppercase is used, convert it to + * lowercase. Also if the end of the ACL contains any whitespace, strip + * it out. + */
Well, this doesn't check the end for whitespace; any internal whitespace will terminate the key:
DEAD BEEF
^ becomes NUL
and results in the same thing as DEAD being passed.
Quoted 32 lines
Quoted 16 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 108
Quoted 12 lines
security/clavis/clavis_keyring.c +11
-0+static void key_acl_destroy (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("destroy clavis_key_acl denied\n" ); +} + +static void key_acl_revoke (struct key *key) +{ +/* It should not be possible to get here */ +pr_info ("revoke clavis_key_acl denied\n" ); +}These keys cannot be destroyed or revoked? This seems…novel to me. What if there's a timeout on the key? If such keys are immortal, timeouts should also be refused?
All the system kernel keyrings work this way. But now that you bring this up, neither of these functions are really necessary, so I will remove them in the next round.
Quoted 11 lines
security/clavis/clavis_keyring.c static struct asymmetric_key_id *clavis_boot_akid; · line 123
Quoted 9 lines
security/clavis/clavis_keyring.c +9
-0+static int key_acl_vet_description (const char *desc) +{ +int i, desc_len; +s16 ktype; + +if (!desc) + goto invalid; + + desc_len =sizeof (desc);This should be
strlen, no?
Quoted 1 line
I will change this to strlen
Actually, this could probably be strnlen using CLAVIS_ASCII_KID_MAX + 1 just to avoid running off into la-la land when we're going to error anyways. Or even 8 because we only actually care about "is at least 7 bytes". Worth a comment either way.
Looking forward to the next cycle.
Thanks,
--Ben
Eric Snowberg
reviewerRe: [RFC PATCH v3 05/13] clavis: Introduce a new key type called clavis_key_acl
Quoted 14 lines · Ben Boeckel
Review
Quoted 9 lines · Eric Snowberg
This was done incase the end-user has a trailing carriage return at the end of their ACL. I have updated the comment as follows:
(quoted diff) +5
-0+ /* + * Copy the user supplied contents, if uppercase is used, convert it to + * lowercase. Also if the end of the ACL contains any whitespace, strip + * it out. + */
Quoted 7 lines
Well, this doesn't check the end for whitespace; any internal whitespace will terminate the key:
DEAD BEEF
^ becomes NULand results in the same thing as
DEADbeing passed.
Originally I was thinking I could extract and fix up the data in pkcs7_preparse_content, later when key_acl_vet_description gets called do the validation. But I see your point that it is possible there could be a valid ACL, followed by a space and some other data, which should trigger an invalid response. I'll take care of this in the next round too. I'll also add a Kunit test for this one. Thanks.
Eric Snowberg
reviewerRFC PATCH v3 6/13 clavis: Populate clavis keyring acl with kernel module signature
In reply to Eric SnowbergIf the kernel is built with CONFIG_MODULE_SIG_KEY, get the subject key identifier and add an ACL for it within the .clavis keyring.
--- certs/.gitignore | 1 + certs/Makefile | 20 ++++++++++++++++++++ certs/clavis_module_acl.c | 7 +++++++ security/clavis/clavis.h | 9 +++++++++ security/clavis/clavis_keyring.c | 27 +++++++++++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 certs/clavis_module_acl.c
certs/.gitignore +1 -0
@@ -3,3 +3,4 @@ /extract-cert /x509_certificate_list /x509_revocation_list +/module_acl
certs/Makefile +20 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o blacklist_hashes.o obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_module_acl.o $(obj)/blacklist_hashes.o: $(obj)/blacklist_hash_list CFLAGS_blacklist_hashes.o := -I $(obj)
@@ -75,6 +76,25 @@ $(obj)/signing_key.x509: $(filter-out $(PKCS11_URI),$(CONFIG_MODULE_SIG_KEY)) $( targets += signing_key.x509 +ifeq ($(CONFIG_MODULE_SIG_KEY),) +quiet_cmd_make_module_acl = GEN $@ + cmd_make_module_acl = \ + echo > $@ +else +quiet_cmd_make_module_acl = GEN $@ + cmd_make_module_acl = \ + openssl x509 -in $< -inform der -ext subjectKeyIdentifier -nocert | \ + tail -n +2 | cut -f2 -d '='| tr -d ':' | tr '[:upper:]' '[:lower:]' | \ + sed 's/^[ \t]*//; s/.*/"00:&",/' > $@ +endif + +$(obj)/module_acl: $(obj)/signing_key.x509 FORCE + $(call if_changed,make_module_acl) + +$(obj)/clavis_module_acl.o: $(obj)/module_acl + +targets += module_acl + $(obj)/revocation_certificates.o: $(obj)/x509_revocation_list $(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCE
certs/clavis_module_acl.c new file +7 -0
@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/kernel.h> + +const char __initconst *const clavis_module_acl[] = { +#include "module_acl" +NULL +};
security/clavis/clavis.h +9 -0
@@ -11,4 +11,13 @@ struct asymmetric_setup_kid {struct asymmetric_key_id id; unsigned char data[CLAVIS_BIN_KID_MAX]; }; + +#ifndef CONFIG_SYSTEM_TRUSTED_KEYRING +const char __initconst *const clavis_module_acl[] = { +NULL +}; +#else +extern const char __initconst *const clavis_module_acl[]; +#endif +#endif /* _SECURITY_CLAVIS_H_ */
security/clavis/clavis_keyring.c +27 -0
@@ -259,6 +259,31 @@ static struct key_restriction *clavis_restriction_alloc(key_restrict_link_func_treturn restriction; } +static void clavis_add_acl (const char *const *skid_list,struct key *keyring) +{ +const char *const *acl; +key_ref_t key; + +for (acl = skid_list; *acl; acl++) { + key =key_create (make_key_ref (keyring, true), +"clavis_key_acl" , + *acl, +NULL , +0 , +KEY_POS_SEARCH |KEY_POS_VIEW |KEY_USR_SEARCH |KEY_USR_VIEW , +KEY_ALLOC_NOT_IN_QUOTA |KEY_ALLOC_BUILT_IN | +KEY_ALLOC_BYPASS_RESTRICTION ); +if (IS_ERR (key)) { +if (PTR_ERR (key) == -EEXIST ) +pr_info ("Duplicate clavis_key_acl %s\n" , *acl); +else +pr_info ("Problem with clavis_key_acl %s: %pe\n" , *acl, key); + }else { +pr_info ("Added clavis_key_acl %s\n" , *acl); + } + } +} +static int __init clavis_keyring_init (void ) {struct key_restriction *restriction;
@@ -274,6 +299,8 @@ static int __init clavis_keyring_init(void)if (IS_ERR (clavis_keyring))panic ("Can't allocate clavis keyring\n" ); +clavis_add_acl (clavis_module_acl, clavis_keyring); +return 0 ; }
Signature · 1 line
2.45.0
Jarkko Sakkinen
maintainerRe: [RFC PATCH v3 06/13] clavis: Populate clavis keyring acl with kernel module signature
Quoted 4 lines · Eric Snowberg
If the kernel is built with
CONFIG_MODULE_SIG_KEY, get the subject key identifier and add an ACL for it within the .clavis keyring.Signed-off-by Eric Snowberg <[email protected]>
Super sound splits! Nice to review, have to give credit on this :-)
Quoted 142 lines
---
certs/.gitignore | 1 +
certs/Makefile | 20 ++++++++++++++++++++ certs/clavis_module_acl.c | 7 +++++++ security/clavis/clavis.h | 9 +++++++++security/clavis/clavis_keyring.c| 27 +++++++++++++++++++++++++++5 files changed, 64 insertions(+)create mode 100644
certs/clavis_module_acl.ccerts/.gitignore +0
-0@@ -3,3 +3,4 @@/extract-cert
/x509_certificate_list
/x509_revocation_listcerts/.gitignore +1
-0+/module_aclcerts/Makefile +0
-0@@ -6,6 +6,7 @@obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o blacklist_hashes.o
obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_module_acl.o
$(obj)/blacklist_hashes.o: $(obj)/blacklist_hash_list CFLAGS_blacklist_hashes.o := -I $(obj)certs/Makefile +0
-0@@ -75,6 +76,25 @@ $(obj)/signing_key.x509: $(filter-out$(PKCS11_URI),$(CONFIG_MODULE_SIG_KEY)) $(
targets += signing_key.x509certs/Makefile +8
-0+ifeq ($(CONFIG_MODULE_SIG_KEY),) +quiet_cmd_make_module_acl = GEN $@ + cmd_make_module_acl = \ + echo > $@ +else +quiet_cmd_make_module_acl = GEN $@ + cmd_make_module_acl = \ + openssl x509 -in $< -inform der -ext subjectKeyIdentifier -nocert | \
certs/Makefile +1
-0+ tail -n +2 | cut -f2 -d '='| tr -d ':' | tr '[:upper:]''[:lower:]' | \
certs/Makefile +10
-0+ sed 's/^[ \t]*//; s/.*/"00:&",/' > $@ +endif + +$(obj)/module_acl: $(obj)/signing_key.x509 FORCE + $(call if_changed,make_module_acl) + +$(obj)/clavis_module_acl.o: $(obj)/module_acl + +targets += module_acl +$(obj)/revocation_certificates.o: $(obj)/x509_revocation_list
$(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCEcerts/clavis_module_acl.c new file +7
-0@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/kernel.h> + +const char __initconst *const clavis_module_acl[] = { +#include "module_acl" +NULL +};security/clavis/clavis.h +9
-0@@ -11,4 +11,13 @@ struct asymmetric_setup_kid { struct asymmetric_key_id id; unsigned char data[CLAVIS_BIN_KID_MAX]; }; + +#ifndef CONFIG_SYSTEM_TRUSTED_KEYRING +const char __initconst *const clavis_module_acl[] = { +NULL +}; +#else +extern const char __initconst *const clavis_module_acl[]; +#endif + #endif /* _SECURITY_CLAVIS_H_ */security/clavis/clavis_keyring.c +0
-0@@ -259,6 +259,31 @@ static struct key_restriction *clavis_restriction_alloc(key_restrict_link_func_t return restriction; }
+static voidclavis_add_acl(const char *const *skid_list, struct key *keyring)security/clavis/clavis_keyring.c +11
-0+{ +const char *const *acl; +key_ref_t key; + +for (acl = skid_list; *acl; acl++) { + key = key_create(make_key_ref(keyring, true), + "clavis_key_acl", + *acl, + NULL, + 0, + KEY_POS_SEARCH | KEY_POS_VIEW |
KEY_USR_SEARCH|KEY_USR_VIEW,security/clavis/clavis_keyring.c +1
-0+ KEY_ALLOC_NOT_IN_QUOTA |
KEY_ALLOC_BUILT_IN|security/clavis/clavis_keyring.c +4
-0+ KEY_ALLOC_BYPASS_RESTRICTION); +if (IS_ERR (key)) { +if (PTR_ERR (key) == -EEXIST ) + pr_info("Duplicate clavis_key_acl%s\n", *acl);
security/clavis/clavis_keyring.c +2
-0+else + pr_info("Problem with clavis_key_acl%s: %pe\n", *acl, key);
security/clavis/clavis_keyring.c +6
-0+ }else { +pr_info ("Added clavis_key_acl %s\n" , *acl); + } + } +} +static int
__initclavis_keyring_init(void)
{
structkey_restriction*restriction;security/clavis/clavis_keyring.c +0
-0@@ -274,6 +299,8 @@ static int __init clavis_keyring_init(void) if (IS_ERR(clavis_keyring)) panic("Can't allocate clavis keyring\n");security/clavis/clavis_keyring.c +2
-0+clavis_add_acl (clavis_module_acl, clavis_keyring); +
Quoted 3 lines
return 0;
}
Not yet tagging, but neither anything to complain. LGTM
BR, Jarkko
Eric Snowberg
reviewerRFC PATCH v3 7/13 keys: Add ability to track intended usage of the public key
In reply to Eric SnowbergAdd two new fields in public_key_signature to track the intended usage of the signature. Also add a flag for the revocation pass. During signature validation, two verifications can take place for the same signature. One to see if it verifies against something on the .blacklist keyring and the other to see if it verifies against the supplied keyring. The flag is used to determine which stage the verification is in.
--- certs/blacklist.c | 3 +++ crypto/asymmetric_keys/pkcs7_trust.c | 20 ++++++++++++++++++++ crypto/asymmetric_keys/pkcs7_verify.c | 4 ++++ include/crypto/pkcs7.h | 3 +++ include/crypto/public_key.h | 4 ++++ 5 files changed, 34 insertions(+)
certs/blacklist.c +3 -0
@@ -17,6 +17,7 @@#include <linux/uidgid.h> #include <keys/asymmetric-type.h> #include <keys/system_keyring.h> +#include <crypto/public_key.h> #include "blacklist.h" /*
@@ -289,7 +290,9 @@ int is_key_on_revocation_list(struct pkcs7_message *pkcs7) {int ret; +pkcs7_set_usage_flag (pkcs7,PKS_REVOCATION_PASS ); ret =pkcs7_validate_trust (pkcs7, blacklist_keyring); +pkcs7_clear_usage_flag (pkcs7,PKS_REVOCATION_PASS );if (ret ==0 )return -EKEYREJECTED ;
crypto/asymmetric_keys/pkcs7_trust.c +20 -0
@@ -131,6 +131,26 @@ static int pkcs7_validate_trust_one(struct pkcs7_message *pkcs7,return 0 ; } +void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +clear_bit (usage, &sinfo->sig->usage_flags); + } +} + +void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +set_bit (usage, &sinfo->sig->usage_flags); + } +} +/** * pkcs7_validate_trust - Validate PKCS#7 trust chain * @pkcs7: The PKCS#7 certificate to validate
crypto/asymmetric_keys/pkcs7_verify.c +4 -0
@@ -455,6 +455,10 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,return ret; } actual_ret =0 ; +if (sinfo->sig) { + sinfo->sig->usage = usage; +set_bit (PKS_USAGE_SET , &sinfo->sig->usage_flags); + } }kleave (" = %d" , actual_ret);
include/crypto/pkcs7.h +3 -0
@@ -32,6 +32,9 @@ extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,extern int pkcs7_validate_trust (struct pkcs7_message *pkcs7,struct key *trust_keyring); +extern void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +extern void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +/* * pkcs7_verify.c */
include/crypto/public_key.h +4 -0
@@ -49,6 +49,10 @@ struct public_key_signature {const char *pkey_algo;const char *hash_algo;const char *encoding; +u32 usage;/* Intended usage */ +unsigned long usage_flags; +#define PKS_USAGE_SET 0 +#define PKS_REVOCATION_PASS 1 };extern void public_key_signature_free (struct public_key_signature *sig);
Signature · 1 line
2.45.0
Re: [RFC PATCH v3 07/13] keys: Add ability to track intended usage of the public key
Quoted 8 lines · Eric Snowberg
Add two new fields in
public_key_signatureto track the intended usage of the signature. Also add a flag for the revocation pass. During signature validation, two verifications can take place for the same signature. One to see if it verifies against something on the .blacklist keyring and the other to see if it verifies against the supplied keyring. The flag is used to determine which stage the verification is in.Signed-off-by Eric Snowberg <[email protected]>
Mimi, was this the patch set you asked to look at while ago?</offtopic>
This patch adds PKS_REVOCATION_PASS and REVOCATION_SET. It would be nice to put in simple terms how they are used in down to eart terms.
Quoted 95 lines
--- certs/blacklist.c | 3 +++ crypto/asymmetric_keys/pkcs7_trust.c | 20 ++++++++++++++++++++ crypto/asymmetric_keys/pkcs7_verify.c | 4 ++++ include/crypto/pkcs7.h | 3 +++ include/crypto/public_key.h | 4 ++++ 5 files changed, 34 insertions(+)certs/blacklist.c +3
-0@@ -17,6 +17,7 @@#include <linux/uidgid.h> #include <keys/asymmetric-type.h> #include <keys/system_keyring.h> +#include <crypto/public_key.h> #include "blacklist.h" /* @@ -289,7 +290,9 @@ int is_key_on_revocation_list(struct pkcs7_message *pkcs7) {int ret; +pkcs7_set_usage_flag (pkcs7,PKS_REVOCATION_PASS ); ret =pkcs7_validate_trust (pkcs7, blacklist_keyring); +pkcs7_clear_usage_flag (pkcs7,PKS_REVOCATION_PASS );if (ret ==0 )return -EKEYREJECTED ;crypto/asymmetric_keys/pkcs7_trust.c +20
-0@@ -131,6 +131,26 @@ static int pkcs7_validate_trust_one(struct pkcs7_message *pkcs7,return 0 ; } +void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +clear_bit (usage, &sinfo->sig->usage_flags); + } +} + +void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +set_bit (usage, &sinfo->sig->usage_flags); + } +} +/** * pkcs7_validate_trust - Validate PKCS#7 trust chain * @pkcs7: The PKCS#7 certificate to validate crypto/asymmetric_keys/pkcs7_verify.c +4
-0@@ -455,6 +455,10 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,return ret; } actual_ret =0 ; +if (sinfo->sig) { + sinfo->sig->usage = usage; +set_bit (PKS_USAGE_SET , &sinfo->sig->usage_flags); + } }kleave (" = %d" , actual_ret);include/crypto/pkcs7.h +3
-0@@ -32,6 +32,9 @@ extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,extern int pkcs7_validate_trust (struct pkcs7_message *pkcs7,struct key *trust_keyring); +extern void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +extern void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +/* * pkcs7_verify.c */ include/crypto/public_key.h +0
-0
include/crypto/public_key.h struct public_key_signature { · line 52
Quoted 4 lines
include/crypto/public_key.h +1
-0@@ -49,6 +49,10 @@ struct public_key_signature {const char *pkey_algo;const char *hash_algo;const char *encoding; +u32 usage;/* Intended usage */
I'd would not size encode this but instead use "unsigned int".
include/crypto/public_key.h struct public_key_signature { · line 53
Quoted 1 line
include/crypto/public_key.h +1
-0+unsigned long usage_flags;
It would be less convoluting if this was just "flags". Now this leaves to wonder what it is encoded for. E.g. for ioctl API one doees it for the API to be size agnostic between 32/64-bit kernels.
include/crypto/public_key.h struct public_key_signature { · line 56
Quoted 3 lines
include/crypto/public_key.h +2
-0+#define PKS_USAGE_SET 0 +#define PKS_REVOCATION_PASS 1 };
I'd add these before the struct and:
/* ... */
#define PKS_USAGE_SET 0
/* ... */
#define PKS_REVOCATION_PASS 1
Quoted 5 lines
include/crypto/public_key.h +0
-0extern void public_key_signature_free (struct public_key_signature *sig);Signature · 1 line
2.45.0
BR, Jarkko
Eric Snowberg
reviewerRe: [RFC PATCH v3 07/13] keys: Add ability to track intended usage of the public key
Quoted 12 lines · Jarkko Sakkinen
Quoted 7 lines · Eric Snowberg
Add two new fields in
public_key_signatureto track the intended usage of the signature. Also add a flag for the revocation pass. During signature validation, two verifications can take place for the same signature. One to see if it verifies against something on the .blacklist keyring and the other to see if it verifies against the supplied keyring. The flag is used to determine which stage the verification is in.
Quoted 6 lines
Quoted 1 line
Signed-off-by Eric Snowberg <[email protected]>Mimi, was this the patch set you asked to look at while ago?</offtopic>
This patch adds
PKS_REVOCATION_PASSandREVOCATION_SET. It would be nice to put in simple terms how they are used in down to eart terms.
Ok, I'll add more details explaining them better in the next round.
Quoted 93 lines
Quoted 93 lines
---
certs/blacklist.c | 3 +++ crypto/asymmetric_keys/pkcs7_trust.c | 20 ++++++++++++++++++++ crypto/asymmetric_keys/pkcs7_verify.c | 4 ++++ include/crypto/pkcs7.h | 3 +++ include/crypto/public_key.h | 4 ++++ 5 files changed, 34 insertions(+)certs/blacklist.c +3
-0@@ -17,6 +17,7 @@#include <linux/uidgid.h> #include <keys/asymmetric-type.h> #include <keys/system_keyring.h> +#include <crypto/public_key.h> #include "blacklist.h" /* @@ -289,7 +290,9 @@ int is_key_on_revocation_list(struct pkcs7_message *pkcs7) {int ret; +pkcs7_set_usage_flag (pkcs7,PKS_REVOCATION_PASS ); ret =pkcs7_validate_trust (pkcs7, blacklist_keyring); +pkcs7_clear_usage_flag (pkcs7,PKS_REVOCATION_PASS );if (ret ==0 )return -EKEYREJECTED ;crypto/asymmetric_keys/pkcs7_trust.c +20
-0@@ -131,6 +131,26 @@ static int pkcs7_validate_trust_one(struct pkcs7_message *pkcs7,return 0 ; } +void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +clear_bit (usage, &sinfo->sig->usage_flags); + } +} + +void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage) +{ +struct pkcs7_signed_info *sinfo; + +for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { +if (sinfo->sig) +set_bit (usage, &sinfo->sig->usage_flags); + } +} +/** * pkcs7_validate_trust - Validate PKCS#7 trust chain * @pkcs7: The PKCS#7 certificate to validate crypto/asymmetric_keys/pkcs7_verify.c +4
-0@@ -455,6 +455,10 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,return ret; } actual_ret =0 ; +if (sinfo->sig) { + sinfo->sig->usage = usage; +set_bit (PKS_USAGE_SET , &sinfo->sig->usage_flags); + } }kleave (" = %d" , actual_ret);include/crypto/pkcs7.h +3
-0@@ -32,6 +32,9 @@ extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,extern int pkcs7_validate_trust (struct pkcs7_message *pkcs7,struct key *trust_keyring); +extern void pkcs7_set_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +extern void pkcs7_clear_usage_flag (struct pkcs7_message *pkcs7,unsigned long usage); +/* * pkcs7_verify.c */ include/crypto/public_key.h +0
-1--- a/include/crypto/public_key.h
Quoted 8 lines
include/crypto/public_key.h struct public_key_signature { · line 52
Quoted 6 lines
+++
b/include/crypto/public_key.hinclude/crypto/public_key.h +1
-0@@ -49,6 +49,10 @@ struct public_key_signature {const char *pkey_algo;const char *hash_algo;const char *encoding; +u32 usage;/* Intended usage */ I'd would not size encode this but instead use "unsigned int".
I'll change that
Quoted 6 lines
include/crypto/public_key.h struct public_key_signature { · line 53
Quoted 2 lines
include/crypto/public_key.h +1
-0+unsigned long usage_flags;It would be less convoluting if this was just "flags". Now this leaves to wonder what it is encoded for. E.g. for ioctl API one doees it for the API to be size agnostic between 32/64-bit kernels.
and change usage_flags to just "flags"
Quoted 7 lines
include/crypto/public_key.h struct public_key_signature { · line 56
Quoted 4 lines
include/crypto/public_key.h +2
-0+#define PKS_USAGE_SET 0 +#define PKS_REVOCATION_PASS 1 };I'd add these before the struct and:
Quoted 5 lines
/* ... */
#definePKS_USAGE_SET0/* ... */
#definePKS_REVOCATION_PASS1
I was following the same pattern done elsewhere in the crypto code, but I can move them before the structure.
Quoted 7 lines
Quoted 5 lines
include/crypto/public_key.h +0
-0extern void public_key_signature_free (struct public_key_signature *sig);Signature · 1 line
2.45.0BR, Jarkko
Thanks for your review.
Mimi Zohar
maintainerRe: [RFC PATCH v3 07/13] keys: Add ability to track intended usage of the public key
In reply to Jarkko SakkinenQuoted 11 lines · Jarkko Sakkinen
Quoted 8 lines · Eric Snowberg
Add two new fields in
public_key_signatureto track the intended usage of the signature. Also add a flag for the revocation pass. During signature validation, two verifications can take place for the same signature. One to see if it verifies against something on the .blacklist keyring and the other to see if it verifies against the supplied keyring. The flag is used to determine which stage the verification is in.Signed-off-by Eric Snowberg <[email protected]>Mimi, was this the patch set you asked to look at while ago?</offtopic>
Yes, in particular please take a look at Paul's comment on 00/13.
Mimi
Eric Snowberg
reviewerRFC PATCH v3 8/13 clavis: Introduce new LSM called clavis
In reply to Eric SnowbergIntroduce a new LSM called clavis. The motivation behind this LSM is to provide access control for system keys. The access control list is contained within a keyring call .clavis. During boot if the clavis= boot arg is supplied with a key id contained within any of the current system keyrings (builtin, secondary, machine, or platform) it shall be used as the root of trust for validating anything that is added to the ACL list.
The first restriction introduced with this LSM is the ability to enforce key usage. The kernel already has a notion of tracking key usage. This LSM adds the ability to enforce this usage based on the system owners configuration.
Each system key may have one or more uses defined within the ACL list. Until an entry is added to the .clavis keyring, no other system key may be used for any other purpose.
--- Documentation/admin-guide/LSM/clavis.rst | 191 ++++++++++++++++++ MAINTAINERS | 7 + crypto/asymmetric_keys/signature.c | 4 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 10 +- security/clavis/Makefile | 1 + security/clavis/clavis.c | 26 +++ security/clavis/clavis.h | 4 + security/clavis/clavis_keyring.c | 78 ++++++- security/security.c | 13 ++ .../selftests/lsm/lsm_list_modules_test.c | 3 + 14 files changed, 346 insertions(+), 9 deletions(-) create mode 100644 Documentation/admin-guide/LSM/clavis.rst create mode 100644 security/clavis/clavis.c
Documentation/admin-guide/LSM/clavis.rst new file +191 -0
@@ -0,0 +1,191 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Clavis +====== + +Clavis is a Linux Security Module that provides mandatory access control to +system kernel keys (i.e. builtin, secondary, machine and platform). These +restrictions will prohibit keys from being used for validation. Upon boot, the +Clavis LSM is provided a key id as a boot parameter. This single key is then +used as the root of trust for any access control modifications made going +forward. Access control updates must be signed and validated by this key. + +Clavis has its own keyring. All ACL updates are applied through this keyring. +The update must be signed by the single root of trust key. + +When enabled, all system keys are prohibited from being used until an ACL is +added for them. + +On UEFI platforms, the root of trust key shall survive a kexec. Trying to +defeat or change it from the command line is not allowed. The original boot +parameter is stored in UEFI and will always be referenced following a kexec. + +The Clavis LSM contains a system keyring call .clavis. It contains a single +asymmetric key that is used to validate anything added to it. This key can +be added during boot and must be a preexisting system kernel key. If the +``clavis=`` boot parameter is not used, any asymmetric key the user owns +can be added to enable the LSM. + +The only user space components are OpenSSL and the keyctl utility. A new +key type call ``clavis_key_acl`` is used for ACL updates. Any number of signed +``clavis_key_acl`` entries may be added to the .clavis keyring. The +``clavis_key_acl`` contains the subject key identifier along with the allowed +usage type for the key. + +The format is as follows: + +.. code-block:: console + + XX:YYYYYYYYYYY + + XX - Single byte of the key type + VERIFYING_MODULE_SIGNATURE 00 + VERIFYING_FIRMWARE_SIGNATURE 01 + VERIFYING_KEXEC_PE_SIGNATURE 02 + VERIFYING_KEY_SIGNATURE 03 + VERIFYING_KEY_SELF_SIGNATURE 04 + VERIFYING_UNSPECIFIED_SIGNATURE 05 + : - ASCII colon + YY - Even number of hexadecimal characters representing the key id + +The ``clavis_key_acl`` must be S/MIME signed by the sole asymmetric key contained +within the .clavis keyring. + +In the future if new features are added, new key types could be created. + +Usage Examples +============== + +How to create a signing key: +---------------------------- + +.. code-block:: bash + + cat <<EOF > clavis-lsm.genkey + [ req ] + default_bits = 4096 + distinguished_name = req_distinguished_name + prompt = no + string_mask = utf8only + x509_extensions = v3_ca + [ req_distinguished_name ] + O = TEST + CN = Clavis LSM key + emailAddress = [email protected] + [ v3_ca ] + basicConstraints=CA:TRUE + subjectKeyIdentifier=hash + authorityKeyIdentifier=keyid:always,issuer + keyUsage=digitalSignature + EOF + + openssl req -new -x509 -utf8 -sha256 -days 3650 -batch \ + -config clavis-lsm.genkey -outform DER \ + -out clavis-lsm.x509 -keyout clavis-lsm.priv + +How to get the Subject Key Identifier +------------------------------------- + +.. code-block:: bash + + openssl x509 -in ./clavis-lsm.x509 -inform der \ + -ext subjectKeyIdentifier -nocert \ + | tail -n +2 | cut -f2 -d '='| tr -d ':' + 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +How to enroll the signing key into the MOK +------------------------------------------ + +The key must now be added to the machine or platform keyrings. This +indicates the key was added by the system owner. For kernels booted through +shim, a first-stage UEFI boot loader, a key may be added to the machine keyring +by doing: + +.. code-block:: bash + + mokutil --import ./clavis-lsm.x509 + +and then rebooting and enrolling the key through MokManager. + +How to enable the Clavis LSM +---------------------------- + +Add the key id to the ``clavis=`` boot parameter. With the example above the +key id is the subject key identifier: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +Add the following boot parameter: + +.. code-block:: console + + clavis=4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +After booting there will be a single key contained in the .clavis keyring: + +.. code-block:: bash + + keyctl show %:.clavis + Keyring + 254954913 ----swrv 0 0 keyring: .clavis + 301905375 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +The original ``clavis=`` boot parameter will persist across any kexec. Changing it or +removing it has no effect. + + +How to sign an entry to be added to the .clavis keyring: +-------------------------------------------------------- + +In this example we have 3 keys in the machine keyring. Our Clavis LSM key, a +key we want to use for kernel verification and a key we want to use for module +verification. + +.. code-block:: bash + + keyctl show %:.machine + Keyring + 999488265 ---lswrv 0 0 keyring: .machine + 912608009 ---lswrv 0 0 \_ asymmetric: TEST: Module Key: 17eb8c5bf766364be094c577625213700add9471 + 646229664 ---lswrv 0 0 \_ asymmetric: TEST: Kernel Key: b360d113c848ace3f1e6a80060b43d1206f0487d + 1073737099 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +To update the .clavis kerying ACL list, first create a file containing the +key usage type followed by a colon and the key id that we want to allow to +validate that usage. In the first example we are saying key +17eb8c5bf766364be094c577625213700add9471 is allowed to validate kernel modules. +In the second example we are saying key b360d113c848ace3f1e6a80060b43d1206f0487d +is allowed to validate signed kernels. + +.. code-block:: bash + + echo "00:17eb8c5bf766364be094c577625213700add9471" > module-acl.txt + echo "02:b360d113c848ace3f1e6a80060b43d1206f0487d" > kernel-acl.txt + +Now both these files must be signed by the key contained in the .clavis keyring: + +.. code-block:: bash + + openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in module-acl.txt \ + -out module-acl.pkcs7 -binary -outform DER -nodetach -noattr + + openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in kernel-acl.txt \ + -out kernel-acl.pkcs7 -binary -outform DER -nodetach -noattr + +Afterwards the ACL list in the clavis keyring can be updated: + +.. code-block:: bash + + keyctl padd clavis_key_acl "" %:.clavis < module-acl.pkcs7 + keyctl padd clavis_key_acl "" %:.clavis < kernel-acl.pkcs7 + + keyctl show %:.clavis + + Keyring + 254954913 ----swrv 0 0 keyring: .clavis + 301905375 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + 1013065475 --alswrv 0 0 \_ clavis_key_acl: 02:b360d113c848ace3f1e6a80060b43d1206f0487d + 445581284 --alswrv 0 0 \_ clavis_key_acl: 00:17eb8c5bf766364be094c577625213700add9471 + +Now the 17eb8c5bf766364be094c577625213700add9471 key can be used for +validating kernel modules and the b360d113c848ace3f1e6a80060b43d1206f0487d +key can be used to validate signed kernels.
MAINTAINERS +7 -0
@@ -5567,6 +5567,13 @@ F: scripts/Makefile.clang F: scripts/clang-tools/ K: \b(?i:clang|llvm)\b +CLAVIS LINUX SECURITY MODULE +M: Eric Snowberg <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/admin-guide/LSM/clavis.rst +F: security/clavis + CLK API M: Russell King <[email protected]> L: [email protected]
crypto/asymmetric_keys/signature.c +4 -0
@@ -13,6 +13,7 @@#include <linux/err.h> #include <linux/slab.h> #include <linux/keyctl.h> +#include <linux/security.h> #include <crypto/public_key.h> #include <keys/user-type.h> #include "asymmetric_keys.h"
@@ -153,6 +154,9 @@ int verify_signature(const struct key *key, ret = subtype->verify_signature (key, sig); +if (!ret) + ret =security_key_verify_signature (key, sig); +pr_devel ("<==%s() = %d\n" , __func__, ret);return ret; }
include/linux/lsm_count.h +7 -1
@@ -102,6 +102,11 @@#define IPE_ENABLED #endif +#if IS_ENABLED (CONFIG_SECURITY_CLAVIS ) +#define CLAVIS_ENABLED 1, +#else +#define CLAVIS_ENABLED +#endif /* * There is a trailing comma that we need to be accounted for. This is done by * using a skipped argument in __COUNT_LSMS
@@ -124,7 +129,8 @@LANDLOCK_ENABLED \ IMA_ENABLED \EVM_ENABLED \ - IPE_ENABLED) +IPE_ENABLED \ + CLAVIS_ENABLED) #else
include/linux/lsm_hook_defs.h +2 -0
@@ -410,6 +410,8 @@ LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **buffer) LSM_HOOK(void, LSM_RET_VOID, key_post_create_or_update, struct key *keyring, struct key *key, const void *payload, size_t payload_len, unsigned long flags, bool create) +LSM_HOOK(int, 0, key_verify_signature, const struct key *key, + const struct public_key_signature *sig)#endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT
include/linux/security.h +7 -0
@@ -63,6 +63,7 @@ enum fs_value_type;struct watch ;struct watch_notification ;struct lsm_ctx ; +struct public_key_signature ;/* Default (no) options for the capable function */ #define CAP_OPT_NONE 0x0
@@ -2053,6 +2054,7 @@ void security_key_post_create_or_update(struct key *keyring, struct key *key, const void *payload, size_t payload_len, unsigned long flags, bool create); +int security_key_verify_signature (const struct key *key,const struct public_key_signature *sig);#else static inline int security_key_alloc(struct key *key,
@@ -2087,6 +2089,11 @@ static inline void security_key_post_create_or_update(struct key *keyring, bool create) { } +static inline int security_key_verify_signature (const struct key *key, +const struct public_key_signature *sig) +{ +return 0 ; +}#endif #endif /* CONFIG_KEYS */
include/uapi/linux/lsm.h +1 -0
@@ -65,6 +65,7 @@ struct lsm_ctx {#define LSM_ID_IMA 111#define LSM_ID_EVM 112#define LSM_ID_IPE 113 +#define LSM_ID_CLAVIS 114/* * LSM_ATTR_XXX definitions identify different LSM attributes
security/Kconfig +5 -5
@@ -265,11 +265,11 @@ endchoice config LSM string "Ordered list of enabled LSMs" - default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf" if DEFAULT_SECURITY_SMACK - default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf" if DEFAULT_SECURITY_APPARMOR - default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf" if DEFAULT_SECURITY_TOMOYO - default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf" if DEFAULT_SECURITY_DAC - default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf" + default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf,clavis" if DEFAULT_SECURITY_SMACK + default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf,clavis" if DEFAULT_SECURITY_APPARMOR + default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf,clavis" if DEFAULT_SECURITY_TOMOYO + default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf,clavis" if DEFAULT_SECURITY_DAC + default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf,clavis" help A comma-separated list of LSMs, in initialization order. Any LSMs left off this list, except for those with order
security/clavis/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.o +obj-$(CONFIG_SECURITY_CLAVIS) += clavis.o
security/clavis/clavis.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +// +#include <linux/lsm_hooks.h> +#include <uapi/linux/lsm.h> +#include "clavis.h" + +static struct security_hook_list clavis_hooks[]__ro_after_init = { +LSM_HOOK_INIT (key_verify_signature, clavis_sig_verify), +}; + +const struct lsm_id clavis_lsmid = { + .name ="clavis" , + .id =LSM_ID_CLAVIS , +}; + +static int __init clavis_lsm_init (void ) +{ +clavis_keyring_init (); +security_add_hooks (clavis_hooks,ARRAY_SIZE (clavis_hooks), &clavis_lsmid); +return 0 ; +}; + +DEFINE_LSM (clavis) = { + .name ="clavis" , + .init = clavis_lsm_init, +};
security/clavis/clavis.h +4 -0
@@ -3,6 +3,8 @@#define _SECURITY_CLAVIS_H_#include <keys/asymmetric-type.h> +struct public_key_signature ; +/* Max length for the asymmetric key id contained on the boot param */ #define CLAVIS_BIN_KID_MAX 32#define CLAVIS_ASCII_KID_MAX 64
@@ -20,4 +22,6 @@ const char __initconst *const clavis_module_acl[] = {extern const char __initconst *const clavis_module_acl[];#endif +int __init clavis_keyring_init (void ); +int clavis_sig_verify (const struct key *key,const struct public_key_signature *sig);#endif /* _SECURITY_CLAVIS_H_ */
security/clavis/clavis_keyring.c +75 -3
92 lines not on this page · raw message
security/security.c +13 -0
@@ -5522,6 +5522,19 @@ void security_key_post_create_or_update(struct key *keyring, struct key *key,call_void_hook (key_post_create_or_update, keyring, key, payload, payload_len, flags, create); } + +/** +* security_key_verify_signature - verify signature +* @key: key +* @sig: signature +* +* See whether signature verification is allowed based on the ACL for +* key usage. +*/ +int security_key_verify_signature (const struct key *key,const struct public_key_signature *sig) +{ +return call_int_hook (key_verify_signature, key, sig); +}#endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT
tools/testing/selftests/lsm/lsm_list_modules_test.c +3 -0
@@ -131,6 +131,9 @@ TEST(correct_lsm_list_modules)case LSM_ID_IPE : name ="ipe" ;break ; +case LSM_ID_CLAVIS : + name ="clavis" ; +break ;default : name ="INVALID" ;break ;
Signature · 1 line
2.45.0
Re: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
Quoted 54 lines · Eric Snowberg
Introduce a new LSM called clavis. The motivation behind this LSM is to provide access control for system keys. The access control list is contained within a keyring call .clavis. During boot if the clavis= boot arg is supplied with a key id contained within any of the current system keyrings (builtin, secondary, machine, or platform) it shall be used as the root of trust for validating anything that is added to the ACL list.
The first restriction introduced with this LSM is the ability to enforce key usage. The kernel already has a notion of tracking key usage. This LSM adds the ability to enforce this usage based on the system owners configuration.
Each system key may have one or more uses defined within the ACL list. Until an entry is added to the .clavis keyring, no other system key may be used for any other purpose.
Signed-off-by Eric Snowberg <[email protected]>--- Documentation/admin-guide/LSM/clavis.rst | 191 ++++++++++++++++++ MAINTAINERS | 7 + crypto/asymmetric_keys/signature.c | 4 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 10 +- security/clavis/Makefile | 1 + security/clavis/clavis.c | 26 +++ security/clavis/clavis.h | 4 + security/clavis/clavis_keyring.c | 78 ++++++- security/security.c | 13 ++ .../selftests/lsm/lsm_list_modules_test.c | 3 + 14 files changed, 346 insertions(+), 9 deletions(-) create mode 100644 Documentation/admin-guide/LSM/clavis.rst create mode 100644 security/clavis/clavis.cDocumentation/admin-guide/LSM/clavis.rst new file +12
-0@@ -0,0 +1,191 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Clavis +====== + +Clavis is a Linux Security Module that provides mandatory access control to +system kernel keys (i.e. builtin, secondary, machine and platform). These +restrictions will prohibit keys from being used for validation. Upon boot, the +Clavis LSM is provided a key id as a boot parameter. This single key is then +used as the root of trust for any access control modifications made going +forward. Access control updates must be signed and validated by this key.
Documentation/admin-guide/LSM/clavis.rst line 22
Quoted 10 lines
Documentation/admin-guide/LSM/clavis.rst new file +10
-0+ +Clavis has its own keyring. All ACL updates are applied through this keyring. +The update must be signed by the single root of trust key. + +When enabled, all system keys are prohibited from being used until an ACL is +added for them. + +On UEFI platforms, the root of trust key shall survive a kexec. Trying to +defeat or change it from the command line is not allowed. The original boot +parameter is stored in UEFI and will always be referenced following a kexec.
Does this mean someone can reboot the host, boot another OS, store a key id in UEFI, and force the root of trust key to be one other than what the user lists in clavis= boot argument?
Never mind! Saw the answer in patches 10 and 11, thanks.
Documentation/admin-guide/LSM/clavis.rst line 24
Quoted 1 line
Documentation/admin-guide/LSM/clavis.rst new file +1
-0+The Clavis LSM contains a system keyring call .clavis. It contains a single
s/call/called/
Documentation/admin-guide/LSM/clavis.rst line 27
Quoted 3 lines
Documentation/admin-guide/LSM/clavis.rst new file +3
-0+asymmetric key that is used to validate anything added to it. This key can +be added during boot and must be a preexisting system kernel key. If the +``clavis=`` boot parameter is not used, any asymmetric key the user owns
Who is "the user", and precisely what does "owns' mean here? Is it just restating that it must be a key already in one of the builtin or secondary or platform keyrings?
And this is done by simply loading it into the clavis keyring, right?
-serge
Eric Snowberg
reviewerRe: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
Quoted 9 lines · On Oct 22, 2024, at 8:25 PM, [email protected] wrote:
Quoted 2 lines · Eric Snowberg
+The Clavis LSM contains a system keyring call .clavis. It contains a single
s/call/called/
I will change that, thanks.
Quoted 7 lines
Documentation/admin-guide/LSM/clavis.rst line 27
Quoted 3 lines
Documentation/admin-guide/LSM/clavis.rst new file +3
-0+asymmetric key that is used to validate anything added to it. This key can +be added during boot and must be a preexisting system kernel key. If the +``clavis=`` boot parameter is not used, any asymmetric key the user ownsWho is "the user", and precisely what does "owns' mean here? Is it just restating that it must be a key already in one of the builtin or secondary or platform keyrings?
In the case where Clavis was not provided a key id during boot, root can add a single public key to the .clavis keyring anytime afterwards. This key does not need to be in any of the system keyrings. Once the key is added, the Clavis LSM is enabled. The root user must also own the private key, since this is required to do the ACL signing. I will try to clarify this better in the documentation.
I wouldn't expect this to be the typical way Clavis would be used. I would also be interested in any feedback if enabling the Clavis LSM this way following boot should be removed. If this were removed, Clavis could only be enabled when using the boot parameter.
Quoted 1 line
And this is done by simply loading it into the clavis keyring, right?
Correct.
Re: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
Quoted 18 lines · Eric Snowberg
Quoted 7 lines · On Oct 22, 2024, at 8:25 PM, [email protected] wrote:
Quoted 2 lines · Eric Snowberg
+The Clavis LSM contains a system keyring call .clavis. It contains a single
s/call/called/
I will change that, thanks.
Quoted 7 lines
Documentation/admin-guide/LSM/clavis.rst line 27
Quoted 3 lines
Documentation/admin-guide/LSM/clavis.rst new file +3
-0+asymmetric key that is used to validate anything added to it. This key can +be added during boot and must be a preexisting system kernel key. If the +``clavis=`` boot parameter is not used, any asymmetric key the user ownsWho is "the user", and precisely what does "owns' mean here? Is it just restating that it must be a key already in one of the builtin or secondary or platform keyrings?
Quoted 5 lines
In the case where Clavis was not provided a key id during boot, root can add a single public key to the .clavis keyring anytime afterwards. This key does not need to be in any of the system keyrings. Once the key is added, the Clavis LSM is enabled. The root user must also own the private key, since this is required to do the ACL signing. I will try to clarify this better
Ooh, I see. Own it as in be able to sign things with it. Of course. Thanks.
Quoted 3 lines
in the documentation.
I wouldn't expect this to be the typical way Clavis would be used. I would
Right, I wasn't asking because I would want to use it that way, but because it feels potentially dangerous :)
Quoted 3 lines
also be interested in any feedback if enabling the Clavis LSM this way following boot should be removed. If this were removed, Clavis could only be enabled when using the boot parameter.
Yeah I don't know enough to give good guidance here. I do worry about UKIs enforcing only the built-in signed kernel command line and so preventing a user from appending their own clavis= entry. Not knowing how this will end up getting deployed, I'm not sure which is the more important issue.
Quoted 4 lines
Quoted 1 line
And this is done by simply loading it into the clavis keyring, right?
Correct.
Mimi Zohar
maintainerRe: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
In reply to Eric SnowbergQuoted 50 lines · Eric Snowberg
Introduce a new LSM called clavis. The motivation behind this LSM is to provide access control for system keys. The access control list is contained within a keyring call .clavis. During boot if the clavis= boot arg is supplied with a key id contained within any of the current system keyrings (builtin, secondary, machine, or platform) it shall be used as the root of trust for validating anything that is added to the ACL list.
The first restriction introduced with this LSM is the ability to enforce key usage. The kernel already has a notion of tracking key usage. This LSM adds the ability to enforce this usage based on the system owners configuration.
Each system key may have one or more uses defined within the ACL list. Until an entry is added to the .clavis keyring, no other system key may be used for any other purpose.
Signed-off-by Eric Snowberg <[email protected]>--- Documentation/admin-guide/LSM/clavis.rst | 191 ++++++++++++++++++ MAINTAINERS | 7 + crypto/asymmetric_keys/signature.c | 4 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 10 +- security/clavis/Makefile | 1 + security/clavis/clavis.c | 26 +++ security/clavis/clavis.h | 4 + security/clavis/clavis_keyring.c | 78 ++++++- security/security.c | 13 ++ .../selftests/lsm/lsm_list_modules_test.c | 3 + 14 files changed, 346 insertions(+), 9 deletions(-) create mode 100644 Documentation/admin-guide/LSM/clavis.rst create mode 100644 security/clavis/clavis.cDocumentation/admin-guide/LSM/clavis.rst new file +8
-0@@ -0,0 +1,191 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Clavis +====== + +Clavis is a Linux Security Module that provides mandatory access control to +system kernel keys (i.e. builtin, secondary, machine and platform). These
Documentation/admin-guide/LSM/clavis.rst line 18
Quoted 10 lines
Documentation/admin-guide/LSM/clavis.rst new file +10
-0+restrictions will prohibit keys from being used for validation. Upon boot, the +Clavis LSM is provided a key id as a boot parameter. This single key is then +used as the root of trust for any access control modifications made going +forward. Access control updates must be signed and validated by this key. + +Clavis has its own keyring. All ACL updates are applied through this keyring. +The update must be signed by the single root of trust key. + +When enabled, all system keys are prohibited from being used until an ACL is +added for them.
Until the single key has been loaded, Clavis is not enabled. Any key on the system trusted keyrings remains usable for any purpose.
-> When enabled, meaning the single key has been loaded onto the Clavis keyring, all system keys are prohibited ...
Until clavis is enabled, in my opinion the defaults should be restrictive (e.g. CONFIG_INTEGRITY_CA_MACHINE_KEYRING, CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN). Once Clavis is enabled, based on a new helper function is_clavis_enforced() we could consider relaxing some of the existing keyring requirements (e.g. kernel modules).
Mimi
Quoted 514 lines
Documentation/admin-guide/LSM/clavis.rst new file +173
-0+ +On UEFI platforms, the root of trust key shall survive a kexec. Trying to +defeat or change it from the command line is not allowed. The original boot +parameter is stored in UEFI and will always be referenced following a kexec. + +The Clavis LSM contains a system keyring call .clavis. It contains a single +asymmetric key that is used to validate anything added to it. This key can +be added during boot and must be a preexisting system kernel key. If the +``clavis=`` boot parameter is not used, any asymmetric key the user owns +can be added to enable the LSM. + +The only user space components are OpenSSL and the keyctl utility. A new +key type call ``clavis_key_acl`` is used for ACL updates. Any number of signed +``clavis_key_acl`` entries may be added to the .clavis keyring. The +``clavis_key_acl`` contains the subject key identifier along with the allowed +usage type for the key. + +The format is as follows: + +.. code-block:: console + + XX:YYYYYYYYYYY + + XX - Single byte of the key type + VERIFYING_MODULE_SIGNATURE 00 + VERIFYING_FIRMWARE_SIGNATURE 01 + VERIFYING_KEXEC_PE_SIGNATURE 02 + VERIFYING_KEY_SIGNATURE 03 + VERIFYING_KEY_SELF_SIGNATURE 04 + VERIFYING_UNSPECIFIED_SIGNATURE 05 + : - ASCII colon + YY - Even number of hexadecimal characters representing the key id + +The ``clavis_key_acl`` must be S/MIME signed by the sole asymmetric key contained +within the .clavis keyring. + +In the future if new features are added, new key types could be created. + +Usage Examples +============== + +How to create a signing key: +---------------------------- + +.. code-block:: bash + + cat <<EOF > clavis-lsm.genkey + [ req ] + default_bits = 4096 + distinguished_name = req_distinguished_name + prompt = no + string_mask = utf8only + x509_extensions = v3_ca + [ req_distinguished_name ] + O = TEST + CN = Clavis LSM key + emailAddress = [email protected] + [ v3_ca ] + basicConstraints=CA:TRUE + subjectKeyIdentifier=hash + authorityKeyIdentifier=keyid:always,issuer + keyUsage=digitalSignature + EOF + + openssl req -new -x509 -utf8 -sha256 -days 3650 -batch \ + -config clavis-lsm.genkey -outform DER \ + -out clavis-lsm.x509 -keyout clavis-lsm.priv + +How to get the Subject Key Identifier +------------------------------------- + +.. code-block:: bash + + openssl x509 -in ./clavis-lsm.x509 -inform der \ + -ext subjectKeyIdentifier -nocert \ + | tail -n +2 | cut -f2 -d '='| tr -d ':' + 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +How to enroll the signing key into the MOK +------------------------------------------ + +The key must now be added to the machine or platform keyrings. This +indicates the key was added by the system owner. For kernels booted through +shim, a first-stage UEFI boot loader, a key may be added to the machine keyring +by doing: + +.. code-block:: bash + + mokutil --import ./clavis-lsm.x509 + +and then rebooting and enrolling the key through MokManager. + +How to enable the Clavis LSM +---------------------------- + +Add the key id to the ``clavis=`` boot parameter. With the example above the +key id is the subject key identifier: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +Add the following boot parameter: + +.. code-block:: console + + clavis=4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +After booting there will be a single key contained in the .clavis keyring: + +.. code-block:: bash + + keyctl show %:.clavis + Keyring + 254954913 ----swrv 0 0 keyring: .clavis + 301905375 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +The original ``clavis=`` boot parameter will persist across any kexec. Changing it or +removing it has no effect. + + +How to sign an entry to be added to the .clavis keyring: +-------------------------------------------------------- + +In this example we have 3 keys in the machine keyring. Our Clavis LSM key, a +key we want to use for kernel verification and a key we want to use for module +verification. + +.. code-block:: bash + + keyctl show %:.machine + Keyring + 999488265 ---lswrv 0 0 keyring: .machine + 912608009 ---lswrv 0 0 \_ asymmetric: TEST: Module Key: 17eb8c5bf766364be094c577625213700add9471 + 646229664 ---lswrv 0 0 \_ asymmetric: TEST: Kernel Key: b360d113c848ace3f1e6a80060b43d1206f0487d + 1073737099 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + +To update the .clavis kerying ACL list, first create a file containing the +key usage type followed by a colon and the key id that we want to allow to +validate that usage. In the first example we are saying key +17eb8c5bf766364be094c577625213700add9471 is allowed to validate kernel modules. +In the second example we are saying key b360d113c848ace3f1e6a80060b43d1206f0487d +is allowed to validate signed kernels. + +.. code-block:: bash + + echo "00:17eb8c5bf766364be094c577625213700add9471" > module-acl.txt + echo "02:b360d113c848ace3f1e6a80060b43d1206f0487d" > kernel-acl.txt + +Now both these files must be signed by the key contained in the .clavis keyring: + +.. code-block:: bash + + openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in module-acl.txt \ + -out module-acl.pkcs7 -binary -outform DER -nodetach -noattr + + openssl smime -sign -signer clavis-lsm.x509 -inkey clavis-lsm.priv -in kernel-acl.txt \ + -out kernel-acl.pkcs7 -binary -outform DER -nodetach -noattr + +Afterwards the ACL list in the clavis keyring can be updated: + +.. code-block:: bash + + keyctl padd clavis_key_acl "" %:.clavis < module-acl.pkcs7 + keyctl padd clavis_key_acl "" %:.clavis < kernel-acl.pkcs7 + + keyctl show %:.clavis + + Keyring + 254954913 ----swrv 0 0 keyring: .clavis + 301905375 ---lswrv 0 0 \_ asymmetric: TEST: Clavis LSM key: 4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8 + 1013065475 --alswrv 0 0 \_ clavis_key_acl: 02:b360d113c848ace3f1e6a80060b43d1206f0487d + 445581284 --alswrv 0 0 \_ clavis_key_acl: 00:17eb8c5bf766364be094c577625213700add9471 + +Now the 17eb8c5bf766364be094c577625213700add9471 key can be used for +validating kernel modules and the b360d113c848ace3f1e6a80060b43d1206f0487d +key can be used to validate signed kernels.MAINTAINERS +7
-0@@ -5567,6 +5567,13 @@ F: scripts/Makefile.clang F: scripts/clang-tools/ K: \b(?i:clang|llvm)\b +CLAVIS LINUX SECURITY MODULE +M: Eric Snowberg <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/admin-guide/LSM/clavis.rst +F: security/clavis + CLK API M: Russell King <[email protected]> L: [email protected]crypto/asymmetric_keys/signature.c +4
-0@@ -13,6 +13,7 @@#include <linux/err.h> #include <linux/slab.h> #include <linux/keyctl.h> +#include <linux/security.h> #include <crypto/public_key.h> #include <keys/user-type.h> #include "asymmetric_keys.h" @@ -153,6 +154,9 @@ int verify_signature(const struct key *key, ret = subtype->verify_signature (key, sig); +if (!ret) + ret =security_key_verify_signature (key, sig); +pr_devel ("<==%s() = %d\n" , __func__, ret);return ret; }include/linux/lsm_count.h +7
-1@@ -102,6 +102,11 @@#define IPE_ENABLED #endif +#if IS_ENABLED (CONFIG_SECURITY_CLAVIS ) +#define CLAVIS_ENABLED 1, +#else +#define CLAVIS_ENABLED +#endif /* * There is a trailing comma that we need to be accounted for. This is done by * using a skipped argument in __COUNT_LSMS @@ -124,7 +129,8 @@LANDLOCK_ENABLED \ IMA_ENABLED \EVM_ENABLED \ - IPE_ENABLED) +IPE_ENABLED \ + CLAVIS_ENABLED) #elseinclude/linux/lsm_hook_defs.h +2
-0@@ -410,6 +410,8 @@ LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **buffer) LSM_HOOK(void, LSM_RET_VOID, key_post_create_or_update, struct key *keyring, struct key *key, const void *payload, size_t payload_len, unsigned long flags, bool create) +LSM_HOOK(int, 0, key_verify_signature, const struct key *key, + const struct public_key_signature *sig)#endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT include/linux/security.h +7
-0@@ -63,6 +63,7 @@ enum fs_value_type;struct watch ;struct watch_notification ;struct lsm_ctx ; +struct public_key_signature ;/* Default (no) options for the capable function */ #define CAP_OPT_NONE 0x0@@ -2053,6 +2054,7 @@ void security_key_post_create_or_update(struct key *keyring, struct key *key, const void *payload, size_t payload_len, unsigned long flags, bool create); +int security_key_verify_signature (const struct key *key,const struct public_key_signature *sig);#else static inline int security_key_alloc(struct key *key,@@ -2087,6 +2089,11 @@ static inline void security_key_post_create_or_update(struct key *keyring, bool create) { } +static inline int security_key_verify_signature (const struct key *key, +const struct public_key_signature *sig) +{ +return 0 ; +}#endif #endif /* CONFIG_KEYS */ include/uapi/linux/lsm.h +1
-0@@ -65,6 +65,7 @@ struct lsm_ctx {#define LSM_ID_IMA 111#define LSM_ID_EVM 112#define LSM_ID_IPE 113 +#define LSM_ID_CLAVIS 114/* * LSM_ATTR_XXX definitions identify different LSM attributes security/Kconfig +5
-5@@ -265,11 +265,11 @@ endchoice config LSM string "Ordered list of enabled LSMs" - default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf" if DEFAULT_SECURITY_SMACK - default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf" if DEFAULT_SECURITY_APPARMOR - default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf" if DEFAULT_SECURITY_TOMOYO - default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf" if DEFAULT_SECURITY_DAC - default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf" + default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf,clavis" if DEFAULT_SECURITY_SMACK + default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf,clavis" if DEFAULT_SECURITY_APPARMOR + default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf,clavis" if DEFAULT_SECURITY_TOMOYO + default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf,clavis" if DEFAULT_SECURITY_DAC + default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf,clavis" help A comma-separated list of LSMs, in initialization order. Any LSMs left off this list, except for those with ordersecurity/clavis/Makefile +1
-0@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.o +obj-$(CONFIG_SECURITY_CLAVIS) += clavis.osecurity/clavis/clavis.c new file +26
-0@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +// +#include <linux/lsm_hooks.h> +#include <uapi/linux/lsm.h> +#include "clavis.h" + +static struct security_hook_list clavis_hooks[]__ro_after_init = { +LSM_HOOK_INIT (key_verify_signature, clavis_sig_verify), +}; + +const struct lsm_id clavis_lsmid = { + .name ="clavis" , + .id =LSM_ID_CLAVIS , +}; + +static int __init clavis_lsm_init (void ) +{ +clavis_keyring_init (); +security_add_hooks (clavis_hooks,ARRAY_SIZE (clavis_hooks), &clavis_lsmid); +return 0 ; +}; + +DEFINE_LSM (clavis) = { + .name ="clavis" , + .init = clavis_lsm_init, +};security/clavis/clavis.h +4
-0@@ -3,6 +3,8 @@#define _SECURITY_CLAVIS_H_#include <keys/asymmetric-type.h> +struct public_key_signature ; +/* Max length for the asymmetric key id contained on the boot param */ #define CLAVIS_BIN_KID_MAX 32#define CLAVIS_ASCII_KID_MAX 64@@ -20,4 +22,6 @@ const char __initconst *const clavis_module_acl[] = {extern const char __initconst *const clavis_module_acl[];#endif +int __init clavis_keyring_init (void ); +int clavis_sig_verify (const struct key *key,const struct public_key_signature *sig);#endif /* _SECURITY_CLAVIS_H_ */ security/clavis/clavis_keyring.c +75
-3@@ -284,7 +284,7 @@ static void clavis_add_acl(const char *const *skid_list, struct key *keyring) } } -static int __init clavis_keyring_init (void ) +int __init clavis_keyring_init (void ) {struct key_restriction *restriction;@@ -306,10 +306,82 @@ static int __init clavis_keyring_init(void)void __init late_init_clavis_setup (void ) { -clavis_keyring_init (); -if (!clavis_boot_akid)return ;system_key_link (clavis_keyring, clavis_boot_akid); } + +int clavis_sig_verify (const struct key *key,const struct public_key_signature *sig) +{ +const struct asymmetric_key_ids *kids =asymmetric_key_ids (key); +const struct asymmetric_key_subtype *subtype; +const struct asymmetric_key_id *newkid; +char *buf_ptr, *ptr; +key_ref_t ref; +int i, buf_len; + +if (!clavis_acl_enforced ()) +return 0 ; +if (key->type != &key_type_asymmetric) +return -EKEYREJECTED ; + subtype =asymmetric_key_subtype (key); +if (!subtype || !key->payload.data[0 ]) +return -EKEYREJECTED ; +if (!subtype->verify_signature) +return -EKEYREJECTED ; + +/* Allow sig validation when not using a system keyring */ +if (!test_bit (PKS_USAGE_SET , &sig->usage_flags)) +return 0 ; + +/* The previous sig validation is enough to get on the clavis keyring */ +if (sig->usage ==VERIFYING_CLAVIS_SIGNATURE ) +return 0 ; + +if (test_bit (PKS_REVOCATION_PASS , &sig->usage_flags)) +return 0 ; + +for (i =0 , buf_len =0 ; i <3 ; i++) { +if (kids->id[i]) { + newkid = (struct asymmetric_key_id *)kids->id[i]; +if (newkid->len > buf_len) + buf_len = newkid->len; + } + } + +if (!buf_len) +return -EKEYREJECTED ; + +/* Allocate enough space for the conversion to ascii plus the header. */ + buf_ptr =kmalloc (buf_len *2 +4 ,GFP_KERNEL | __GFP_ZERO); + +if (!buf_ptr) +return -ENOMEM ; + +for (i =0 ; i <3 ; i++) { +if (kids->id[i]) { + newkid = (struct asymmetric_key_id *)kids->id[i]; +if (!newkid->len) +continue ; + + ptr = buf_ptr; + ptr =bin2hex (ptr, &sig->usage,1 ); + *ptr++ =':' ; + ptr =bin2hex (ptr, newkid->data, newkid->len); + *ptr =0 ; + ref =keyring_search (make_key_ref (clavis_keyring_get (), true), + &clavis_key_acl, buf_ptr, false); + +if (!IS_ERR (ref)) +break ; + } + } + +kfree (buf_ptr); + +if (IS_ERR (ref)) +return -EKEYREJECTED ; + +return 0 ; +}security/security.c +13
-0@@ -5522,6 +5522,19 @@ void security_key_post_create_or_update(struct key *keyring, struct key *key,call_void_hook (key_post_create_or_update, keyring, key, payload, payload_len, flags, create); } + +/** +* security_key_verify_signature - verify signature +* @key: key +* @sig: signature +* +* See whether signature verification is allowed based on the ACL for +* key usage. +*/ +int security_key_verify_signature (const struct key *key,const struct public_key_signature *sig) +{ +return call_int_hook (key_verify_signature, key, sig); +}#endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT tools/testing/selftests/lsm/lsm_list_modules_test.c +3
-0@@ -131,6 +131,9 @@ TEST(correct_lsm_list_modules)case LSM_ID_IPE : name ="ipe" ;break ; +case LSM_ID_CLAVIS : + name ="clavis" ; +break ;default : name ="INVALID" ;break ;
Eric Snowberg
reviewerRe: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
Quoted 69 lines · Mimi Zohar
Quoted 50 lines · Eric Snowberg
Introduce a new LSM called clavis. The motivation behind this LSM is to provide access control for system keys. The access control list is contained within a keyring call .clavis. During boot if the clavis= boot arg is supplied with a key id contained within any of the current system keyrings (builtin, secondary, machine, or platform) it shall be used as the root of trust for validating anything that is added to the ACL list.
The first restriction introduced with this LSM is the ability to enforce key usage. The kernel already has a notion of tracking key usage. This LSM adds the ability to enforce this usage based on the system owners configuration.
Each system key may have one or more uses defined within the ACL list. Until an entry is added to the .clavis keyring, no other system key may be used for any other purpose.
Signed-off-by Eric Snowberg <[email protected]>---
Documentation/admin-guide/LSM/clavis.rst | 191 ++++++++++++++++++ MAINTAINERS | 7 + crypto/asymmetric_keys/signature.c | 4 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 10 +- security/clavis/Makefile | 1 + security/clavis/clavis.c | 26 +++ security/clavis/clavis.h | 4 + security/clavis/clavis_keyring.c | 78 ++++++- security/security.c | 13 ++ .../selftests/lsm/lsm_list_modules_test.c | 3 + 14 files changed, 346 insertions(+), 9 deletions(-)create mode 100644
Documentation/admin-guide/LSM/clavis.rstcreate mode 100644security/clavis/clavis.cDocumentation/admin-guide/LSM/clavis.rst new file +8
-0@@ -0,0 +1,191 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Clavis +====== + +Clavis is a Linux Security Module that provides mandatory access control to +system kernel keys (i.e. builtin, secondary, machine and platform). TheseDocumentation/admin-guide/LSM/clavis.rst line 18
Quoted 10 lines
Documentation/admin-guide/LSM/clavis.rst new file +10
-0+restrictions will prohibit keys from being used for validation. Upon boot, the +Clavis LSM is provided a key id as a boot parameter. This single key is then +used as the root of trust for any access control modifications made going +forward. Access control updates must be signed and validated by this key. + +Clavis has its own keyring. All ACL updates are applied through this keyring. +The update must be signed by the single root of trust key. + +When enabled, all system keys are prohibited from being used until an ACL is +added for them.Until the single key has been loaded, Clavis is not enabled. Any key on the system trusted keyrings remains usable for any purpose.
Quoted 8 lines
-> When enabled, meaning the single key has been loaded onto the Clavis keyring, all system keys are prohibited ...
Until clavis is enabled, in my opinion the defaults should be restrictive (e.g.
CONFIG_INTEGRITY_CA_MACHINE_KEYRING,CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN). Once Clavis is enabled, based on a new helper functionis_clavis_enforced()we could consider relaxing some of the existing keyring requirements (e.g. kernel modules).
If I made this change, would it be acceptable to update the Kconfig
description for CONFIG_INTEGRITY_CA_MACHINE_KEYRING and CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN that the restriction only applies when Clavis is not enabled? You don't
think there would be push back that those restrictions are not always
being enforced?
Mimi Zohar
maintainerRe: [RFC PATCH v3 08/13] clavis: Introduce new LSM called clavis
Quoted 68 lines · Eric Snowberg
Quoted 68 lines · Mimi Zohar
Quoted 50 lines · Eric Snowberg
Introduce a new LSM called clavis. The motivation behind this LSM is to provide access control for system keys. The access control list is contained within a keyring call .clavis. During boot if the clavis= boot arg is supplied with a key id contained within any of the current system keyrings (builtin, secondary, machine, or platform) it shall be used as the root of trust for validating anything that is added to the ACL list.
The first restriction introduced with this LSM is the ability to enforce key usage. The kernel already has a notion of tracking key usage. This LSM adds the ability to enforce this usage based on the system owners configuration.
Each system key may have one or more uses defined within the ACL list. Until an entry is added to the .clavis keyring, no other system key may be used for any other purpose.
Signed-off-by Eric Snowberg <[email protected]>---
Documentation/admin-guide/LSM/clavis.rst | 191 ++++++++++++++++++ MAINTAINERS | 7 + crypto/asymmetric_keys/signature.c | 4 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 10 +- security/clavis/Makefile | 1 + security/clavis/clavis.c | 26 +++ security/clavis/clavis.h | 4 + security/clavis/clavis_keyring.c | 78 ++++++- security/security.c | 13 ++ .../selftests/lsm/lsm_list_modules_test.c | 3 + 14 files changed, 346 insertions(+), 9 deletions(-)create mode 100644
Documentation/admin-guide/LSM/clavis.rstcreate mode 100644security/clavis/clavis.cDocumentation/admin-guide/LSM/clavis.rst new file +8
-0@@ -0,0 +1,191 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Clavis +====== + +Clavis is a Linux Security Module that provides mandatory access control to +system kernel keys (i.e. builtin, secondary, machine and platform). TheseDocumentation/admin-guide/LSM/clavis.rst line 18
Quoted 10 lines
Documentation/admin-guide/LSM/clavis.rst new file +10
-0+restrictions will prohibit keys from being used for validation. Upon boot, the +Clavis LSM is provided a key id as a boot parameter. This single key is then +used as the root of trust for any access control modifications made going +forward. Access control updates must be signed and validated by this key. + +Clavis has its own keyring. All ACL updates are applied through this keyring. +The update must be signed by the single root of trust key. + +When enabled, all system keys are prohibited from being used until an ACL is +added for them.Until the single key has been loaded, Clavis is not enabled. Any key on the system trusted keyrings remains usable for any purpose.
Quoted 8 lines
Quoted 8 lines
-> When enabled, meaning the single key has been loaded onto the Clavis keyring, all system keys are prohibited ...
Until clavis is enabled, in my opinion the defaults should be restrictive (e.g.
CONFIG_INTEGRITY_CA_MACHINE_KEYRING,CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN). Once Clavis is enabled, based on a new helper functionis_clavis_enforced()we could consider relaxing some of the existing keyring requirements (e.g. kernel modules).
For example, kernel/module/signing.c: mod_verify_sig() would be updated to check whether Clavis is configured and enabled and then search/use keys on the other system keyrings.
Quoted 6 lines
If I made this change, would it be acceptable to update the
Kconfig
description forCONFIG_INTEGRITY_CA_MACHINE_KEYRINGandCONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTINthat the restriction only applies when Clavis is not enabled? You don't
think there would be push back that those restrictions are not always
being enforced?
Instead I would add a Kconfig "Note:" indicating that enabling Clavis relaxes the requirement that the key exists on the system trusted .secondary_trusted_keys keyring.
thanks,
Mimi
Eric Snowberg
reviewerRFC PATCH v3 9/13 clavis: Allow user to define acl at build time
In reply to Eric SnowbergAdd a new Kconfig called Security_CLAVIS_ACL_LIST. If set, this option should be the file name of a list of clavis ACL entries. This will be included into a C wrapper to incorporate the acl list into the kernel. The file contents must be in the following format: <two digit key usage number>:<subject key id>. If more than one entry is added, add a carriage return after each entry.
--- security/clavis/.gitignore | 1 + security/clavis/Kconfig | 10 ++++++++++ security/clavis/Makefile | 16 ++++++++++++++++ security/clavis/clavis.h | 2 ++ security/clavis/clavis_builtin_acl.c | 7 +++++++ security/clavis/clavis_keyring.c | 1 + 6 files changed, 37 insertions(+) create mode 100644 security/clavis/.gitignore create mode 100644 security/clavis/clavis_builtin_acl.c
security/clavis/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/builtin_acl
security/clavis/Kconfig +10 -0
@@ -9,3 +9,13 @@ config SECURITY_CLAVIS keyrings (builtin, secondary, or platform). One way to add this key is during boot by passing in the asymmetric key id within the "clavis=" boot param. This keyring is required by the Clavis LSM. + +config SECURITY_CLAVIS_ACL_LIST + string "Clavis ACL list to preload into the clavis keyring" + depends on SECURITY_CLAVIS + help + If set, this option should be the file name of a list of clavis ACL + entries. This will be included into a C wrapper to incorporate the + acl list into the kernel. The file contents must be in the following + format: <two digit key usage number>:<subject key id>. If more than + one entry is added, add a carriage return after each entry.
security/clavis/Makefile +16 -0
@@ -2,3 +2,19 @@ obj-$(CONFIG_SECURITY_CLAVIS) += clavis_keyring.o obj-$(CONFIG_SECURITY_CLAVIS) += clavis.o +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_builtin_acl.o + +ifeq ($(CONFIG_SECURITY_CLAVIS_ACL_LIST),) +quiet_cmd_make_builtin_acl = GEN $@ + cmd_make_builtin_acl = \ + echo > $@ +else +quiet_cmd_make_builtin_acl = GEN $@ + cmd_make_builtin_acl = \ + sed 's/^[ \t]*//; s/.*/"&",/' $< | tr '[:upper:]' '[:lower:]' > $@ +endif + +$(obj)/builtin_acl: $(CONFIG_SECURITY_CLAVIS_ACL_LIST) FORCE + $(call if_changed,make_builtin_acl) + +$(obj)/clavis_builtin_acl.o: $(obj)/builtin_acl
security/clavis/clavis.h +2 -0
@@ -14,6 +14,8 @@ struct asymmetric_setup_kid {unsigned char data[CLAVIS_BIN_KID_MAX ]; }; +extern const char __initconst *const clavis_builtin_acl_list[]; +#ifndef CONFIG_SYSTEM_TRUSTED_KEYRING const char __initconst *const clavis_module_acl[] = { NULL
security/clavis/clavis_builtin_acl.c new file +7 -0
@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "clavis.h" + +const char __initconst *const clavis_builtin_acl_list[] = { +#include "builtin_acl" +NULL +};
security/clavis/clavis_keyring.c +1 -0
@@ -300,6 +300,7 @@ int __init clavis_keyring_init(void)panic ("Can't allocate clavis keyring\n" );clavis_add_acl (clavis_module_acl, clavis_keyring); +clavis_add_acl (clavis_builtin_acl_list, clavis_keyring);return 0 ; }
Signature · 1 line
2.45.0
Eric Snowberg
reviewerRFC PATCH v3 10/13 efi: Make clavis boot param persist across kexec
In reply to Eric SnowbergAdd the ability for the clavis boot param to persist across kexec. This is done by creating a RT variable before ExitBootServices is called. The new variable is called Clavis with a new GUID 193ccef6-348b-4f1f-a81b-0ea4b899dbf2. This variable does not have NVRAM set, signifying it was created during the Boot Services phase. This variable will persist across a kexec, however it will not persist across a power on reset. This same type of functionality is currently used within EFI shim to mirror MOK variables into the kernel. It is being used here so the clavis boot param can not be changed via kexec. If a different clavis boot param is used, the one stored in the RT variable will be used instead. Enforcement of which boot param to use will be done in a follow on patch.
--- drivers/firmware/efi/Kconfig | 12 +++++++ drivers/firmware/efi/libstub/Makefile | 1 + drivers/firmware/efi/libstub/clavis.c | 33 +++++++++++++++++++ .../firmware/efi/libstub/efi-stub-helper.c | 2 ++ drivers/firmware/efi/libstub/efi-stub.c | 2 ++ drivers/firmware/efi/libstub/efistub.h | 8 +++++ drivers/firmware/efi/libstub/x86-stub.c | 2 ++ include/linux/efi.h | 1 + 8 files changed, 61 insertions(+) create mode 100644 drivers/firmware/efi/libstub/clavis.c
drivers/firmware/efi/Kconfig +12 -0
@@ -186,6 +186,18 @@ config RESET_ATTACK_MITIGATION have been evicted, since otherwise it will trigger even on clean reboots. +config EARLY_CLAVIS + bool "Early clavis" + depends on EFI_STUB + help + Allow the clavis boot param to persist across kexec. This will create a + variable called Clavis with a 193ccef6-348b-4f1f-a81b-0ea4b899dbf2 GUID. + This variable does not have NVRAM set, signifying it was created during + the Boot Services phase. This variable will persist across a kexec, + however it will not persist across a power on reset. During kexec, if + a different clavis boot param is used, the one stored in the RT variable + will be used instead. + config EFI_RCI2_TABLE bool "EFI Runtime Configuration Interface Table Version 2 Support" depends on X86 || COMPILE_TEST
drivers/firmware/efi/libstub/Makefile +1 -0
@@ -86,6 +86,7 @@ lib-$(CONFIG_X86) += x86-stub.o smbios.o lib-$(CONFIG_X86_64) += x86-5lvl.o lib-$(CONFIG_RISCV) += kaslr.o riscv.o riscv-stub.o lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o +lib-$(CONFIG_EARLY_CLAVIS) += clavis.o CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
drivers/firmware/efi/libstub/clavis.c new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/efi.h> +#include <asm/efi.h> +#include "efistub.h" + +#define MAX_PARAM_LENGTH 64 +static const efi_char16_t clavis_param_name[] =L"Clavis" ; +static const efi_guid_t clavis_guid =LINUX_EFI_CLAVIS_GUID ; +static unsigned char param_data[MAX_PARAM_LENGTH ]; +static size_t param_len; + +void efi_parse_clavis (char *option) +{ +if (!option) +return ; + + param_len =strnlen (option,MAX_PARAM_LENGTH ); +memcpy (param_data, option, param_len); +} + +void efi_setup_clavis (void ) +{ +efi_status_t error; + +if (param_len) { + error =set_efi_var (clavis_param_name, &clavis_guid, +EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS , + param_len, ¶m_data); + } + +if (error) +efi_err ("Failed to set Clavis\n" ); +}
drivers/firmware/efi/libstub/efi-stub-helper.c +2 -0
@@ -100,6 +100,8 @@ efi_status_t efi_parse_options(char const *cmdline) }else if (!strcmp (param,"video" ) && val &&strstarts (val,"efifb:" )) {efi_parse_option_graphics (val +strlen ("efifb:" )); + }else if (!strcmp (param,"clavis" ) && val) { +efi_parse_clavis (val); } }efi_bs_call (free_pool, buf);
drivers/firmware/efi/libstub/efi-stub.c +2 -0
@@ -183,6 +183,8 @@ efi_status_t efi_stub_common(efi_handle_t handle,install_memreserve_table (); +efi_setup_clavis (); + status =efi_boot_kernel (handle, image, image_addr, cmdline_ptr);free_screen_info (si);
drivers/firmware/efi/libstub/efistub.h +8 -0
@@ -1142,6 +1142,14 @@ static inline voidefi_enable_reset_attack_mitigation (void) { }#endif +#ifdef CONFIG_EARLY_CLAVIS +void efi_parse_clavis (char *option); +void efi_setup_clavis (void ); +#else +static inline void efi_parse_clavis (char *option) { } +static inline void efi_setup_clavis (void ) { } +#endif +void efi_retrieve_eventlog (void );struct screen_info *alloc_screen_info (void );
drivers/firmware/efi/libstub/x86-stub.c +2 -0
@@ -1044,6 +1044,8 @@ void __noreturn efi_stub_entry(efi_handle_t handle,setup_unaccepted_memory (); +efi_setup_clavis (); + status =exit_boot (boot_params, handle);if (status !=EFI_SUCCESS ) {efi_err ("exit_boot() failed!\n" );
include/linux/efi.h +1 -0
@@ -423,6 +423,7 @@ void efi_native_runtime_setup(void);#define LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID EFI_GUID(0xd5d1de3c, 0x105c, 0x44f9, 0x9e, 0xa9, 0xbc, 0xef, 0x98, 0x12, 0x00, 0x31)#define RISCV_EFI_BOOT_PROTOCOL_GUID EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, 0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf) +#define LINUX_EFI_CLAVIS_GUID EFI_GUID(0x193ccef6, 0x348b, 0x4f1f, 0xa8, 0x1b, 0x0e, 0xa4, 0xb8, 0x99, 0xdb, 0xf2)/* * This GUID may be installed onto the kernel image's handle as a NULL protocol
Signature · 1 line
2.45.0
Eric Snowberg
reviewerRFC PATCH v3 11/13 clavis: Prevent boot param change during kexec
In reply to Eric SnowbergIf found, use the new Clavis EFI RT variable to validate the clavis boot param didn't change during a reboot. If the boot param is different or missing, use the one stored in EFI instead. This will prevent a pivot in the root of trust for the upcoming Clavis LSM. If CONFIG_EARLY_CLAVIS is not enabled, the Clavis EFI RT variable will never be set and therefore not used.
--- security/clavis/Makefile | 4 +++ security/clavis/clavis.h | 9 ++++++ security/clavis/clavis_efi.c | 50 ++++++++++++++++++++++++++++++++ security/clavis/clavis_keyring.c | 11 ++++++- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 security/clavis/clavis_efi.c
security/clavis/Makefile +4 -0
@@ -18,3 +18,7 @@ $(obj)/builtin_acl: $(CONFIG_SECURITY_CLAVIS_ACL_LIST) FORCE $(call if_changed,make_builtin_acl) $(obj)/clavis_builtin_acl.o: $(obj)/builtin_acl + +ifeq ($(CONFIG_EFI),y) +obj-$(CONFIG_SECURITY_CLAVIS) += clavis_efi.o +endif
security/clavis/clavis.h +9 -0
@@ -24,6 +24,15 @@ const char __initconst *const clavis_module_acl[] = {extern const char __initconst *const clavis_module_acl[];#endif +#ifdef CONFIG_EFI +int clavis_efi_param (struct asymmetric_key_id *kid,int len); +#else +static inline int __init clavis_efi_param (struct asymmetric_key_id *kid,int len) +{ +return -EINVAL ; +} +#endif +int __init clavis_keyring_init (void );int clavis_sig_verify (const struct key *key,const struct public_key_signature *sig);#endif /* _SECURITY_CLAVIS_H_ */
security/clavis/clavis_efi.c new file +50 -0
50 lines not on this page · raw message
security/clavis/clavis_keyring.c +10 -1
@@ -307,9 +307,18 @@ int __init clavis_keyring_init(void)void __init late_init_clavis_setup (void ) { -if (!clavis_boot_akid) +struct asymmetric_setup_kid efi_keyid; +struct asymmetric_key_id *keyid = &efi_keyid.id; +int error; + + error =clavis_efi_param (keyid,ARRAY_SIZE (efi_keyid.data)); + +if (error && !clavis_boot_akid)return ; +if (error) + keyid = clavis_boot_akid; +system_key_link (clavis_keyring, clavis_boot_akid); }
Signature · 1 line
2.45.0
Eric Snowberg
reviewerRFC PATCH v3 12/13 clavis: Add function redirection for Kunit support
In reply to Eric SnowbergIn preparation for Kunit support within Clavis, add function redirection for some of the static functions. Also Add KUNIT_STATIC_STUB_REDIRECT to a few functions that will be redirected in the future. This should have no functional change.
--- security/clavis/clavis_keyring.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
security/clavis/clavis_keyring.c +29 -0
@@ -8,6 +8,7 @@#include <keys/system_keyring.h> #include <keys/user-type.h> #include <crypto/pkcs7.h> +#include <kunit/static_stub.h> #include "clavis.h" static struct key *clavis_keyring;
@@ -46,6 +47,9 @@ static int pkcs7_preparse_content(void *ctx, const void *data, size_t len, size_return ret; } +int (*const pkcs7_preparse_content_fn_ptr)(void *ctx,const void *data,size_t len, +size_t asn1hdrlen) = pkcs7_preparse_content; +static void key_acl_free_preparse (struct key_preparsed_payload *prep) {kfree (prep->description);
@@ -54,16 +58,24 @@ static void key_acl_free_preparse(struct key_preparsed_payload *prep)static struct key *clavis_keyring_get (void ) { +KUNIT_STATIC_STUB_REDIRECT (clavis_keyring_get);return clavis_keyring; } +struct key * (*const clavis_keyring_get_fn_ptr)(void ) = clavis_keyring_get; +static bool clavis_acl_enforced (void ) { +KUNIT_STATIC_STUB_REDIRECT (clavis_acl_enforced);return clavis_enforced; } +bool (*const clavis_acl_enforced_fn_ptr)(void ) = clavis_acl_enforced; +static int key_acl_preparse (struct key_preparsed_payload *prep) { +KUNIT_STATIC_STUB_REDIRECT (key_acl_preparse, prep); +/* * Only allow the description to be set via the pkcs7 data contents. * The exception to this rule is if the entry was builtin, it will have
@@ -79,6 +91,8 @@ static int key_acl_preparse(struct key_preparsed_payload *prep) prep); } +int (*const key_acl_preparse_fn_ptr)(struct key_preparsed_payload *prep) = key_acl_preparse; +static int key_acl_instantiate (struct key *key,struct key_preparsed_payload *prep) {/*
@@ -225,6 +239,10 @@ static struct asymmetric_key_id *clavis_parse_boot_param(char *kid, struct asymmreturn akid; } +struct asymmetric_key_id * + (*const parse_boot_param_fn_ptr)(char *kid,struct asymmetric_key_id *akid, +int akid_max_len) = clavis_parse_boot_param; +static int __init clavis_param (char *kid) { clavis_boot_akid = clavis_parse_boot_param(kid, &clavis_setup_akid.id,
@@ -247,6 +265,10 @@ static struct key *clavis_keyring_alloc(const char *desc, struct key_restrictionreturn keyring; } +struct key * + (*const keyring_alloc_fn_ptr)(const char *desc,struct key_restriction *restriction) = + clavis_keyring_alloc; +static struct key_restriction *clavis_restriction_alloc (key_restrict_link_func_t check_func) {struct key_restriction *restriction;
@@ -259,6 +281,10 @@ static struct key_restriction *clavis_restriction_alloc(key_restrict_link_func_treturn restriction; } +struct key_restriction * + (*const restriction_alloc_fn_ptr)(key_restrict_link_func_t + check_func) = clavis_restriction_alloc; +static void clavis_add_acl (const char *const *skid_list,struct key *keyring) {const char *const *acl;
@@ -284,6 +310,9 @@ static void clavis_add_acl(const char *const *skid_list, struct key *keyring) } } +void (*const clavis_add_acl_fn_ptr)(const char *const *skid_list, +struct key *keyring) = clavis_add_acl; +int __init clavis_keyring_init (void ) {struct key_restriction *restriction;
Signature · 1 line
2.45.0
Eric Snowberg
reviewerRFC PATCH v3 13/13 clavis: Kunit support
In reply to Eric SnowbergAdd Kunit coverage to Clavis.
The Makefile will generate multiple test vectors. All test vectors will end up in the x509.h, acl.h or signed_data.h file.
The clavis test vectors (ctv) include:
6 different x509 certs. One for each of the different key usage types. This will be loaded into the machine_kunit keyring.
ctv_0[x]_x509
1 x509 cert that will be used for revocations:
ctv_rev_x509
6 different Clavis ACL's. One for each usage type:
ctv_0[x]_x509_acl
2 different Clavis keys ctv_ca0_x509 and ctv_ca1_x509.
12 different PCKS7 signed Clavis ACLs.
6 signed by ctv_ca0:
ctv_ca0_0[x]_pkcs7
6 signed by ctv_ca1
ctv_ca1_0[x]_pkcs7
1 signed module (with random data) signed by a key in the module ACL:
ctv_module_ca0_signed
1 signed module (with random data) signed by a revoked key:
ctv_module_rev_signed
1 Unspecified data that is PKCS7 signed the key unspecified data ACL:
ctv_data_05_signed
The tests can be enabled through a new Kconfig: SECURITY_CLAVIS_KUNIT_TEST.
Run all KUnit tests for Clavis with:
./tools/testing/kunit/kunit.py run --kunitconfig security/clavis
The only areas missing are stubbing out EFI and system_key_link. Everything else should be covered with this patch.
--- security/clavis/.gitignore | 1 + security/clavis/.kunitconfig | 4 + security/clavis/Kconfig | 16 + security/clavis/Makefile | 132 ++++++++ security/clavis/clavis.h | 24 ++ security/clavis/clavis_test.c | 566 ++++++++++++++++++++++++++++++++++ 6 files changed, 743 insertions(+) create mode 100644 security/clavis/.kunitconfig create mode 100644 security/clavis/clavis_test.c
security/clavis/.gitignore +1 -0
@@ -1 +1,2 @@ /builtin_acl +/sign-file*
security/clavis/.kunitconfig new file +4 -0
@@ -0,0 +1,4 @@ +CONFIG_KUNIT=y +CONFIG_SECURITY=y +CONFIG_SECURITY_CLAVIS=y +CONFIG_SECURITY_CLAVIS_KUNIT_TEST=y
security/clavis/Kconfig +16 -0
@@ -19,3 +19,19 @@ config SECURITY_CLAVIS_ACL_LIST acl list into the kernel. The file contents must be in the following format: <two digit key usage number>:<subject key id>. If more than one entry is added, add a carriage return after each entry. + +config SECURITY_CLAVIS_KUNIT_TEST + bool "KUnit tests for Clavis" if !KUNIT_ALL_TESTS + depends on SECURITY_CLAVIS && KUNIT + default KUNIT_ALL_TESTS + select SYSTEM_BLACKLIST_KEYRING + select SYSTEM_REVOCATION_LIST + help + Build KUnit tests for Clavis. + + See the KUnit documentation in Documentation/dev-tools/kunit + + Run all KUnit tests for Clavis with: + ./tools/testing/kunit/kunit.py run --kunitconfig security/clavis + + If you are unsure how to answer this question, answer N.
security/clavis/Makefile +132 -0
141 lines not on this page · raw message
security/clavis/clavis.h +24 -0
@@ -35,4 +35,28 @@ static inline int __init clavis_efi_param(struct asymmetric_key_id *kid, int lenint __init clavis_keyring_init (void );int clavis_sig_verify (const struct key *key,const struct public_key_signature *sig); +#ifdef CONFIG_SECURITY_CLAVIS_KUNIT_TEST +extern void key_type_put (struct key_type *ktype); +extern struct key_type *key_type_lookup (const char *type); +extern long keyctl_update_key (key_serial_t id,const void __user *_payload,size_t plen); +extern struct key * (*const clavis_keyring_get_fn_ptr)(void ); +extern int (*const key_acl_preparse_fn_ptr)(struct key_preparsed_payload *prep); +extern void (*const clavis_add_acl_fn_ptr)(const char *const *skid_list,struct key *keyring); + +extern struct key * + (*const keyring_alloc_fn_ptr)(const char *desc,struct key_restriction *restriction); + +extern struct key_restriction * + (*const restriction_alloc_fn_ptr)(key_restrict_link_func_t check_func); + +extern struct asymmetric_key_id * + (*const parse_boot_param_fn_ptr)(char *kid,struct asymmetric_key_id *akid, +int akid_max_len); + +extern int + (*const pkcs7_preparse_content_fn_ptr)(void *ctx,const void *data,size_t len, +size_t asn1hdrlen); + +extern bool (*const clavis_acl_enforced_fn_ptr)(void ); +#endif #endif /* _SECURITY_CLAVIS_H_ */
security/clavis/clavis_test.c new file +566 -0
566 lines not on this page · raw message
Signature · 1 line
2.45.0
kernel test robot
build botRe: [RFC PATCH v3 13/13] clavis: Kunit support
kernel test robot noticed the following build errors:
Hi Eric,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on 8e929cb546ee42c9a61d24fae60605e9e3192354]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Snowberg/certs-Remove-CONFIG_INTEGRITY_PLATFORM_KEYRING-check/20241018-000510 base: 8e929cb546ee42c9a61d24fae60605e9e3192354 patch link: https://lore.kernel.org/r/20241017155516.2582369-14-eric.snowberg%40oracle.com patch subject: [RFC PATCH v3 13/13] clavis: Kunit support config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20241021/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241021/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: security/clavis/clavis_test.o: in function `clavis_parse_boot_param_tests':
>> clavis_test.c:(.text+0x287): undefined reference to `kunit_binary_ptr_assert_format' >> ld: clavis_test.c:(.text+0x295): undefined reference to `__kunit_do_failed_assertion' >> ld: clavis_test.c:(.text+0x2bf): undefined reference to `kunit_binary_ptr_assert_format' ld: clavis_test.c:(.text+0x2cd): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x2f7): undefined reference to `kunit_binary_ptr_assert_format' ld: clavis_test.c:(.text+0x305): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x32f): undefined reference to `kunit_binary_ptr_assert_format' ld: clavis_test.c:(.text+0x33d): undefined reference to `__kunit_do_failed_assertion' >> ld: clavis_test.c:(.text+0x375): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x383): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x3b5): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x3c3): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x3f5): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x403): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x435): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x443): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x475): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x483): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `clavis_test_keyring_init': >> clavis_test.c:(.text+0x580): undefined reference to `kunit_ptr_not_err_assert_format' ld: clavis_test.c:(.text+0x58e): undefined reference to `__kunit_do_failed_assertion' >> ld: clavis_test.c:(.text+0x5b0): undefined reference to `kunit_ptr_not_err_assert_format' ld: clavis_test.c:(.text+0x5be): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x5f5): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x603): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `unspecified_signed_tests': >> clavis_test.c:(.text+0x63f): undefined reference to `__kunit_activate_static_stub' >> ld: clavis_test.c:(.text+0x653): undefined reference to `__kunit_activate_static_stub' >> ld: clavis_test.c:(.text+0x7d9): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0x7e2): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0x834): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x842): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x874): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x882): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x8b4): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x8c2): undefined reference to `__kunit_do_failed_assertion' >> ld: clavis_test.c:(.text+0x8e4): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x8f2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x924): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x932): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x964): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x972): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `module_revocation_tests': clavis_test.c:(.text+0x9af): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0x9c3): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0xa86): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0xa8f): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0xadc): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xaea): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0xb24): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xb32): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `module_invalid_signed_tests': clavis_test.c:(.text+0xb6f): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0xb83): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0xd06): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0xd0f): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0xd5c): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xd6a): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0xda4): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xdb2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0xde4): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xdf2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0xe14): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0xe22): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0xe54): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0xe62): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `module_signed_tests': clavis_test.c:(.text+0xe9f): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0xeb3): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0x1033): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0x103c): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0x108c): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x109a): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x10d4): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x10e2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1114): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x1122): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1144): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x1152): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1184): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x1192): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `signed_acl_tests': clavis_test.c:(.text+0x13a1): undefined reference to `__kunit_activate_static_stub' ld: clavis_test.c:(.text+0x14d9): undefined reference to `kunit_deactivate_static_stub' ld: clavis_test.c:(.text+0x1519): undefined reference to `kunit_ptr_not_err_assert_format' ld: clavis_test.c:(.text+0x1527): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1551): undefined reference to `kunit_ptr_not_err_assert_format' ld: clavis_test.c:(.text+0x155f): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x158d): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x159b): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x15cd): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x15db): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x160d): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x161b): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1666): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x1674): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `register_key_type_tests': clavis_test.c:(.text+0x178e): undefined reference to `kunit_binary_ptr_assert_format' ld: clavis_test.c:(.text+0x179c): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x17e3): undefined reference to `kunit_binary_ptr_assert_format' ld: clavis_test.c:(.text+0x17f1): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `builtin_acl_tests': >> clavis_test.c:(.text+0x1955): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x1963): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1994): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x19a2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x19d4): undefined reference to `kunit_binary_assert_format' ld: clavis_test.c:(.text+0x19e2): undefined reference to `__kunit_do_failed_assertion' ld: clavis_test.c:(.text+0x1a04): undefined reference to `kunit_unary_assert_format' ld: clavis_test.c:(.text+0x1a12): undefined reference to `__kunit_do_failed_assertion' ld: security/clavis/clavis_test.o: in function `clavis_suite_init': >> clavis_test.c:(.text+0x1a8f): undefined reference to `kunit_log_append' ld: security/clavis/clavis_test.o: in function `key_acl_vet_description_tests': >> clavis_test.c:(.text+0x1d1f): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1d2d): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x1d88): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1d96): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x1df1): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1dff): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x1e5a): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1e68): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x1ec3): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1ed1): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x1f6f): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x1f7d): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x2020): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x202e): undefined reference to `__kunit_do_failed_assertion'
ld: clavis_test.c:(.text+0x204e): undefined reference to `kunit_unary_assert_format'
ld: clavis_test.c:(.text+0x205c): undefined reference to `__kunit_do_failed_assertion'
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Mimi Zohar
maintainerRe: [RFC PATCH v3 13/13] clavis: Kunit support
In reply to Eric Snowbergsecurity/clavis/Kconfig config SECURITY_CLAVIS_ACL_LIST · line 25
Quoted 3 lines · Eric Snowberg
security/clavis/Kconfig +3
-0+config SECURITY_CLAVIS_KUNIT_TEST + bool "KUnit tests for Clavis" if !KUNIT_ALL_TESTS + depends on SECURITY_CLAVIS && KUNIT
Change KUNIT -> KUNIT=y
security/clavis/Kconfig config SECURITY_CLAVIS_ACL_LIST · line 37
Quoted 12 lines
security/clavis/Kconfig +12
-0+ default KUNIT_ALL_TESTS + select SYSTEM_BLACKLIST_KEYRING + select SYSTEM_REVOCATION_LIST + help + Build KUnit tests for Clavis. + + See the KUnit documentation in Documentation/dev-tools/kunit + + Run all KUnit tests for Clavis with: + ./tools/testing/kunit/kunit.py run --kunitconfig security/clavis + + If you are unsure how to answer this question, answer N.
thanks,
Mimi
Mimi Zohar
maintainerQuoted 17 lines · Eric Snowberg
Motivation:
Each end-user has their own security threat model. What is important to one end-user may not be important to another. There is not a right or wrong threat model.
A common request made when adding new kernel changes that could impact the threat model around system kernel keys is to add additional
Kconfigoptions. As kernel developers, it is challenging to both add and keep track of all theKconfigoptions around security features that may limit or restrict system key usage. It is also difficult for a general purpose distro to take advantage of some of these features, since it may prevent some users from executing their workload.It is the author's belief that it is better left up to the end-user on how kernel keys should be used within their system.
Quoted 10 lines
Throughout the Linux kernel, key usage is tracked when doing signature verification with keys contained within one of the system keyrings; however, there isn't a way for the end-user to enforce this usage. This series gives the end-user the ability to configure key usage based on their threat model. Having the ability to enforce key usage also improves security by reducing the attack surface should a system key be compromised. It allows new features to be added without the need for additional
Kconfigoptions for fear of changing the end-user's threat model. It also allows a distro to build a kernel that suits various end-user's needs without resorting to selectingKconfigoptions with the least restrictive security options.
The motivation for this patch set is convincing and addresses limiting the usage of keys loaded directly or indirectly onto the system trusted keyrings - .builtin, .machine, and .secondary_trusted_keys keyrings. Pre-loading the build time ephemeral kernel module signing key is a nice improvement from the previous versions. My main concern is not with Clavis per-se, but that the LSM infrastructure allows configuring all the LSMs, but enabling at build time and modifying at runtime a subset of them. Without Clavis enabled, nothing changes
- any key on the system trusted keyrings remains usable for any purpose. With the current LSM design, the end user security threat model cannot be guaranteed.
Mimi
Quoted 176 lines
Solution:
This series introduces a new LSM called Clavis (Latin word meaning key). This LSM leaves it up to the end-user to determine what system keys they want to use and for what purpose.
The Clavis LSM adds the ability to do access control for all system keys. When enabled, until an ACL entry is added for a specific key, none of the system keys may be used for any type of verification purpose. When the kernel is built, typically kernel modules are signed with an ephemeral key, an ACL entry for the ephemeral key is pre-loaded, allowing the kernel modules to load during boot. At build time other ACL entries may also be included.
The Clavis LSM requires the end-user to have their own public key infrastructure (PKI). In order for a Clavis ACL entry to be added, the ACL must be signed by what is being called the Clavis key. The Clavis key is owned by the end-user. The Clavis public key can be contained within the machine keyring, or it can be added after the machine boots.
Not only is there a new Clavis key being introduced, but there is also a new .clavis keyring. The .clavis keyring contains a single Clavis key. It also contains any number of ACL entries that are signed by the Clavis key.
It is believed that the most common setup would be to have the Clavis key contained within the machine keyring. Enabling the Clavis LSM during boot is accomplished by passing in the asymmetric key id for the Clavis key within a new "clavis=" boot param. The asymmetric key id must match one already contained within any of the system keyrings. If a match is found, a link is created into the new .clavis keyring. This Clavis key shall be used as the root of trust for any keyring ACL updates afterwards.
On UEFI systems the "clavis" boot param is mirrored into a new UEFI variable within the EFI stub code. This variable will persist until the next reboot. This same type of functionality is done within shim. Since this variable is created before ExitBootServices (EBS) it will not have the NVRAM bit set, signifying it was created during the Boot Services phase. This is being used so the "clavis" boot param can not be changed via kexec, thereby preventing a pivot of the root of trust.
As mentioned earlier, this LSM introduces a new .clavis keyring. Following boot, no new keys can be added to this keyring and only the key designated via the initial boot param may be used. If the clavis boot param was not used, the LSM can be enabled afterwards using the keyctl command. The end-user may add their Clavis key into the .clavis keyring and the Clavis LSM shall be enabled.
The .clavis keyring also holds the access control list for system keys. A new key type called
clavis_key_aclis being introduced. This contains the usage followed by the asymmetric key id. To be added to the clavis keyring, theclavis_key_aclmust be S/MIME signed by the Clavis key. New ACL additions to the .clavis keyring may be added at any time.Currently this LSM does not require new changes or modifications to any user space tools. It also does not have a securityfs interface. Everything is done using the existing keyctl tool through the new .clavis keyring. The S/MIME signing can be done with a simple OpenSSL command. If additions or updates need to be added in the future, new ACL key types could be created. With this approach, maintainability should not be an issue in the future if missing items are identified.
Clavis must be configured at build time with
CONFIG_SECURITY_CLAVIS=y. The list of security modules enabled by default is set withCONFIG_LSM. The kernel configuration must containCONFIG_LSM=[...],claviswith [...] as the list of other security modules for the running system.For setup and usage instructions, a clavis admin-guide has been included in
Documentation/admin-guide/LSM/clavis.rst.Future enhancements to this LSM could include:
1. Subsystems that currently use system keys with
VERIFYING_UNSPECIFIED_SIGNATUREcould be updated with their specific usage type. For example, a usage type for IMA, BPF, etc could be added.2. Having the ability to allow platform keys to be on par with all other system keys when using this LSM. This would be useful for a user that controls their entire UEFI SB DB key chain and doesn't want to use MOK keys. This could also potentially remove the need for the machine keyring all together.
3. Some of the
Kconfigoptions around key usage and types could be deprecated.I would appreciate any feedback on this approach. Thanks.
Changes in v3:
Rebased to 6.12-rc3
Added Kunit test code
Preload an ACL in the clavis keyring with the ephemeral module signing key Preload user defined ACL data into the clavis keyring with build time data Changes to the second patch recommended by Jarkko
Reordered patches recommended by Mimi
Documentation improvements recommended by RandyChanges in v2:
Rebased to 6.10-rc1
Various cleanup in the first patch recommended by Jarkko Documentation improvements recommended by Randy Fixed lint warnings
Other cleanupEric Snowberg (13):
certs: RemoveCONFIG_INTEGRITY_PLATFORM_KEYRINGcheck
certs: Introduce ability to link to a system key
clavis: Introduce a new system keyring called clavis
keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)
clavis: Introduce a new key type calledclavis_key_acl
clavis: Populate clavis keyring acl with kernel module signature
keys: Add ability to track intended usage of the public key
clavis: Introduce new LSM called clavis
clavis: Allow user to define acl at build time
efi: Make clavis boot param persist across kexec
clavis: Prevent boot param change during kexec
clavis: Add function redirection for Kunit support
clavis: Kunit supportDocumentation/admin-guide/LSM/clavis.rst | 191 ++++++ .../admin-guide/kernel-parameters.txt | 6 + MAINTAINERS | 7 + certs/.gitignore | 1 + certs/Makefile | 20 + certs/blacklist.c | 3 + certs/clavis_module_acl.c | 7 + certs/system_keyring.c | 36 +- crypto/asymmetric_keys/asymmetric_type.c | 1 + crypto/asymmetric_keys/pkcs7_trust.c | 20 + crypto/asymmetric_keys/pkcs7_verify.c | 5 + crypto/asymmetric_keys/signature.c | 4 + drivers/firmware/efi/Kconfig | 12 + drivers/firmware/efi/libstub/Makefile | 1 + drivers/firmware/efi/libstub/clavis.c | 33 + .../firmware/efi/libstub/efi-stub-helper.c | 2 + drivers/firmware/efi/libstub/efi-stub.c | 2 + drivers/firmware/efi/libstub/efistub.h | 8 + drivers/firmware/efi/libstub/x86-stub.c | 2 + include/crypto/pkcs7.h | 3 + include/crypto/public_key.h | 4 + include/keys/system_keyring.h | 7 +- include/linux/efi.h | 1 + include/linux/integrity.h | 8 + include/linux/lsm_count.h | 8 +- include/linux/lsm_hook_defs.h | 2 + include/linux/security.h | 7 + include/linux/verification.h | 2 + include/uapi/linux/lsm.h | 1 + security/Kconfig | 11 +- security/Makefile | 1 + security/clavis/.gitignore | 2 + security/clavis/.kunitconfig | 4 + security/clavis/Kconfig | 37 ++ security/clavis/Makefile | 156 +++++ security/clavis/clavis.c | 26 + security/clavis/clavis.h | 62 ++ security/clavis/clavis_builtin_acl.c | 7 + security/clavis/clavis_efi.c | 50 ++ security/clavis/clavis_keyring.c | 426 +++++++++++++ security/clavis/clavis_test.c | 566 ++++++++++++++++++ security/integrity/iint.c | 2 + security/security.c | 13 + .../selftests/lsm/lsm_list_modules_test.c | 3 + 44 files changed, 1757 insertions(+), 13 deletions(-) create mode 100644 Documentation/admin-guide/LSM/clavis.rst create mode 100644 certs/clavis_module_acl.c create mode 100644 drivers/firmware/efi/libstub/clavis.c create mode 100644 security/clavis/.gitignore create mode 100644 security/clavis/.kunitconfig create mode 100644 security/clavis/Kconfig create mode 100644 security/clavis/Makefile create mode 100644 security/clavis/clavis.c create mode 100644 security/clavis/clavis.h create mode 100644 security/clavis/clavis_builtin_acl.c create mode 100644 security/clavis/clavis_efi.c create mode 100644 security/clavis/clavis_keyring.c create mode 100644 security/clavis/clavis_test.cbase-commit:
8e929cb546ee42c9a61d24fae60605e9e3192354
Eric Snowberg
reviewerHi Mimi,
Quoted 31 lines · Mimi Zohar
Quoted 17 lines · Eric Snowberg
Motivation:
Each end-user has their own security threat model. What is important to one end-user may not be important to another. There is not a right or wrong threat model.
A common request made when adding new kernel changes that could impact the threat model around system kernel keys is to add additional
Kconfigoptions. As kernel developers, it is challenging to both add and keep track of all theKconfigoptions around security features that may limit or restrict system key usage. It is also difficult for a general purpose distro to take advantage of some of these features, since it may prevent some users from executing their workload.It is the author's belief that it is better left up to the end-user on how kernel keys should be used within their system.
Quoted 10 lines
Throughout the Linux kernel, key usage is tracked when doing signature verification with keys contained within one of the system keyrings; however, there isn't a way for the end-user to enforce this usage. This series gives the end-user the ability to configure key usage based on their threat model. Having the ability to enforce key usage also improves security by reducing the attack surface should a system key be compromised. It allows new features to be added without the need for additional
Kconfigoptions for fear of changing the end-user's threat model. It also allows a distro to build a kernel that suits various end-user's needs without resorting to selectingKconfigoptions with the least restrictive security options.
Quoted 5 lines
The motivation for this patch set is convincing and addresses limiting the usage of keys loaded directly or indirectly onto the system trusted keyrings - .builtin, .machine, and .secondary_trusted_keys keyrings. Pre-loading the build time ephemeral kernel module signing key is a nice improvement from the previous versions.
Apologies for the delayed response and thanks for your feedback on this and the other patches you reviewed in the series.
Quoted 5 lines
My main concern is not with Clavis per-se, but that the LSM infrastructure allows configuring all the LSMs, but enabling at build time and modifying at runtime a subset of them. Without Clavis enabled, nothing changes
- any key on the system trusted keyrings remains usable for any purpose. With the current LSM design, the end user security threat model cannot be guaranteed.
I went in the direction of creating a new LSM based on this discussion [1]. I was hoping to get some feedback from Paul, since I believe I have addressed the guidelines for a new LSM. Currently, the Clavis LSM only adds a single LSM hook. To address your concern, maybe Clavis shouldn't be a LSM? Possibly it could live in the keyring code on its own.
Paul Moore
maintainerQuoted 1 line · Eric Snowberg
Quoted 1 line · Mimi Zohar
...
Quoted 11 lines
Quoted 5 lines
My main concern is not with Clavis per-se, but that the LSM infrastructure allows configuring all the LSMs, but enabling at build time and modifying at runtime a subset of them. Without Clavis enabled, nothing changes
- any key on the system trusted keyrings remains usable for any purpose. With the current LSM design, the end user security threat model cannot be guaranteed.I went in the direction of creating a new LSM based on this discussion [1]. I was hoping to get some feedback from Paul, since I believe I have addressed the guidelines for a new LSM. Currently, the Clavis LSM only adds a single LSM hook. To address your concern, maybe Clavis shouldn't be a LSM? Possibly it could live in the keyring code on its own.
My turn to apologize for a very late reply, you've been very patient and I appreciate that.
With respect to Mimi's concerns about disabling Clavis, or any LSM for that matter, at runtime, doing so requires the ability to modify the kernel's command line. I would argue that if a user can manipulate the kernel command line there are more serious issues that need to be dealt with first. Any user who is seriously concerned about the state of their system should have some mechanism in place to ensure that the kernel command line is not subject to tampering; thankfully there are efforts underway to help bring tamper resistant command lines to a larger audience (the UKI work).
I can't remember if anyone has ever brought this up on-list, and if so what objections there may have been, but I've always wondered if the real problem is simply that we use a handful of keyrings for far too many things inside the kernel. What terrible things would need to be overcome if we created additional keyrings based on usage, e.g. ".modulesigning", and used these task specific keyrings instead of the existing source/trust oriented keyrings? I imagine we would likely need some mechanism to link a key from the existing source/trust keyrings, e.g. ".machine", to a task specific keyring, e.g. ".modulesigning", but I can't imagine that would be too difficult.
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this? Were they supportive of the idea, but simply felt it was better as an LSM? I see Jarkko has reviewed and commented on a number of the patches, so I'll take that as an implicit acceptance of the concept, but have you heard anything from David?
Signature · 1 line
paul-moore.com
Paul Moore
maintainerQuoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
That's my current thinking, and why I asked about locating Clavis in the keys subsystem directly (although I still think better keyring granularity and a shift towards usage based keyrings is the better option). If David and Jarkko are opposed to integrating Clavis into the keys subsystem we can consider this as a LSM, I'm just not sure it's the best first option. Does that make sense?
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 25 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Quoted 6 lines
That's my current thinking, and why I asked about locating Clavis in the keys subsystem directly (although I still think better keyring granularity and a shift towards usage based keyrings is the better option). If David and Jarkko are opposed to integrating Clavis into the keys subsystem we can consider this as a LSM, I'm just not sure it's the best first option. Does that make sense?
Thanks for your feedback Paul. I have no preference if it is a new LSM or not. My interest is finding the path of least resistance to get this type of capability added to mainline code. Hopefully David and Jarkko will provide their opinions.
Mimi Zohar
maintainerQuoted 14 lines · Eric Snowberg
Quoted 14 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
Quoted 9 lines
Quoted 9 lines
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Hi Jarkko, David,
Both Paul's and my main concerns with this patch set is storing policy in the keyring. We would appreciate your chiming in here about storing key policy in the keyring itself.
thanks,
Mimi
Quoted 12 lines
Quoted 7 lines
That's my current thinking, and why I asked about locating Clavis in the keys subsystem directly (although I still think better keyring granularity and a shift towards usage based keyrings is the better option). If David and Jarkko are opposed to integrating Clavis into the keys subsystem we can consider this as a LSM, I'm just not sure it's the best first option. Does that make sense?
Thanks for your feedback Paul. I have no preference if it is a new LSM or not. My interest is finding the path of least resistance to get this type of capability added to mainline code. Hopefully David and Jarkko will provide their opinions.
Paul Moore
maintainerQuoted 23 lines · Mimi Zohar
Quoted 12 lines · Eric Snowberg
Quoted 12 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
Quoted 9 lines
Quoted 9 lines
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Quoted 5 lines
Hi Jarkko, David,
Both Paul's and my main concerns with this patch set is storing policy in the keyring. We would appreciate your chiming in here about storing key policy in the keyring itself.
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Signature · 1 line
paul-moore.com
Mimi Zohar
maintainerQuoted 30 lines · Paul Moore
Quoted 23 lines · Mimi Zohar
Quoted 12 lines · Eric Snowberg
Quoted 12 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
Quoted 9 lines
Quoted 9 lines
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Quoted 5 lines
Hi Jarkko, David,
Both Paul's and my main concerns with this patch set is storing policy in the keyring. We would appreciate your chiming in here about storing key policy in the keyring itself.
Quoted 7 lines
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The proliferation of keyrings won't solve the key usage problem for IMA- appraisal. IMA-appraisal can be used to verify the kexec image, kernel modules, firwmare, etc, but it also verifies file signatures contained in userspace packages. To support the latter case, keyrings would need to be application specific. (This version of Clavis doesn't solve the latter key usage for IMA- appraisal either.)
The keys baked into the kernel are trusted because the kernel itself was signed and verified (secure boot). Anyone building a kernel can build a key into the kernel image, which establishes a "root of trust". That key can then be used to verify and load other keys onto the IMA keyring.
The problem is how to safely establish a root of trust without baking the key into the kernel image and then limiting that trust to specific usages or applications.
Mimi
Paul Moore
maintainerQuoted 10 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Quoted 4 lines
The proliferation of keyrings won't solve the key usage problem for IMA- appraisal. IMA-appraisal can be used to verify the kexec image, kernel modules, firwmare, etc, but it also verifies file signatures contained in userspace packages.
To be clear I don't think the usage oriented keyring idea will solve every keyring problem, but it seems like it solves a fair number of things that I've heard lately.
Quoted 3 lines
To support the latter case, keyrings would need to be application
specific. (This version of Clavis doesn't solve the latter key usage for IMA- appraisal either.)
Application specific keyrings are more-or-less what I've been trying to describe.
Quoted 4 lines
The keys baked into the kernel are trusted because the kernel itself was signed and verified (secure boot). Anyone building a kernel can build a key into the kernel image, which establishes a "root of trust". That key can then be used to verify and load other keys onto the IMA keyring.
Sure, I'm not saying that trust isn't important, and that there are varying levels of trust. My argument is that having additional, usage/application oriented keyrings which contain links back to keys imported and stored in the traditional trust oriented keyrings could neatly solve a number of keyring access control issues.
Quoted 3 lines
The problem is how to safely establish a root of trust without baking the key into the kernel image and then limiting that trust to specific usages or applications.
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Signature · 1 line
paul-moore.com
Mimi Zohar
maintainerQuoted 20 lines · Paul Moore
Quoted 10 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Quoted 4 lines
The proliferation of keyrings won't solve the key usage problem for IMA- appraisal. IMA-appraisal can be used to verify the kexec image, kernel modules, firwmare, etc, but it also verifies file signatures contained in userspace packages.
To be clear I don't think the usage oriented keyring idea will solve every keyring problem, but it seems like it solves a fair number of things that I've heard lately.
Quoted 6 lines
Quoted 3 lines
To support the latter case, keyrings would need to be application
specific. (This version of Clavis doesn't solve the latter key usage for IMA- appraisal either.)Application specific keyrings are more-or-less what I've been trying to describe.
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 16 lines
Quoted 5 lines
The keys baked into the kernel are trusted because the kernel itself was signed and verified (secure boot). Anyone building a kernel can build a key into the kernel image, which establishes a "root of trust". That key can then be used to verify and load other keys onto the IMA keyring.
Sure, I'm not saying that trust isn't important, and that there are varying levels of trust. My argument is that having additional, usage/application oriented keyrings which contain links back to keys imported and stored in the traditional trust oriented keyrings could neatly solve a number of keyring access control issues.
Quoted 3 lines
The problem is how to safely establish a root of trust without baking the key into the kernel image and then limiting that trust to specific usages or applications.
Quoted 7 lines
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Clavis defined both a mechanism for establishing trust and access control rules.
Clavis defined a single Clavis key to establish trust. The Clavis policy rules were signed by the Clavis key. The Clavis policy rules defined the access control.
Mimi
Paul Moore
maintainerQuoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 8 lines
Quoted 7 lines
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Quoted 5 lines
Clavis defined both a mechanism for establishing trust and access control rules.
Clavis defined a single Clavis key to establish trust. The Clavis policy rules were signed by the Clavis key. The Clavis policy rules defined the access control.
Unfortunately I think we're getting a little ambiguous with how we are using the word "trust". Just as "security" can mean different things depending on context, so can "trust" as the qualities we are trusting will vary depending on context. I'll leave it at that for now as I believe we are talking about different things in the paragraphs above.
Regardless, I'll also say this regarding Clavis and key/keyring access controls - as implemented, Clavis doesn't look like a LSM to me for the reasons already given. If all of the various keys subsystem maintainers believe it is the Right Thing To Do inside the keys subsystem then it isn't my place to have a say in that. I personally believe that doing the work to support usage oriented keyrings before, or while, implementing a Clavis-like mechanism is the better option, but that is a decision for you and the other key maintainers.
Signature · 1 line
paul-moore.com
Mimi Zohar
maintainerQuoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys. Only a particular key should be used to verify the file signatures for a particular application. The scenarios, described above, are the ratio of distro/single entity vs. non distro/single entity signed packages, which would correspond to the number of keyrings.
Clavis limits key usage based on LSM hooks (e.g. kernel modules, kernel image, firmware, etc). It's a good start, but even this probably is not fine enough granularity.
Quoted 21 lines
Quoted 9 lines
Quoted 8 lines
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Quoted 5 lines
Clavis defined both a mechanism for establishing trust and access control rules.
Clavis defined a single Clavis key to establish trust. The Clavis policy rules were signed by the Clavis key. The Clavis policy rules defined the access control.
Unfortunately I think we're getting a little ambiguous with how we are using the word "trust". Just as "security" can mean different things depending on context, so can "trust" as the qualities we are trusting will vary depending on context. I'll leave it at that for now as I believe we are talking about different things in the paragraphs above.
Quoted 8 lines
Regardless, I'll also say this regarding Clavis and key/keyring access controls - as implemented, Clavis doesn't look like a LSM to me for the reasons already given. If all of the various keys subsystem maintainers believe it is the Right Thing To Do inside the keys subsystem then it isn't my place to have a say in that. I personally believe that doing the work to support usage oriented keyrings before, or while, implementing a Clavis-like mechanism is the better option, but that is a decision for you and the other key maintainers.
"Usage oriented keyrings" similarly implies any key on a particular keyring is acceptable. Without understanding what you mean by "usage oriented keyrings", I would assume it would work initially, but eventually it too will not be fine enough granularity.
Mimi
Paul Moore
maintainerQuoted 30 lines · Mimi Zohar
Quoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 2 lines
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys.
Yep.
Quoted 3 lines
Only a
particular key should be used to verify the file signatures for a particular application.
That's definitely one access control policy, but I can also envision a scenario where I have just one keyring for application signatures with multiple keys from multiple vendors.
Quoted 3 lines
Clavis limits key usage based on LSM hooks (e.g. kernel modules, kernel image, firmware, etc). It's a good start, but even this probably is not fine enough granularity.
Which is fine, but like I said earlier, it makes far more sense to me to move towards usage oriented keyrings and then apply whatever additional access control granularity is required to meet a given scenario.
It's also worth (re)mentioning that what makes Clavis not-a-LSM in my mind is how it is implemented, not necessarily its security goals. If Clavis were to be implemented in such a way that it only relied on security/LSM blobs and not keys/keyrings it might be more suitable.
Quoted 29 lines
Quoted 20 lines
Quoted 8 lines
Quoted 7 lines
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Quoted 5 lines
Clavis defined both a mechanism for establishing trust and access control rules.
Clavis defined a single Clavis key to establish trust. The Clavis policy rules were signed by the Clavis key. The Clavis policy rules defined the access control.
Unfortunately I think we're getting a little ambiguous with how we are using the word "trust". Just as "security" can mean different things depending on context, so can "trust" as the qualities we are trusting will vary depending on context. I'll leave it at that for now as I believe we are talking about different things in the paragraphs above.
Quoted 8 lines
Regardless, I'll also say this regarding Clavis and key/keyring access controls - as implemented, Clavis doesn't look like a LSM to me for the reasons already given. If all of the various keys subsystem maintainers believe it is the Right Thing To Do inside the keys subsystem then it isn't my place to have a say in that. I personally believe that doing the work to support usage oriented keyrings before, or while, implementing a Clavis-like mechanism is the better option, but that is a decision for you and the other key maintainers.
Quoted 2 lines
"Usage oriented keyrings" similarly implies any key on a particular keyring is acceptable.
Yep.
Quoted 3 lines
Without understanding what you mean by "usage oriented keyrings", I would assume it would work initially, but eventually it too will not be fine enough granularity.
It all depends on what your goals are, but like I said above, it really seems to me like this is a good first step which can be followed up with additional granularity.
Signature · 1 line
paul-moore.com
Mimi Zohar
maintainerQuoted 36 lines · Paul Moore
Quoted 30 lines · Mimi Zohar
Quoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 2 lines
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys.
Yep.
Quoted 7 lines
Quoted 3 lines
Only a
particular key should be used to verify the file signatures for a particular application.That's definitely one access control policy, but I can also envision a scenario where I have just one keyring for application signatures with multiple keys from multiple vendors.
Having a single keyring with keys from multiple software vendors is the status quo.
Quoted 9 lines
Quoted 4 lines
Clavis limits key usage based on LSM hooks (e.g. kernel modules, kernel image, firmware, etc). It's a good start, but even this probably is not fine enough granularity.
Which is fine, but like I said earlier, it makes far more sense to me to move towards usage oriented keyrings and then apply whatever additional access control granularity is required to meet a given scenario.
Since you didn't agree with my example of "usage oriented keyrings", please provide an example.
Quoted 40 lines
It's also worth (re)mentioning that what makes Clavis not-a-LSM in my mind is how it is implemented, not necessarily its security goals. If Clavis were to be implemented in such a way that it only relied on
security/LSMblobs and not keys/keyrings it might be more suitable.Quoted 29 lines
Quoted 20 lines
Quoted 8 lines
Quoted 7 lines
My takeaway from Clavis was that it was more about establishing a set of access controls around keys already present in the keyrings and my comments about usage/spplication oriented keyrings have been in that context. While the access control policy, regardless of how it is implemented, should no doubt incorporate the trust placed in the individual keys, how that trust is established is a separate issue from access control as far as I'm concerned.
Quoted 5 lines
Clavis defined both a mechanism for establishing trust and access control rules.
Clavis defined a single Clavis key to establish trust. The Clavis policy rules were signed by the Clavis key. The Clavis policy rules defined the access control.
Unfortunately I think we're getting a little ambiguous with how we are using the word "trust". Just as "security" can mean different things depending on context, so can "trust" as the qualities we are trusting will vary depending on context. I'll leave it at that for now as I believe we are talking about different things in the paragraphs above.
Quoted 8 lines
Regardless, I'll also say this regarding Clavis and key/keyring access controls - as implemented, Clavis doesn't look like a LSM to me for the reasons already given. If all of the various keys subsystem maintainers believe it is the Right Thing To Do inside the keys subsystem then it isn't my place to have a say in that. I personally believe that doing the work to support usage oriented keyrings before, or while, implementing a Clavis-like mechanism is the better option, but that is a decision for you and the other key maintainers.
Quoted 2 lines
"Usage oriented keyrings" similarly implies any key on a particular keyring is acceptable.
Yep.
Quoted 7 lines
Quoted 3 lines
Without understanding what you mean by "usage oriented keyrings", I would assume it would work initially, but eventually it too will not be fine enough granularity.
It all depends on what your goals are, but like I said above, it really seems to me like this is a good first step which can be followed up with additional granularity.
Without a concrete example of "usage oriented keyrings", it's hard to understand why "additional" granularity should be deferred. From my perspective, "additional" granularity is the main issue.
Mimi
Paul Moore
maintainerQuoted 41 lines · Mimi Zohar
Quoted 40 lines · Paul Moore
Quoted 30 lines · Mimi Zohar
Quoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 2 lines
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys.
Yep.
Quoted 3 lines
Only a
particular key should be used to verify the file signatures for a particular application.
Quoted 6 lines
Quoted 3 lines
That's definitely one access control policy, but I can also envision a scenario where I have just one keyring for application signatures with multiple keys from multiple vendors.
Having a single keyring with keys from multiple software vendors is the status quo.
A single keyring with keys from multiple vendors does happen today yes, but there is no separation based on how those keys are used, e.g. separate application signature and kernel module signature keyrings.
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Clavis limits key usage based on LSM hooks (e.g. kernel modules, kernel image, firmware, etc). It's a good start, but even this probably is not fine enough granularity.
Which is fine, but like I said earlier, it makes far more sense to me to move towards usage oriented keyrings and then apply whatever additional access control granularity is required to meet a given scenario.
Since you didn't agree with my example of "usage oriented keyrings", please provide an example.
I have.
Signature · 1 line
paul-moore.com
Mimi Zohar
maintainerQuoted 46 lines · Paul Moore
Quoted 45 lines · Mimi Zohar
Quoted 43 lines · Paul Moore
Quoted 30 lines · Mimi Zohar
Quoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 2 lines
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys.
Yep.
Quoted 3 lines
Only a
particular key should be used to verify the file signatures for a particular application.That's definitely one access control policy, but I can also envision a scenario where I have just one keyring for application signatures with multiple keys from multiple vendors.
Quoted 6 lines
Quoted 2 lines
Having a single keyring with keys from multiple software vendors is the status quo.
A single keyring with keys from multiple vendors does happen today yes, but there is no separation based on how those keys are used, e.g. separate application signature and kernel module signature keyrings.
As soon as you add multiple vendors keys on the kernel module signature keyring, you'll need finer grained access control.
Mimi
Paul Moore
maintainerQuoted 50 lines · Mimi Zohar
Quoted 49 lines · Paul Moore
Quoted 47 lines · Mimi Zohar
Quoted 36 lines · Paul Moore
Quoted 30 lines · Mimi Zohar
Quoted 21 lines · Paul Moore
Quoted 3 lines · Mimi Zohar
Quoted 2 lines · Paul Moore
Quoted 1 line · Mimi Zohar
On Thu, 2025-02-27 at 17:22 -0500, Paul Moore wrote:
...
Quoted 5 lines
Ok, let's go through different scenarios to see if it would scale.
Scenario 1: Mostly distro signed userspace applications, minimum number of developer, customer, 3rd party applications.
Quoted 8 lines
Scenario 2: Multiple developer, customer, 3rd party applications, signed by the same party.
Scenario 3: extreme case - every application signed by different party.
With the minimum case, there would probably be a default key or sets of permissible keys. In the extreme case, the number of keyrings would be equivalent to the number of application/software packages.
Quoted 7 lines
Perhaps we're not understanding each other, but my understanding of the above three scenarios is that they are all examples of signed applications where something (likely something in the kernel like IMA) verifies the signature on the application. While there are going to be differing numbers of keys in each of the three scenarios, I believe they would all be on/linked-to the same usage oriented keyring as they all share the same usage: application signatures.
Quoted 2 lines
Yes they're all verifying file signatures, but the software packages are from different sources (e.g. distro, chrome), signed by different keys.
Yep.
Quoted 7 lines
Quoted 3 lines
Only a
particular key should be used to verify the file signatures for a particular application.That's definitely one access control policy, but I can also envision a scenario where I have just one keyring for application signatures with multiple keys from multiple vendors.
Having a single keyring with keys from multiple software vendors is the status quo.
Quoted 6 lines
Quoted 3 lines
A single keyring with keys from multiple vendors does happen today yes, but there is no separation based on how those keys are used, e.g. separate application signature and kernel module signature keyrings.
As soon as you add multiple vendors keys on the kernel module signature keyring, you'll need finer grained access control.
Maybe. It depends on your security policy, some solutions might be okay with keyring level access control granularity, others may want finer grained control.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 7 lines · Paul Moore
Quoted 2 lines · Mimi Zohar
Quoted 1 line · Paul Moore
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
Quoted 22 lines
Quoted 5 lines
The proliferation of keyrings won't solve the key usage problem for IMA- appraisal. IMA-appraisal can be used to verify the kexec image, kernel modules, firwmare, etc, but it also verifies file signatures contained in userspace packages.
To be clear I don't think the usage oriented keyring idea will solve every keyring problem, but it seems like it solves a fair number of things that I've heard lately.
Quoted 3 lines
To support the latter case, keyrings would need to be application specific. (This version of Clavis doesn't solve the latter key usage for IMA- appraisal either.)
Application specific keyrings are more-or-less what I've been trying to describe.
Quoted 4 lines
The keys baked into the kernel are trusted because the kernel itself was signed and verified (secure boot). Anyone building a kernel can build a key into the kernel image, which establishes a "root of trust". That key can then be used to verify and load other keys onto the IMA keyring.
Quoted 5 lines
Sure, I'm not saying that trust isn't important, and that there are varying levels of trust. My argument is that having additional, usage/application oriented keyrings which contain links back to keys imported and stored in the traditional trust oriented keyrings could neatly solve a number of keyring access control issues.
I'm not sure I completely follow this. If a user space application wants to use system kernel keys in this manner, can't this be done today? (I'm not talking about IMA here). The keyctl has both the "link" and "restrict_keyring".
Or do you mean take things further with Clavis? Meaning when usage is setup for a key, it is then populated in a new usage based keyring?
Paul Moore
maintainerQuoted 12 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Quoted 7 lines
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 25 lines · Paul Moore
Quoted 12 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Quoted 7 lines
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Paul Moore
maintainerQuoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 36 lines · Paul Moore
Quoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Quoted 6 lines
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
These keys are used by the Lockdown LSM to provide signature validation.
I realize the contents that follow in this paragraph is outside the boundary of mainline kernel code. Every distro that wants their shim signed must explain how their kernel enforces lockdown mode. The minimum requirement is lockdown in integrity mode. Also, the expectation is lockdown enforcement continues on through a kexec.
When in lockdown integrity mode, features that allow the kernel to be modified at runtime are disabled. How would what you have suggested above adhere to these goals?
The point of the Clavis LSM is to use the root of trust provided to the kernel prior to it booting. This maintains the lockdown integrity goals, while also giving the end-user the ability to determine how kernel keys are used.
Paul Moore
maintainerQuoted 43 lines · Eric Snowberg
Quoted 33 lines · Paul Moore
Quoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Quoted 6 lines
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
These keys are used by the Lockdown LSM to provide signature validation.
Quoted 6 lines
I realize the contents that follow in this paragraph is outside the boundary of mainline kernel code. Every distro that wants their shim signed must explain how their kernel enforces lockdown mode. The minimum requirement is lockdown in integrity mode. Also, the expectation is lockdown enforcement continues on through a kexec.
I personally find it very amusing the UEFI Secure Boot shim is reliant on an unmaintained and only marginally supported LSM, Lockdown. Has anyone recently verified that Lockdown's protections are still intact and comprehensive enough to be worthwhile? Sorry, this is a bit of a digression, but since you were the one to bring up Lockdown I thought it would be important to mention that I don't have much faith that it is still working to the same level as it originally was intended. I have a TODO list item to draft a policy around deprecating unmaintained LSMs after an extended period of time, and once that is in place if we don't have a qualified maintainer for Lockdown it will likely fall into the deprecation process (whatever that may be).
Quoted 3 lines
When in lockdown integrity mode, features that allow the kernel to be modified at runtime are disabled. How would what you have suggested above adhere to these goals?
For starters, verify that Lockdown is still comprehensive enough to satisfy these requirements on a modern Linux kernel. After that has been done, find someone with some kernel experience to step up and maintain Lockdown. Finally, put a mechanism in place so that someone/something is regularly evaluating changes in the upstream kernel to ensure that Lockdown is still able to achieve its security goals.
After all that, then you can start worrying about keys.
Quoted 4 lines
The point of the Clavis LSM is to use the root of trust provided to the kernel prior to it booting. This maintains the lockdown integrity goals, while also giving the end-user the ability to determine how kernel keys are used.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 55 lines · Paul Moore
Quoted 43 lines · Eric Snowberg
Quoted 33 lines · Paul Moore
Quoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Quoted 6 lines
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
These keys are used by the Lockdown LSM to provide signature validation.
Quoted 6 lines
I realize the contents that follow in this paragraph is outside the boundary of mainline kernel code. Every distro that wants their shim signed must explain how their kernel enforces lockdown mode. The minimum requirement is lockdown in integrity mode. Also, the expectation is lockdown enforcement continues on through a kexec.
Quoted 11 lines
I personally find it very amusing the UEFI Secure Boot shim is reliant on an unmaintained and only marginally supported LSM, Lockdown. Has anyone recently verified that Lockdown's protections are still intact and comprehensive enough to be worthwhile? Sorry, this is a bit of a digression, but since you were the one to bring up Lockdown I thought it would be important to mention that I don't have much faith that it is still working to the same level as it originally was intended. I have a TODO list item to draft a policy around deprecating unmaintained LSMs after an extended period of time, and once that is in place if we don't have a qualified maintainer for Lockdown it will likely fall into the deprecation process (whatever that may be).
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
Paul Moore
maintainerQuoted 65 lines · Eric Snowberg
Quoted 53 lines · Paul Moore
Quoted 43 lines · Eric Snowberg
Quoted 33 lines · Paul Moore
Quoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Quoted 6 lines
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
These keys are used by the Lockdown LSM to provide signature validation.
Quoted 6 lines
I realize the contents that follow in this paragraph is outside the boundary of mainline kernel code. Every distro that wants their shim signed must explain how their kernel enforces lockdown mode. The minimum requirement is lockdown in integrity mode. Also, the expectation is lockdown enforcement continues on through a kexec.
Quoted 11 lines
I personally find it very amusing the UEFI Secure Boot shim is reliant on an unmaintained and only marginally supported LSM, Lockdown. Has anyone recently verified that Lockdown's protections are still intact and comprehensive enough to be worthwhile? Sorry, this is a bit of a digression, but since you were the one to bring up Lockdown I thought it would be important to mention that I don't have much faith that it is still working to the same level as it originally was intended. I have a TODO list item to draft a policy around deprecating unmaintained LSMs after an extended period of time, and once that is in place if we don't have a qualified maintainer for Lockdown it will likely fall into the deprecation process (whatever that may be).
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
--
paul-moore.com
Eric Snowberg
reviewerQuoted 70 lines · Paul Moore
Quoted 65 lines · Eric Snowberg
Quoted 64 lines · Paul Moore
Quoted 43 lines · Eric Snowberg
Quoted 33 lines · Paul Moore
Quoted 22 lines · Eric Snowberg
Quoted 22 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could you further clarify how a usage oriented keyring would work? For example, if a kernel module keyring was added, how would the end-user add keys to it while maintaining a root of trust?
Quoted 6 lines
Consider it an exercise left to the reader :)
I imagine there are different ways one could do that, either using traditional user/group/capability permissions and/or LSM permissions, it would depend on the environment and the security goals of the overall system.
These keys are used by the Lockdown LSM to provide signature validation.
Quoted 6 lines
I realize the contents that follow in this paragraph is outside the boundary of mainline kernel code. Every distro that wants their shim signed must explain how their kernel enforces lockdown mode. The minimum requirement is lockdown in integrity mode. Also, the expectation is lockdown enforcement continues on through a kexec.
I personally find it very amusing the UEFI Secure Boot shim is reliant on an unmaintained and only marginally supported LSM, Lockdown. Has anyone recently verified that Lockdown's protections are still intact and comprehensive enough to be worthwhile? Sorry, this is a bit of a digression, but since you were the one to bring up Lockdown I thought it would be important to mention that I don't have much faith that it is still working to the same level as it originally was intended. I have a TODO list item to draft a policy around deprecating unmaintained LSMs after an extended period of time, and once that is in place if we don't have a qualified maintainer for Lockdown it will likely fall into the deprecation process (whatever that may be).
Quoted 4 lines
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
Based on your previous lockdown comments, I thought you might have some new information. Having lockdown enforcement has always been a requirement to get a shim signed by Microsoft.
The alternative "usage-oriented keyring" approach you've suggested wouldn't align with the threat model that lockdown aims to achieve. For a distro-based kernel, I don't see the value in pursuing such an approach. For someone compiling their own kernel and not using a distro kernel, they could compile in their own keys. With Clavis, I attempted to develop an approach that would meet the lockdown threat model requirements while allowing the end user to control key usage as they deem fit.
Paul Moore
maintainerQuoted 2 lines · Eric Snowberg
Quoted 2 lines · Paul Moore
On March 6, 2025 5:29:36 PM Eric Snowberg <[email protected]> wrote:
...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
Based on your previous lockdown comments, I thought you might have some new information. Having lockdown enforcement has always been a requirement to get a shim signed by Microsoft.
I want to address two things, the first, and most important, is that while I am currently employed by Microsoft, I do not speak for Microsoft and the decisions and actions I take as an upstream Linux kernel maintainer are not vetted by Microsoft in any way. I think you will find that many upstream kernel maintainers operate in a similar way for a variety of very good reasons.
The second issue is that my main focus is on ensuring we have a secure, safe, and well maintained LSM subsystem within the upstream Linux kernel. While I do care about downstream efforts, e.g. UEFI Secure Boot, those efforts are largely outside the scope of the upstream Linux kernel and not my first concern. If the developer groups who are focused on things like UEFI SB want to rely on functionality within the upstream Linux kernel they should be prepared to stand up and contribute/maintain those features or else they may go away at some point in the future. In very blunt terms, contribute upstream or Lockdown dies.
However, let me be clear that I consider deprecation and removal of a LSM to be an option of last resort. My preference would be to find a capable maintainer, or two, that would be willing to take on a maintenance role for the LSM in question. Luckily I think we may have some people who are interested in doing so for the Lockdown LSM, hopefully you'll see something on-list in the near future.
Quoted 2 lines
The alternative "usage-oriented keyring" approach you've suggested wouldn't align with the threat model that lockdown aims to achieve.
That's a Lockdown problem, or more specifically a problem for the people who are freeloading on the Lockdown LSM and expecting it to be maintained without contributing anything meaningful.
Quoted 2 lines
For
a distro-based kernel, I don't see the value in pursuing such an approach.
So you've said. I disagree, but we've already had that discussion, let's agree to not waste any more time repeating ourselves.
Quoted 3 lines
With Clavis, I attempted to develop
an approach that would meet the lockdown threat model requirements while allowing the end user to control key usage as they deem fit.
As mentioned previously, the design/implementation choices you made for Clavis means it is better suited for inclusion in the key subsystem and not as a standalone LSM. If you wanted to redesign/rework Clavis to stick to the traditional LSM security blobs perhaps that is something we could consider as a LSM, but it's probably worth seeing if David and Jarkko have any interest in including Clavis functionality in the key subsystem first.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 18 lines · Paul Moore
Quoted 2 lines · Eric Snowberg
Quoted 2 lines · Paul Moore
On March 6, 2025 5:29:36 PM Eric Snowberg <[email protected]> wrote:
...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
Based on your previous lockdown comments, I thought you might have some new information. Having lockdown enforcement has always been a requirement to get a shim signed by Microsoft.
...
Quoted 7 lines
Quoted 3 lines
The alternative "usage-oriented keyring" approach you've suggested wouldn't align with the threat model that lockdown aims to achieve.
That's a Lockdown problem, or more specifically a problem for the people who are freeloading on the Lockdown LSM and expecting it to be maintained without contributing anything meaningful.
There are past examples of previous contributions, but they don't seem to go anywhere:
https://lkml.org/lkml/2023/5/26/1057
Which causes us to carry patches like this downstream.
Quoted 5 lines
Quoted 4 lines
With Clavis, I attempted to develop
an approach that would meet the lockdown threat model requirements while allowing the end user to control key usage as they deem fit.
Quoted 7 lines
As mentioned previously, the design/implementation choices you made for Clavis means it is better suited for inclusion in the key subsystem and not as a standalone LSM. If you wanted to redesign/rework Clavis to stick to the traditional LSM security blobs perhaps that is something we could consider as a LSM, but it's probably worth seeing if David and Jarkko have any interest in including Clavis functionality in the key subsystem first.
The direction of creating a new LSM was based on this discussion:
https://lkml.org/lkml/2023/10/5/312
A lot of time could have been saved had your concerns been voiced in either the first or second round. If David or Jarkko are interested in a non LSM version, I can work on that.
Paul Moore
maintainerQuoted 21 lines · Eric Snowberg
Quoted 15 lines · Paul Moore
Quoted 2 lines · Eric Snowberg
Quoted 2 lines · Paul Moore
On March 6, 2025 5:29:36 PM Eric Snowberg <[email protected]> wrote:
...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
Based on your previous lockdown comments, I thought you might have some new information. Having lockdown enforcement has always been a requirement to get a shim signed by Microsoft.
...
Quoted 3 lines
Quoted 2 lines
The alternative "usage-oriented keyring" approach you've suggested wouldn't align with the threat model that lockdown aims to achieve.
Quoted 8 lines
Quoted 3 lines
That's a Lockdown problem, or more specifically a problem for the people who are freeloading on the Lockdown LSM and expecting it to be maintained without contributing anything meaningful.
There are past examples of previous contributions, but they don't seem to go anywhere:
Those patches proposed loosening Lockdown restrictions, which is particularly concerning given the intent behind Lockdown, and considering the author did not have any existing patches under security/ (they still do not, I just checked) there was room for concern. If your first introduction to your neighbour includes proposing the removal of the locks on their front door, you have to understand that they might not consider this a valuable contribution and might bristle at the idea of handing over responsibility of their home's security to you.
You are welcome to continue to criticize me and my handling of things, that's the popular thing to do these days when you disagree with a maintainer, but I will note that I don't recall you offering to step up and maintain Lockdown anywhere in this thread.
Quoted 1 line
Which causes us to carry patches like this downstream.
Which is your choice, and I'm sure you have plenty more patches unrelated to Lockdown in your downstream repo.
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
With Clavis, I attempted to develop
an approach that would meet the lockdown threat model requirements while allowing the end user to control key usage as they deem fit.As mentioned previously, the design/implementation choices you made for Clavis means it is better suited for inclusion in the key subsystem and not as a standalone LSM. If you wanted to redesign/rework Clavis to stick to the traditional LSM security blobs perhaps that is something we could consider as a LSM, but it's probably worth seeing if David and Jarkko have any interest in including Clavis functionality in the key subsystem first.
Quoted 1 line
The direction of creating a new LSM was based on this discussion ...
Oh so we are going to repeat ourselves, are we?
Quoted 2 lines
A lot of time could have been saved had your concerns been voiced in either the first or second round ...
I'm still waiting for someone to connect the dots between a lack of "timely" review (feel free to define that however you like) and these never ending threads where we keep rehashing arguments over and over and over ...
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 3 lines · Paul Moore
...
Quoted 2 lines
, but I will note that I don't recall you offering to step up and maintain Lockdown anywhere in this thread.
I didn't realize that trying to contribute a new LSM and being willing to be the maintainer of it also involved stepping up to maintain lockdown.
Paul Moore
maintainerQuoted 7 lines · Eric Snowberg
Quoted 1 line · Paul Moore
...
Quoted 2 lines
, but I will note that I don't recall you offering to step up and maintain Lockdown anywhere in this thread.
I didn't realize that trying to contribute a new LSM and being willing to be the maintainer of it also involved stepping up to maintain lockdown.
It doesn't, but your criticism of how Lockdown is being handled definitely falls a bit flat.
Signature · 1 line
paul-moore.com
Eric Snowberg
reviewerQuoted 7 lines · Paul Moore
Quoted 2 lines · Eric Snowberg
Quoted 1 line · Paul Moore
...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
, but I will note that I don't recall you offering to step up and maintain Lockdown anywhere in this thread.
I didn't realize that trying to contribute a new LSM and being willing to be the maintainer of it also involved stepping up to maintain lockdown.
It doesn't, but your criticism of how Lockdown is being handled definitely falls a bit flat.
I merely pointed out the inaccuracy of your assertion that people are freeloading off it and not contributing anything substantial by providing an example.
Paul Moore
maintainerQuoted 8 lines · Eric Snowberg
Quoted 8 lines · Paul Moore
Quoted 5 lines · Eric Snowberg
Quoted 1 line · Paul Moore
...
Quoted 2 lines
, but I will note that I don't recall you offering to step up and maintain Lockdown anywhere in this thread.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I didn't realize that trying to contribute a new LSM and being willing to be the maintainer of it also involved stepping up to maintain lockdown.
It doesn't, but your criticism of how Lockdown is being handled definitely falls a bit flat.
I merely pointed out the inaccuracy of your assertion that people are freeloading off it and not contributing anything substantial by providing an example.
In my opinion the example you provided did not demonstrate that at all for reasons already mentioned. As for the issue of freeloading on Lockdown, I believe I've already made myself clear on that point.
--
paul-moore.com
Jarkko Sakkinen
maintainerQuoted 15 lines · Paul Moore
Quoted 2 lines · Eric Snowberg
Quoted 2 lines · Paul Moore
On March 6, 2025 5:29:36 PM Eric Snowberg <[email protected]> wrote:
...
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Does this mean Microsoft will begin signing shims in the future without the lockdown requirement?
That's not a question I can answer, you'll need to discuss that with the UEFI SB people.
Based on your previous lockdown comments, I thought you might have some new information. Having lockdown enforcement has always been a requirement to get a shim signed by Microsoft.
Quoted 6 lines
I want to address two things, the first, and most important, is that while I am currently employed by Microsoft, I do not speak for Microsoft and the decisions and actions I take as an upstream Linux kernel maintainer are not vetted by Microsoft in any way. I think you will find that many upstream kernel maintainers operate in a similar way for a variety of very good reasons.
This is understood. If one takes a kernel maintainer role, one should unconditionally disobey any vetting by the employer (even at the cost of the job, or alternatively at the cost of giving up the maintainership).
And with you in particular I don't think anyone has any trust issues, no matter which group of villains you might be employed by ;-)
Quoted 11 lines
The second issue is that my main focus is on ensuring we have a secure, safe, and well maintained LSM subsystem within the upstream Linux kernel. While I do care about downstream efforts, e.g. UEFI Secure Boot, those efforts are largely outside the scope of the upstream Linux kernel and not my first concern. If the developer groups who are focused on things like UEFI SB want to rely on functionality within the upstream Linux kernel they should be prepared to stand up and contribute/maintain those features or else they may go away at some point in the future. In very blunt terms, contribute upstream or Lockdown dies.
Could Lockdown functionality be re-implemented with that eBPF LSM? I have not really looked into it so far...
BR, Jarkko
Paul Moore
maintainerQuoted 1 line · Jarkko Sakkinen
On Thu, Mar 20, 2025 at 05:36:41PM -0400, Paul Moore wrote:
...
Quoted 7 lines
Quoted 6 lines
I want to address two things, the first, and most important, is that while I am currently employed by Microsoft, I do not speak for Microsoft and the decisions and actions I take as an upstream Linux kernel maintainer are not vetted by Microsoft in any way. I think you will find that many upstream kernel maintainers operate in a similar way for a variety of very good reasons.
Quoted 6 lines
This is understood. If one takes a kernel maintainer role, one should unconditionally disobey any vetting by the employer (even at the cost of the job, or alternatively at the cost of giving up the maintainership).
And with you in particular I don't think anyone has any trust issues, no matter which group of villains you might be employed by ;-)
Haha :D
Quoted 11 lines
Quoted 10 lines
The second issue is that my main focus is on ensuring we have a secure, safe, and well maintained LSM subsystem within the upstream Linux kernel. While I do care about downstream efforts, e.g. UEFI Secure Boot, those efforts are largely outside the scope of the upstream Linux kernel and not my first concern. If the developer groups who are focused on things like UEFI SB want to rely on functionality within the upstream Linux kernel they should be prepared to stand up and contribute/maintain those features or else they may go away at some point in the future. In very blunt terms, contribute upstream or Lockdown dies.
Quoted 2 lines
Could Lockdown functionality be re-implemented with that eBPF LSM? I have not really looked into it so far...
I haven't looked at it too closely, but the kernel code is very simplistic so I would be surprised if it couldn't be implemented in eBPF, although there might be some issues about *very* early boot (Lockdown can run as an "early" LSM) and integrity which would need to be addressed (there is work ongoing in that are, see the recent Hornet posting as one example of that work). Beyond that there are policy/political issues around that would need to be worked out; nothing that couldn't be done, but it would be something that we would need to sort out.
However, as I mentioned earlier, with Lockdown already present in the kernel, deprecation and removal is really only an option of last resort, and I'm hopeful we won't come to that. We've seen some proper Lockdown patches submitted overnight (!!!) and I'm discussing maintainer roles with a couple of people off-list; with a bit of luck I'm thinking Lockdown might be properly maintained after this upcoming merge window. Fingers crossed :)
Signature · 1 line
paul-moore.com
James Bottomley
maintainerQuoted 2 lines · Eric Snowberg
Having lockdown enforcement has always been
a requirement to get a shim signed by Microsoft.
This is factually incorrect. Microsoft transferred shim signing to an independent process run by a group of open source maintainers a while ago:
https://github.com/rhboot/shim-review/
If you actually look, you'll see even Microsoft has to obey this upstream process for their Linux distro:
https://github.com/rhboot/shim-review/issues/427
Regards,
James
Eric Snowberg
reviewerQuoted 11 lines · James Bottomley
Quoted 2 lines · Eric Snowberg
Having lockdown enforcement has always been
a requirement to get a shim signed by Microsoft.This is factually incorrect. Microsoft transferred shim signing to an independent process run by a group of open source maintainers a while ago:
Yes, the shim-review process is understood. I'm not sure how my sentence is factually incorrect though. Unless you are saying Microsoft no longer maintains the private key. Hopefully that is not the case, since the public key ships on just about every single PC built.
James Bottomley
maintainerQuoted 7 lines · Eric Snowberg
Quoted 7 lines
On Mar 20, 2025, at 4:40 PM, James Bottomley
<[email protected]> wrote:Quoted 2 lines · Eric Snowberg
Having lockdown enforcement has always been
a requirement to get a shim signed by Microsoft.
Quoted 6 lines
Quoted 3 lines
This is factually incorrect. Microsoft transferred shim signing to an independent process run by a group of open source maintainers a while ago:
Yes, the shim-review process is understood. I'm not sure how my sentence is factually incorrect though.
You said people "get shim signed by Microsoft". They don't, they get it signed by the key held by the shim-review maintainers.
Quoted 2 lines
Unless you are saying Microsoft no longer maintains the private
key.
Well technically the private key is owned by UEFI (and referred to as the UEFI CA) but there are multiple HSM based copies floating around under the control of various operating system groups. The Windows OS group holds one and the shim-review group holds another ... there are probably other copies I don't know about, though.
The point about this is that UEFI co-ordinates various discussions between the private key holders about how to preserve security in the UEFI boot environment (mostly at the UEFI Security Sub Team level) it's no longer something Microsoft uniquely decides.
Quoted 2 lines
Hopefully that is not the case, since the public key ships on just about every single PC built.
I don't understand why Microsoft no-longer owning the private key is a problem? Only the public key ships on PCs and that hasn't changed (at least not yet, it might have to for NIST requirements since RSA2048 is being deprecated).
Regards,
James
Eric Snowberg
reviewerQuoted 36 lines · James Bottomley
Quoted 7 lines · Eric Snowberg
Quoted 7 lines
On Mar 20, 2025, at 4:40 PM, James Bottomley
<[email protected]> wrote:Quoted 2 lines · Eric Snowberg
Having lockdown enforcement has always been
a requirement to get a shim signed by Microsoft.Quoted 6 lines
Quoted 3 lines
This is factually incorrect. Microsoft transferred shim signing to an independent process run by a group of open source maintainers a while ago:
Yes, the shim-review process is understood. I'm not sure how my sentence is factually incorrect though.
You said people "get shim signed by Microsoft". They don't, they get it signed by the key held by the shim-review maintainers.
Quoted 2 lines
Unless you are saying Microsoft no longer maintains the private key.
Well technically the private key is owned by UEFI (and referred to as the UEFI CA) but there are multiple HSM based copies floating around under the control of various operating system groups. The Windows OS group holds one and the shim-review group holds another ... there are probably other copies I don't know about, though.
The point about this is that UEFI co-ordinates various discussions between the private key holders about how to preserve security in the UEFI boot environment (mostly at the UEFI Security Sub Team level) it's no longer something Microsoft uniquely decides.
Quoted 7 lines
Quoted 2 lines
Hopefully that is not the case, since the public key ships on just
about every single PC built.I don't understand why Microsoft no-longer owning the private key is a problem? Only the public key ships on PCs and that hasn't changed (at least not yet, it might have to for NIST requirements since RSA2048 is being deprecated).
A couple concerns come to mind. First, the vetting process being done for individuals that have signing authority with the HSM outside of Microsoft. Another would be access control of the HSM. Especially if it is not within Microsoft's possession.
James Bottomley
maintainerQuoted 2 lines · Eric Snowberg
Quoted 2 lines
On Mar 21, 2025, at 10:55 AM, James Bottomley
<[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
Hopefully that is not the case, since the public key ships on just about every single PC built.
I don't understand why Microsoft no-longer owning the private key is a problem? Only the public key ships on PCs and that hasn't changed (at least not yet, it might have to for NIST requirements since RSA2048 is being deprecated).
A couple concerns come to mind. First, the vetting process being done for individuals that have signing authority with the HSM outside of Microsoft.
I'm not aware UEFI has published any information on this. I think the shim-review repo predates UEFI ownership, but I'm sure the maintainers of the repository can answer how they came to be trusted ...
Quoted 2 lines
Another would be access control of the HSM. Especially if it is not within Microsoft's possession.
... and how they handle the HSM.
However, if you're worried about risks to the integrity of secure boot, I'd be much more concerned about the number of ODM motherboard manufacturers who seem to have managed to lose their PK private keys, or keys they placed into db, somehow ...
Regards,
James
Eric Snowberg
reviewerQuoted 16 lines · James Bottomley
Quoted 2 lines · Eric Snowberg
Quoted 2 lines
On Mar 21, 2025, at 10:55 AM, James Bottomley
<[email protected]> wrote:[...]
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Hopefully that is not the case, since the public key ships on
just about every single PC built.I don't understand why Microsoft no-longer owning the private key is a problem? Only the public key ships on PCs and that hasn't changed (at least not yet, it might have to for NIST requirements since RSA2048 is being deprecated).
Quoted 7 lines
Quoted 3 lines
A couple concerns come to mind. First, the vetting process being done for individuals that have signing authority with the HSM outside of Microsoft.
I'm not aware UEFI has published any information on this. I think the shim-review repo predates UEFI ownership, but I'm sure the maintainers of the repository can answer how they came to be trusted ...
Thanks for clarifying, I didn’t realize there were copies of the private key outside of Microsoft.
Quoted 9 lines
Quoted 2 lines
Another would be access control of the HSM. Especially if it is not within Microsoft's possession.
... and how they handle the HSM.
However, if you're worried about risks to the integrity of secure boot, I'd be much more concerned about the number of ODM motherboard manufacturers who seem to have managed to lose their PK private keys, or keys they placed into db, somehow ...
That’s precisely the protection Clavis offers. It begins immediately after ExitBootServices and continues through all kexecs. Once the kernel starts, the end-user is in control of all system kernel keys. Obviously some type of precaution must be taken to get into the first kernel. The Clavis key belongs to the end-user, and they have the freedom to determine which kernel keys perform specific tasks within the system. This level of protection wouldn’t be feasible with the proposed named kernel keyring approach. With the named kernel keyring approach, it could be defeated with kexec. When you have hardware vendors shipping systems in the past with test/demo DB/KEK/PK keys, or other companies that allow their signing key to be used by others, this level of protection is sought after by some users.
Jarkko Sakkinen
maintainerQuoted 8 lines · James Bottomley
Quoted 2 lines · Eric Snowberg
Having lockdown enforcement has always been
a requirement to get a shim signed by Microsoft.This is factually incorrect. Microsoft transferred shim signing to an independent process run by a group of open source maintainers a while ago:
Quoted 6 lines
https://github.com/rhboot/shim-review/
If you actually look, you'll see even Microsoft has to obey this upstream process for their Linux distro:
I did not know this. Thanks for educating!
Quoted 5 lines
Regards,
James
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 21 lines · Paul Moore
Quoted 12 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
Quoted 7 lines
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could we implement such change in a way that these new imaginary (at this point) usage oriented keyrings would be used to create the "legacy" keyrings?
Quoted 4 lines
Signature · 2 lines
-- paul-moore.com
BR, Jarkko
Paul Moore
maintainerQuoted 22 lines · Jarkko Sakkinen
Quoted 21 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.
Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could we implement such change in a way that these new imaginary (at this point) usage oriented keyrings would be used to create the "legacy" keyrings?
I think it would be easier for them to coexist so that one could have an easier migration. It's possible that even once everything was migrated to the new usage oriented keyrings it would still make sense to keep the existing keyrings in place and always link keys from there to the newer usage keyrings.
Signature · 1 line
paul-moore.com
Jarkko Sakkinen
maintainerQuoted 32 lines · Paul Moore
Quoted 22 lines · Jarkko Sakkinen
Quoted 21 lines · Paul Moore
Quoted 19 lines · Eric Snowberg
Quoted 11 lines · Paul Moore
Quoted 9 lines · Mimi Zohar
Quoted 8 lines · Paul Moore
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
The intent is not to limit ourselves to the source of the key. The main point of Clavis is to allow the end-user to determine what kernel keys they want to trust and for what purpose, irrespective of the originating source (.builtin_trusted, .secondary, .machine, or .platform). If we could go back in time, individual keyrings could be created that are oriented
toward usage. The idea for introducing Clavis is to bridge what we
have today with kernel keys and allow them to be usage based.Quoted 8 lines
Quoted 4 lines
While it is unlikely that the current well known keyrings could be removed, I see no reason why new usage oriented keyrings could not be introduced. We've seen far more significant shifts in the kernel over the years.
Could we implement such change in a way that these new imaginary (at this point) usage oriented keyrings would be used to create the "legacy" keyrings?
Quoted 5 lines
I think it would be easier for them to coexist so that one could have an easier migration. It's possible that even once everything was migrated to the new usage oriented keyrings it would still make sense to keep the existing keyrings in place and always link keys from there to the newer usage keyrings.
OK, so here I agree and disagree:
1. It probably does not port everything.
2. Still, we need to be sure that "can be done" condition is satisfied for the sake of robustness.
Quoted 4 lines
Signature · 2 lines
-- paul-moore.com
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 30 lines · Paul Moore
Quoted 23 lines · Mimi Zohar
Quoted 12 lines · Eric Snowberg
Quoted 12 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
Quoted 9 lines
Quoted 9 lines
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Quoted 5 lines
Hi Jarkko, David,
Both Paul's and my main concerns with this patch set is storing policy in the keyring. We would appreciate your chiming in here about storing key policy in the keyring itself.
Quoted 7 lines
I'd still also like to see some discussion about moving towards the addition of keyrings oriented towards usage instead of limiting ourselves to keyrings that are oriented on the source of the keys. Perhaps I'm missing some important detail which makes this impractical, but it seems like an obvious improvement to me and would go a long way towards solving some of the problems that we typically see with kernel keys.
I get the theoretical concern but cannot see anything obvious in the patch set that would nail into practical concerns.
Quoted 3 lines
Signature · 2 lines
-- paul-moore.com
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 25 lines · Mimi Zohar
Quoted 14 lines · Eric Snowberg
Quoted 14 lines · Paul Moore
Quoted 5 lines · Paul Moore
Regardless, back to Clavis ... reading quickly through the cover letter again, I do somewhat wonder if this isn't better integrated into the keyring proper; have you talked to both David and Jarkko about this?
I realize I should probably expand on my thinking a bit, especially since my comment a while regarding LSMs dedicated to enforcing access control on keys is what was given as a reason for making Clavis a LSM.
Quoted 9 lines
Quoted 9 lines
I still stand by my comment from over a year ago that I see no reason why we couldn't support a LSM that enforces access controls on keyrings/keys. What gives me pause with the Clavis LSM is that so much of Clavis is resident in the keyrings themselves, e.g. Clavis policy ACLs and authorization keys, that it really feels like it should be part of the keys subsystem and not a LSM. Yes, existing LSMs do have LSM specific data that resides outside of the LSM and in an object's subsystem, but that is usually limited to security identifiers and similar things, not the LSM's security policy.
Quoted 5 lines
Hi Jarkko, David,
Both Paul's and my main concerns with this patch set is storing policy in the keyring. We would appreciate your chiming in here about storing key policy in the keyring itself.
Right so the problem here would be that keyring defines policy for keys?
Like in abstract "textbook sense" a policy should not live within in the closure that it dictactes. And the most classic issue would be probably circular dependencies.
Theory aside, in practical sense, can you spot an example from the patch set where we could introduce issue by having Clavis as it is?
Quoted 4 lines
thanks,
Mimi
BR, Jarkko