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
531#ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG531#ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG
532static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len)532static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len)
533{533{
534 return verify_pefile_signature(kernel, kernel_len,534 int ret;
535 VERIFY_USE_SECONDARY_KEYRING,535
536 VERIFYING_KEXEC_PE_SIGNATURE);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;
537}545}
538#endif546#endif
539 547
certs/system_keyring.c+12−1
@@ -240,11 +240,22 @@ int verify_pkcs7_signature(const void *data, size_t len, · 239 unmodified lines
240#else240#else
241 trusted_keys = builtin_trusted_keys;241 trusted_keys = builtin_trusted_keys;
242#endif242#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 }
243 }254 }
244 ret = pkcs7_validate_trust(pkcs7, trusted_keys);255 ret = pkcs7_validate_trust(pkcs7, trusted_keys);
245 if (ret < 0) {256 if (ret < 0) {
246 if (ret == -ENOKEY)257 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");
248 goto error;259 goto error;
249 }260 }
250 261
include/linux/verification.h+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
17 * should be used.17 * should be used.
18 */18 */
19#define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)19#define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)
20#define VERIFY_USE_PLATFORM_KEYRING ((struct key *)2UL)
20 21
21/*22/*
22 * The use to which an asymmetric key is being put.23 * 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