forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrity: Introduce a Linux keyring called machine
Many UEFI Linux distributions boot using shim. The UEFI shim provides what is called Machine Owner Keys (MOK). Shim uses both the UEFI Secure Boot DB and MOK keys to validate the next step in the boot chain. The MOK facility can be used to import user generated keys. These keys can be used to sign an end-users development kernel build. When Linux boots, both UEFI Secure Boot DB and MOK keys get loaded in the Linux .platform keyring. Define a new Linux keyring called machine. This keyring shall contain just MOK keys and not the remaining keys in the platform keyring. This new machine keyring will be used in follow on patches. Unlike keys in the platform keyring, keys contained in the machine keyring will be trusted within the kernel if the end-user has chosen to do so. Signed-off-by: Eric Snowberg <[email protected]> Tested-by: Jarkko Sakkinen <[email protected]> Tested-by: Mimi Zohar <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
- Loading branch information
Showing
5 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Machine keyring routines. | ||
* | ||
* Copyright (c) 2021, Oracle and/or its affiliates. | ||
*/ | ||
|
||
#include "../integrity.h" | ||
|
||
static __init int machine_keyring_init(void) | ||
{ | ||
int rc; | ||
|
||
rc = integrity_init_keyring(INTEGRITY_KEYRING_MACHINE); | ||
if (rc) | ||
return rc; | ||
|
||
pr_notice("Machine keyring initialized\n"); | ||
return 0; | ||
} | ||
device_initcall(machine_keyring_init); | ||
|
||
void __init add_to_machine_keyring(const char *source, const void *data, size_t len) | ||
{ | ||
key_perm_t perm; | ||
int rc; | ||
|
||
perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW; | ||
rc = integrity_load_cert(INTEGRITY_KEYRING_MACHINE, source, data, len, perm); | ||
|
||
/* | ||
* Some MOKList keys may not pass the machine keyring restrictions. | ||
* If the restriction check does not pass and the platform keyring | ||
* is configured, try to add it into that keyring instead. | ||
*/ | ||
if (rc && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) | ||
rc = integrity_load_cert(INTEGRITY_KEYRING_PLATFORM, source, | ||
data, len, perm); | ||
|
||
if (rc) | ||
pr_info("Error adding keys to machine keyring %s\n", source); | ||
} |