use more system keyrings to verify arm64 kdump kernel image signature
Subsystems (5)
v4 cover use more system keyrings to verify arm64 kdump kernel image signature
This patch set allows arm64 to use more system keyrings to verify kdump kernel image signature by making the existing code in x64 public.
v4:
- fix commit reference format issue and other checkpatch.pl warnings [Baoquan]
v3:
- s/arch_kexec_kernel_verify_pe_sig/kexec_kernel_verify_pe_sig [Eric]
- clean up arch_kexec_kernel_verify_sig [Eric]
v2:
- only x86_64 and arm64 need to enable PE file signature check [Dave]
Coiby Xu (3):
kexec: clean up arch_kexec_kernel_verify_sig
kexec, KEYS: make the code in bzImage64_verify_sig generic
arm64: kexec_file: use more system keyrings to verify kernel image
signature
arch/arm64/kernel/kexec_image.c | 4 +-- arch/x86/kernel/kexec-bzimage64.c | 13 +------- include/linux/kexec.h | 7 +++-- kernel/kexec_file.c | 51 ++++++++++++++++++------------- 4 files changed, 37 insertions(+), 38 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/3 kexec: clean up arch_kexec_kernel_verify_sig
Commit 9ec4ecef0af7 ("kexec_file,x86,powerpc: factor out kexec_file_ops functions") allows implementing the arch-specific implementation of kernel image verification in kexec_file_ops->verify_sig. Currently, there is no arch-specific implementation of arch_kexec_kernel_verify_sig. So clean it up.
--- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-)
include/linux/kexec.h +0 -4
@@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);
kernel/kexec_file.c +13 -21
@@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default (struct kimage *image,void *buf, -unsigned long buf_len) -{ -if (!image->fops || !image->fops->verify_sig) { -pr_debug ("kernel loader does not support signature verification.\n" ); -return -EKEYREJECTED ; - } - -return image->fops->verify_sig (buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len) -{ -return kexec_image_verify_sig_default (image, buf, buf_len); -} -#endif -/* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated.
@@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig (struct kimage *image,void *buf, +unsigned long buf_len) +{ +if (!image->fops || !image->fops->verify_sig) { +pr_debug ("kernel loader does not support signature verification.\n" ); +return -EKEYREJECTED ; + } + +return image->fops->verify_sig (buf, buf_len); +} +static int kimage_validate_signature (struct kimage *image) {int ret; - ret =arch_kexec_kernel_verify_sig (image, image->kernel_buf, - image->kernel_buf_len); + ret =kexec_image_verify_sig (image, image->kernel_buf, + image->kernel_buf_len);if (ret) {if (IS_ENABLED (CONFIG_KEXEC_SIG_FORCE )) {
Signature · 1 line
2.34.1
Re: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig
Quoted 3 lines · Coiby Xu
Commit
9ec4ecef0af7("kexec_file,x86,powerpc: factor outkexec_file_opsfunctions") allows implementing the arch-specific implementation of kernel image verification inkexec_file_ops->verify_sig. Currently, there is no
Looking back at the old commit 9ec4ecef0af7, it mistakenly added a generic arch_kexec_kernel_verify_sig() which is marked as __weak, and expects any architecture will add a arch specified version if needed. In fact those arch specified difference has been removed by wrapping them into each architecture's own struct kexec_file_ops methods. Means in the commit, the generic arch_kexec_kernel_verify_sig() is unnecessary at all.
Now, you clean up that uncessary function with code change.
I think description telling above analysis could be clearer.
Quoted 85 lines
arch-specific implementation of
arch_kexec_kernel_verify_sig. So clean it up.Suggested-by Eric W. Biederman <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-)include/linux/kexec.h +0
-4@@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);kernel/kexec_file.c +13
-21@@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default (struct kimage *image,void *buf, -unsigned long buf_len) -{ -if (!image->fops || !image->fops->verify_sig) { -pr_debug ("kernel loader does not support signature verification.\n" ); -return -EKEYREJECTED ; - } - -return image->fops->verify_sig (buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len) -{ -return kexec_image_verify_sig_default (image, buf, buf_len); -} -#endif -/* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated. @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig (struct kimage *image,void *buf, +unsigned long buf_len) +{ +if (!image->fops || !image->fops->verify_sig) { +pr_debug ("kernel loader does not support signature verification.\n" ); +return -EKEYREJECTED ; + } + +return image->fops->verify_sig (buf, buf_len); +} +static int kimage_validate_signature (struct kimage *image) {int ret; - ret =arch_kexec_kernel_verify_sig (image, image->kernel_buf, - image->kernel_buf_len); + ret =kexec_image_verify_sig (image, image->kernel_buf, + image->kernel_buf_len);if (ret) {if (IS_ENABLED (CONFIG_KEXEC_SIG_FORCE )) {Signature · 1 line
2.34.1
Re: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig
Quoted 5 lines · Baoquan He
Quoted 3 lines · Coiby Xu
Commit
9ec4ecef0af7("kexec_file,x86,powerpc: factor outkexec_file_opsfunctions") allows implementing the arch-specific implementation of kernel image verification inkexec_file_ops->verify_sig. Currently, there is no
Quoted 7 lines
Looking back at the old commit
9ec4ecef0af7, it mistakenly added a genericarch_kexec_kernel_verify_sig()which is marked as__weak, and expects any architecture will add a arch specified version if needed. In fact those arch specified difference has been removed by wrapping them into each architecture's own structkexec_file_opsmethods. Means in the commit, the genericarch_kexec_kernel_verify_sig()is unnecessary at all.
Thanks for looking at commit 9ec4ecef0af7 for me!
Although commit 9ec4ecef0af7 added some code in arch_kexec_kernel_verify_sig so kexec_file_ops->verify_sig can be called, this commit doesn't add __weak arch_kexec_kernel_verify_sig itself. And kexec_file_ops isn't supposed to replace arch-specific implementation using __weak considering s390 and x86 still make use of __weak to implement its own version of arch_kexec_apply_relocations_add. How about the commit message as follows?
Currently this no arch-specific implementation of arch_kexec_kernel_verify_sig. Even if we want to add an implementation for an architecture in the future, we can simply use "(struct kexec_file_ops*)->verify_sig". So clean it up.
Quoted 91 lines
Now, you clean up that uncessary function with code change.
I think description telling above analysis could be clearer.
Quoted 85 lines
arch-specific implementation of
arch_kexec_kernel_verify_sig. So clean it up.Suggested-by Eric W. Biederman <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-)include/linux/kexec.h +0
-4@@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);kernel/kexec_file.c +13
-22@@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default (struct kimage *image,void *buf, -unsigned long buf_len) -{ -if (!image->fops || !image->fops->verify_sig) { -pr_debug ("kernel loader does not support signature verification.\n" ); -return -EKEYREJECTED ; - } - -return image->fops->verify_sig (buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len) -{ -return kexec_image_verify_sig_default (image, buf, buf_len); -} -#endif -/* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated. @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig (struct kimage *image,void *buf, +unsigned long buf_len) +{ +if (!image->fops || !image->fops->verify_sig) { +pr_debug ("kernel loader does not support signature verification.\n" ); +return -EKEYREJECTED ; + } + +return image->fops->verify_sig (buf, buf_len); +} +static int kimage_validate_signature (struct kimage *image) {int ret; - ret =arch_kexec_kernel_verify_sig (image, image->kernel_buf, - image->kernel_buf_len); + ret =kexec_image_verify_sig (image, image->kernel_buf, + image->kernel_buf_len);if (ret) {if (IS_ENABLED (CONFIG_KEXEC_SIG_FORCE )) { --2.34.1
Signature · 2 lines
Best regards, Coiby
Re: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig
Quoted 16 lines · Coiby Xu
Quoted 5 lines · Baoquan He
Quoted 3 lines · Coiby Xu
Commit
9ec4ecef0af7("kexec_file,x86,powerpc: factor outkexec_file_opsfunctions") allows implementing the arch-specific implementation of kernel image verification inkexec_file_ops->verify_sig. Currently, there is noQuoted 7 lines
Looking back at the old commit
9ec4ecef0af7, it mistakenly added a genericarch_kexec_kernel_verify_sig()which is marked as__weak, and expects any architecture will add a arch specified version if needed. In fact those arch specified difference has been removed by wrapping them into each architecture's own structkexec_file_opsmethods. Means in the commit, the genericarch_kexec_kernel_verify_sig()is unnecessary at all.Thanks for looking at commit
9ec4ecef0af7for me!
Quoted 7 lines
Although commit
9ec4ecef0af7added some code inarch_kexec_kernel_verify_sigsokexec_file_ops->verify_sigcan be called, this commit doesn't add__weakarch_kexec_kernel_verify_sigitself. Andkexec_file_opsisn't supposed to replace arch-specific implementation using__weakconsidering s390 and x86 still make use of__weakto implement its own version ofarch_kexec_apply_relocations_add. How about the commit message as follows?
Yes, arch_kexec_apply_relocations_add has its different version on arches. But arch_kexec_kernel_verify_sig() is different. There's a specific method for that, ->verify_sig().
struct kexec_file_ops {
kexec_probe_t *probe;
kexec_load_t *load;
kexec_cleanup_t *cleanup;
#ifdef CONFIG_KEXEC_SIG
kexec_verify_sig_t *verify_sig;#endif
};
Quoted 5 lines
Currently this no arch-specific implementation of
arch_kexec_kernel_verify_sig. Even if we want to add an implementation for an architecture in the future, we can simply use "(struct kexec_file_ops*)->verify_sig". So clean it up.
That is also fine. I think it's better to put the above in if we have checked the old commit. Anyway, please take the sentences which comforts you more. And there's grammer mistake, please use 'Currently there is not' to replace.
Quoted 96 lines
Quoted 91 lines
Now, you clean up that uncessary function with code change.
I think description telling above analysis could be clearer.
Quoted 85 lines
arch-specific implementation of
arch_kexec_kernel_verify_sig. So clean it up.Suggested-by Eric W. Biederman <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-)include/linux/kexec.h +0
-4@@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);kernel/kexec_file.c +13
-22@@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default (struct kimage *image,void *buf, -unsigned long buf_len) -{ -if (!image->fops || !image->fops->verify_sig) { -pr_debug ("kernel loader does not support signature verification.\n" ); -return -EKEYREJECTED ; - } - -return image->fops->verify_sig (buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len) -{ -return kexec_image_verify_sig_default (image, buf, buf_len); -} -#endif -/* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated. @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig (struct kimage *image,void *buf, +unsigned long buf_len) +{ +if (!image->fops || !image->fops->verify_sig) { +pr_debug ("kernel loader does not support signature verification.\n" ); +return -EKEYREJECTED ; + } + +return image->fops->verify_sig (buf, buf_len); +} +static int kimage_validate_signature (struct kimage *image) {int ret; - ret =arch_kexec_kernel_verify_sig (image, image->kernel_buf, - image->kernel_buf_len); + ret =kexec_image_verify_sig (image, image->kernel_buf, + image->kernel_buf_len);if (ret) {if (IS_ENABLED (CONFIG_KEXEC_SIG_FORCE )) { --2.34.1
Signature · 2 lines
Best regards, Coiby
Re: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig
Quoted 29 lines · Baoquan He
Quoted 16 lines · Coiby Xu
Quoted 5 lines · Baoquan He
Quoted 3 lines · Coiby Xu
Commit
9ec4ecef0af7("kexec_file,x86,powerpc: factor outkexec_file_opsfunctions") allows implementing the arch-specific implementation of kernel image verification inkexec_file_ops->verify_sig. Currently, there is noQuoted 7 lines
Looking back at the old commit
9ec4ecef0af7, it mistakenly added a genericarch_kexec_kernel_verify_sig()which is marked as__weak, and expects any architecture will add a arch specified version if needed. In fact those arch specified difference has been removed by wrapping them into each architecture's own structkexec_file_opsmethods. Means in the commit, the genericarch_kexec_kernel_verify_sig()is unnecessary at all.Thanks for looking at commit
9ec4ecef0af7for me!Quoted 7 lines
Although commit
9ec4ecef0af7added some code inarch_kexec_kernel_verify_sigsokexec_file_ops->verify_sigcan be called, this commit doesn't add__weakarch_kexec_kernel_verify_sigitself. Andkexec_file_opsisn't supposed to replace arch-specific implementation using__weakconsidering s390 and x86 still make use of__weakto implement its own version ofarch_kexec_apply_relocations_add. How about the commit message as follows?Yes,
arch_kexec_apply_relocations_addhas its different version on arches. Butarch_kexec_kernel_verify_sig()is different. There's a specific method for that, ->verify_sig().
Quoted 9 lines
struct kexec_file_ops { kexec_probe_t *probe; kexec_load_t *load; kexec_cleanup_t *cleanup; #ifdef CONFIG_KEXEC_SIG kexec_verify_sig_t *verify_sig;#endif
};
Thanks for the explanation! This example of arch_kexec_apply_relocations_add is indeed not good and don't illustrate my point. My point is we can't say commit 9ec4ecef0af7 made a mistake since it's not this commit that introduced "__weak arch_kexec_kernel_verify_sig" and I don't think its motivation was to replace __weak with kexec_file_ops. Currently we still have "__weak arch_kimage_file_post_load_cleanup" and kexec_file_ops->cleanup.
Quoted 10 lines
Quoted 5 lines
Currently this no arch-specific implementation of
arch_kexec_kernel_verify_sig. Even if we want to add an implementation for an architecture in the future, we can simply use "(struct kexec_file_ops*)->verify_sig". So clean it up.That is also fine. I think it's better to put the above in if we have checked the old commit. Anyway, please take the sentences which comforts you more. And there's grammer mistake, please use 'Currently there is not' to replace.
Thanks for catching the mistake!
Quoted 98 lines
Quoted 97 lines
Quoted 87 lines
Now, you clean up that uncessary function with code change.
I think description telling above analysis could be clearer.
Quoted 81 lines
arch-specific implementation of
arch_kexec_kernel_verify_sig. So clean it up.Suggested-by Eric W. Biederman <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-)include/linux/kexec.h +0
-4@@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);kernel/kexec_file.c +13
-21@@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)return kexec_image_post_load_cleanup_default (image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default (struct kimage *image,void *buf, -unsigned long buf_len) -{ -if (!image->fops || !image->fops->verify_sig) { -pr_debug ("kernel loader does not support signature verification.\n" ); -return -EKEYREJECTED ; - } - -return image->fops->verify_sig (buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig (struct kimage *image,void *buf, -unsigned long buf_len) -{ -return kexec_image_verify_sig_default (image, buf, buf_len); -} -#endif -/* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated. @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig (struct kimage *image,void *buf, +unsigned long buf_len) +{ +if (!image->fops || !image->fops->verify_sig) { +pr_debug ("kernel loader does not support signature verification.\n" ); +return -EKEYREJECTED ; + } + +return image->fops->verify_sig (buf, buf_len); +} +static int kimage_validate_signature (struct kimage *image) {int ret; - ret =arch_kexec_kernel_verify_sig (image, image->kernel_buf, - image->kernel_buf_len); + ret =kexec_image_verify_sig (image, image->kernel_buf, + image->kernel_buf_len);if (ret) {Quoted 5 lines
Quoted 4 lines
kernel/kexec_file.c +0
-1if (IS_ENABLED (CONFIG_KEXEC_SIG_FORCE )) { --2.34.1
--
Best regards,
Coiby
Signature · 2 lines
Best regards, Coiby
PATCH v4 2/3 kexec, KEYS: make the code in bzImage64_verify_sig generic
In reply to Coiby XuThe code in bzImage64_verify_sig could make use of system keyrings including .buitin_trusted_keys, .secondary_trusted_keys and .platform keyring to verify signed kernel image as PE file. Make it generic so both x86_64 and arm64 can use it.
--- arch/x86/kernel/kexec-bzimage64.c | 13 +------------ include/linux/kexec.h | 7 +++++++ kernel/kexec_file.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-)
arch/x86/kernel/kexec-bzimage64.c +1 -12
@@ -17,7 +17,6 @@#include <linux/kernel.h> #include <linux/mm.h> #include <linux/efi.h> -#include <linux/verification.h> #include <asm/bootparam.h> #include <asm/setup.h>
@@ -531,17 +530,7 @@ static int bzImage64_cleanup(void *loader_data)#ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG static int bzImage64_verify_sig (const char *kernel,unsigned long kernel_len) { -int ret; - - ret =verify_pefile_signature (kernel, kernel_len, -VERIFY_USE_SECONDARY_KEYRING , -VERIFYING_KEXEC_PE_SIGNATURE ); -if (ret == -ENOKEY &&IS_ENABLED (CONFIG_INTEGRITY_PLATFORM_KEYRING )) { - ret =verify_pefile_signature (kernel, kernel_len, -VERIFY_USE_PLATFORM_KEYRING , -VERIFYING_KEXEC_PE_SIGNATURE ); - } -return ret; +return kexec_kernel_verify_pe_sig (kernel, kernel_len); }#endif
include/linux/kexec.h +7 -0
@@ -19,6 +19,7 @@#include <asm/io.h> #include <uapi/linux/kexec.h> +#include <linux/verification.h> #ifdef CONFIG_KEXEC_CORE #include <linux/list.h>
@@ -196,6 +197,12 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi,const Elf_Shdr *relsec, const Elf_Shdr *symtab);int arch_kimage_file_post_load_cleanup (struct kimage *image); +#ifdef CONFIG_KEXEC_SIG +#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION +int kexec_kernel_verify_pe_sig (const char *kernel, +unsigned long kernel_len); +#endif +#endif int arch_kexec_locate_mem_hole (struct kexec_buf *kbuf);extern int kexec_add_buffer (struct kexec_buf *kbuf);
kernel/kexec_file.c +17 -0
@@ -165,6 +165,23 @@ void kimage_file_post_load_cleanup(struct kimage *image) }#ifdef CONFIG_KEXEC_SIG +#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION +int kexec_kernel_verify_pe_sig (const char *kernel,unsigned long kernel_len) +{ +int ret; + + ret =verify_pefile_signature (kernel, kernel_len, +VERIFY_USE_SECONDARY_KEYRING , +VERIFYING_KEXEC_PE_SIGNATURE ); +if (ret == -ENOKEY &&IS_ENABLED (CONFIG_INTEGRITY_PLATFORM_KEYRING )) { + ret =verify_pefile_signature (kernel, kernel_len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_KEXEC_PE_SIGNATURE ); + } +return ret; +} +#endif +static int kexec_image_verify_sig (struct kimage *image,void *buf,unsigned long buf_len) {
Signature · 1 line
2.34.1
PATCH v4 3/3 arm64: kexec_file: use more system keyrings to verify kernel image signature
In reply to Coiby XuThis allows to verify arm64 kernel image signature using not only .builtin_trusted_keys but also .secondary_trusted_keys and .platform keyring.
--- arch/arm64/kernel/kexec_image.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm64/kernel/kexec_image.c +1 -3
@@ -14,7 +14,6 @@#include <linux/kexec.h> #include <linux/pe.h> #include <linux/string.h> -#include <linux/verification.h> #include <asm/byteorder.h> #include <asm/cpufeature.h> #include <asm/image.h>
@@ -133,8 +132,7 @@ static void *image_load(struct kimage *image,#ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG static int image_verify_sig (const char *kernel,unsigned long kernel_len) { -return verify_pefile_signature (kernel, kernel_len,NULL , -VERIFYING_KEXEC_PE_SIGNATURE ); +return kexec_kernel_verify_pe_sig (kernel, kernel_len); }#endif
Signature · 1 line
2.34.1
v4 cover use more system keyrings to verify arm64 kdump kernel image signature
In reply to Coiby XuHi Coiby,
Quoted 2 lines · Coiby Xu
This patch set allows arm64 to use more system keyrings to verify kdump kernel image signature by making the existing code in x64 public.
Could you tell more about why arm64 need use more system keyrings to verify kdump kernel iamge signature?
What problem have you encountered to make you want to do this?
Thanks
Baoquan
v4 cover use more system keyrings to verify arm64 kdump kernel image signature
Hi Baoquan,
Quoted 10 lines · Baoquan He
Hi Coiby,
Quoted 2 lines · Coiby Xu
This patch set allows arm64 to use more system keyrings to verify kdump kernel image signature by making the existing code in x64 public.
Could you tell more about why arm64 need use more system keyrings to verify kdump kernel iamge signature?
What problem have you encountered to make you want to do this?
Thanks for raising this question! Currently, a problem faced by arm64 is if a kernel image is signed by a MOK key, this kernel image would be rejected with the error "Lockdown: kexec: kexec of unsigned images is restricted; see man kernel_lockdown.7". I'll improve the cover letter and the 3rd commit message to have this info.
Quoted 4 lines
Thanks
Baoquan
Signature · 2 lines
Best regards, Coiby
v4 cover use more system keyrings to verify arm64 kdump kernel image signature
Quoted 12 lines · Coiby Xu
Hi Baoquan,
Quoted 9 lines · Baoquan He
Hi Coiby,
Quoted 2 lines · Coiby Xu
This patch set allows arm64 to use more system keyrings to verify kdump kernel image signature by making the existing code in x64 public.
Could you tell more about why arm64 need use more system keyrings to verify kdump kernel iamge signature?
Quoted 7 lines
Quoted 1 line
What problem have you encountered to make you want to do this?
Thanks for raising this question! Currently, a problem faced by arm64 is if a kernel image is signed by a MOK key, this kernel image would be rejected with the error "Lockdown: kexec: kexec of unsigned images is restricted; see man kernel_lockdown.7". I'll improve the cover letter and the 3rd commit message to have this info.
Thanks for the effort, Coiby.
Usually, when we post patch to solve issues, or improve, we had better tell
1) what problem we encounter;
2) why the problem happened, what is the root cause after investigation and analysis;
3) how you fix it;
The 1) and 2) are very important to help reviewer understand what's going on, and why this patch is needed. As you can see, in this patchset, only 3) is presented.
Cheers