Message ID | 20210907160110.2699645-9-eric.snowberg@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Enroll kernel keys thru MOK | expand |
Hi Eric, On Tue, 2021-09-07 at 12:01 -0400, Eric Snowberg wrote: > diff --git a/certs/system_keyring.c b/certs/system_keyring.c > index 955bd57815f4..747f0c528fec 100644 > --- a/certs/system_keyring.c > +++ b/certs/system_keyring.c > @@ -89,7 +89,10 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void > if (!restriction) > panic("Can't allocate secondary trusted keyring restriction\n"); > > - restriction->check = restrict_link_by_builtin_and_secondary_trusted; > + if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING)) > + restriction->check = restrict_link_by_builtin_secondary_and_ca_trusted; Returning the new restriction in a function named get_builtin_and_secondary_restriction() is kind of weird. Renaming the function to get_secondary_restriction() would be clearer. thanks, Mimi
diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 955bd57815f4..747f0c528fec 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -89,7 +89,10 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void if (!restriction) panic("Can't allocate secondary trusted keyring restriction\n"); - restriction->check = restrict_link_by_builtin_and_secondary_trusted; + if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING)) + restriction->check = restrict_link_by_builtin_secondary_and_ca_trusted; + else + restriction->check = restrict_link_by_builtin_and_secondary_trusted; return restriction; } diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index 2b75bbbd9e0e..c3c1939be2f1 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c @@ -34,7 +34,11 @@ static const char * const keyring_name[INTEGRITY_KEYRING_MAX] = { }; #ifdef CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +#define restrict_link_to_ima restrict_link_by_builtin_secondary_and_ca_trusted +#else #define restrict_link_to_ima restrict_link_by_builtin_and_secondary_trusted +#endif #else #define restrict_link_to_ima restrict_link_by_builtin_trusted #endif
With the introduction of the machine keyring, the end-user may choose to trust Machine Owner Keys (MOK) within the kernel. If they have chosen to trust them, the .machine keyring will contain these keys. If not, the machine keyring will always be empty. Update the restriction check to allow the secondary trusted keyring and ima keyring to also trust machine keys. Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com> --- v4: Initial version (consolidated two previous patches) v5: Rename to machine keyring --- certs/system_keyring.c | 5 ++++- security/integrity/digsig.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)