History

kexec, KEYS: Make use of platform keyring for signature verify

This patch allows the kexec_file_load syscall to verify the PE signed kernel image signature based on the preboot keys stored in the .platform keyring, as fall back, if the signature verification failed due to not finding the public key in the secondary or builtin keyrings. This commit adds a VERIFY_USE_PLATFORM_KEYRING similar to previous VERIFY_USE_SECONDARY_KEYRING indicating that verify_pkcs7_signature should verify the signature using platform keyring. Also, decrease the error message log level when verification failed with -ENOKEY, so that if called tried multiple time with different keyring it won't generate extra noises.

Kairui Song committed 7 years ago

Commit 278311e1 parent 219a3e83 files · +24 −4Browse files

Unified · Split

3 files
  1. arch/x86/kernel/kexec-bzimage64.c +11 −3
  2. certs/system_keyring.c +12 −1
  3. include/linux/verification.h +1 −0
arch/x86/kernel/kexec-bzimage64.c+11−3
@@ -531,9 +531,17 @@ static int bzImage64_cleanup(void *loader_data) · 530 unmodified lines
531531 #ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG
532532 static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len)
533533 {
534− return verify_pefile_signature(kernel, kernel_len,
535− VERIFY_USE_SECONDARY_KEYRING,
536− VERIFYING_KEXEC_PE_SIGNATURE);
534+ int ret;
535+
536+ ret = verify_pefile_signature(kernel, kernel_len,
537+ VERIFY_USE_SECONDARY_KEYRING,
538+ VERIFYING_KEXEC_PE_SIGNATURE);
539+ if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) {
540+ ret = verify_pefile_signature(kernel, kernel_len,
541+ VERIFY_USE_PLATFORM_KEYRING,
542+ VERIFYING_KEXEC_PE_SIGNATURE);
543+ }
544+ return ret;
537545 }
538546 #endif
539547
certs/system_keyring.c+12−1
@@ -240,11 +240,22 @@ int verify_pkcs7_signature(const void *data, size_t len, · 239 unmodified lines
240240 #else
241241 trusted_keys = builtin_trusted_keys;
242242 #endif
243+ } else if (trusted_keys == VERIFY_USE_PLATFORM_KEYRING) {
244+#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING
245+ trusted_keys = platform_trusted_keys;
246+#else
247+ trusted_keys = NULL;
248+#endif
249+ if (!trusted_keys) {
250+ ret = -ENOKEY;
251+ pr_devel("PKCS#7 platform keyring is not available\n");
252+ goto error;
253+ }
243254 }
244255 ret = pkcs7_validate_trust(pkcs7, trusted_keys);
245256 if (ret < 0) {
246257 if (ret == -ENOKEY)
247− pr_err("PKCS#7 signature not signed with a trusted key\n");
258+ pr_devel("PKCS#7 signature not signed with a trusted key\n");
248259 goto error;
249260 }
250261
include/linux/verification.h+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 * should be used.
1818 */
1919 #define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)
20+#define VERIFY_USE_PLATFORM_KEYRING ((struct key *)2UL)
2021
2122 /*
2223 * The use to which an asymmetric key is being put.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t