sign: Sign spawn kernels for kexec_file_load() verification - #21
Merged
Merged
Conversation
A bzImage's PE signature does not survive kerf extracting the ELF vmlinux, so a host that enforces kexec signatures refuses every spawn kernel kerf loads. The multikernel kernel now verifies a PKCS#7 signature appended to the ELF vmlinux in the module signature format. Add "kerf sign", which extracts the vmlinux from a bzImage when needed and appends that signature with an RSA or ECDSA key. It is a separate command so the signing key stays on the build machine rather than on every host that loads kernels. The PKCS#7 message is assembled here instead of by cryptography's PKCS#7 builder, which labels RSA signatures sha256WithRSAEncryption; the kernel only accepts rsaEncryption and would refuse them. For RSA the output is byte-for-byte what scripts/sign-file writes. kerf load now warns when it loads a bzImage on a host that enforces signatures, and explains signature errors from kexec_file_load(), including EPERM from lockdown, which it used to report as a missing root privilege. Signed-off-by: Cong Wang <cwang@multikernel.io>
congwang-mk
force-pushed
the
kerf-sign
branch
from
September 30, 2026 04:48
525adc0 to
0e3e4b2
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kerf extracts the ELF vmlinux from a bzImage before
kexec_file_load(), so the bzImage's PE signature never reaches the kernel, and a host that enforces kexec signatures (CONFIG_KEXEC_SIG_FORCEor lockdown) refuses every spawn kernel. The multikernel kernel now verifies a PKCS#7 signature appended to the ELF vmlinux in the module signature format (multikernel/linux3f867f5f5c67).kerf sign KERNEL -o OUTPUT --key KEY [--cert CERT] [--hash sha256|sha384|sha512]extracts the vmlinux from a bzImage when needed and appends that signature, with an RSA or ECDSA key. It is a separate command so the signing key stays on the build machine instead of every host that loads kernels.cryptographydoing the signing. cryptography's PKCS#7 builder labels RSA signaturessha256WithRSAEncryption, which the kernel's PKCS#7 parser rejects (-ENOPKG); it only acceptsrsaEncryption. For RSA the output is byte-for-byte whatscripts/sign-filewrites.kerf loadwarns when it loads a bzImage on a host that enforces signatures, and explains signature errors fromkexec_file_load()(ENODATA,ENOKEY/EKEYREJECTED, andEPERMfrom lockdown, which it used to report as a missing root privilege).cryptographyas a dependency.Test plan
pytest: 433 passed, including 31 new tests intests/test_signature.pyscripts/sign-file; ECDSA structure identical field by fieldENODATA, vmlinux signed with an untrusted key refused withENOKEY, vmlinux signed with the trusted key loaded and booted twice (start, kill, start)/proc/config.gz; a kernel exposing neither gets only the error note🤖 Generated with Claude Code