Skip to content

linux: generate deterministic module signatures and certificates - #571181

Merged
zowoq merged 11 commits into
staging-nixosfrom
wip-emily/push-xllppwszomnw
Oct 14, 2026
Merged

zowoq merged 11 commits into
staging-nixosfrom
wip-emily/push-xllppwszomnw

Conversation

@emilazy

@emilazy emilazy commented Oct 7, 2026

Copy link
Copy Markdown
Member

Add a package for kmodigest, and use it to provide optional support for deterministic module verification. Best reviewed commit‐by‐commit.

This enables the use of kernel lockdown and module signature enforcement with fully reproducible builds, bridging the gap until the Merkle tree hash‐based module integrity checking work lands upstream in Linux. The scheme used has security equivalent to conventional ECDSA with one ephemeral key per module; see the kmodigest README for much more detail.

This does not enforce module verification by default; it just enables optional support. Adding support for signing full kernel images and wiring this up into NixOS is left to future work.

The added NixOS test is moderately slow to boot, especially on x86‐64 (~20s); this is an artefact of inefficiencies in the test runner’s console handling and the verbose console log level used by default, as the kernel emits one KERN_NOTICE log message per built‐in certificate (and hence per available kernel module). Boots with real hardware consoles and the default NixOS log level are not affected by this and the impact on boot speed there is within the milliseconds range. This only affects systems which explicitly choose to rebuild the kernel image with the module certificates anyway, so the effective user impact should be nil. I have a stack of patches to make the test runner use the virtio console which I plan to push out later.

Stacked on top of #571141, #571142, and #571170.

cc @katexochen who blogged about similar keyless ECDSA tricks and might be interested in this work :)


This is part of the end‐to‐end NixOS boot security project, funded through NGI Fediversity Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme.

Things done

  • Built on platform:
    • x86_64-linux (linux_5_10, linux, linux_latest)
    • aarch64-linux (linux, linux_latest)
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.
  • Follows the automation/AI policy.

@emilazy
emilazy force-pushed the wip-emily/push-xllppwszomnw branch from d2b6bc7 to 39a5b71 Compare October 7, 2026 05:21
@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, Atemu, AxerTheAxe, JerrySM64, andir, eljamm, lovesegfault, moni-dz, thiagokokada, thoughtpolice and zzzsyyy and removed request for a team October 7, 2026 05:32
@nixpkgs-ci nixpkgs-ci Bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: kernel The Linux kernel labels Oct 7, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team October 7, 2026 05:48
Comment thread pkgs/os-specific/linux/kernel/build.nix Outdated
sed 's/$/\.cer/' modules.order | xargs -d'\n' cat > modules.cer
sed 's/$/\.cer/' modules.order | xargs -d'\n' rm
''
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 5.10/5.15 kernels have been been removed so these conditions could be removed. #570647

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, thanks! Dropped this and the conditional kernel configuration.

@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from d0b7646 to c2a8db2 Compare October 8, 2026 17:21
@emilazy
emilazy force-pushed the wip-emily/push-xllppwszomnw branch from 39a5b71 to 14e472b Compare October 8, 2026 17:21
@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from c2a8db2 to 8a3d399 Compare October 10, 2026 02:00
@emilazy
emilazy force-pushed the wip-emily/push-xllppwszomnw branch from 14e472b to 7c25b2e Compare October 10, 2026 02:00
@emilazy
emilazy force-pushed the wip-emily/push-omlskzuxuzxs branch from 8a3d399 to 70b7136 Compare October 10, 2026 15:34
@emilazy
emilazy force-pushed the wip-emily/push-xllppwszomnw branch from 7c25b2e to 18f1ad9 Compare October 10, 2026 15:34
@yuannan yuannan mentioned this pull request Oct 21, 2026
3 of 13 tasks
welles added a commit to welles/nixos-config that referenced this pull request Oct 21, 2026
nixpkgs' new-lg4ff splices kernelModuleMakeFlags unquoted into bash.
Since NixOS/nixpkgs#571181 they contain the module signing rule
`cmd_sign=…/kmodigest$(space)$@`, and bash runs `$(space)` as a command:
"space: command not found", exit code 127. Build the package with the
flags quoted and add it directly instead of through
hardware.new-lg4ff.enable, which only adds the package and loads
hid-logitech-new.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixos-cuda-channel-updater Bot pushed a commit to nixos-cuda/nixpkgs that referenced this pull request Oct 21, 2026
The custom installPhase copied acpi_call.ko manually, bypassing
scripts/Makefile.modinst. The module was therefore not stripped, not
compressed, and — since the kernel now signs modules deterministically
with kmodigest (PR NixOS#571181) — not signed and missing the per-module
certificate that the kmod aggregator expects next to every external
module, breaking the module closure of hosts using acpi_call.

Use the upstream install target, which runs the kernel's
modules_install, so modinst strips, signs and compresses the module and
emits acpi_call.ko.cer alongside it.

Assisted-by: Kilo Code (GLM-5.3-Flash)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The bundled Makefile-footer.gmk passes
"CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL=" to the kernel's modules_install, so
the modules were installed unsigned and without the per-module certificate that
the kmod aggregator expects next to every external module since PR NixOS#571181.

Set VBOX_ALLOW_MODULE_SIGNING=1 and propagate kernelModuleMakeFlags (which
routes the signing rule to the deterministic kmodigest), so modinst
signs the modules and emits vboxdrv.ko.cer and friends alongside them.

Assisted-by: Kilo Code (GLM-5.3-Flash)
(cherry picked from commit 7bd4fa6)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The custom installPhase copied acpi_call.ko manually, bypassing
scripts/Makefile.modinst. The module was therefore not stripped, not
compressed, and — since the kernel now signs modules deterministically
with kmodigest (PR NixOS#571181) — not signed and missing the per-module
certificate that the kmod aggregator expects next to every external
module, breaking the module closure of hosts using acpi_call.

Use the upstream install target, which runs the kernel's
modules_install, so modinst strips, signs and compresses the module and
emits acpi_call.ko.cer alongside it.

Assisted-by: Kilo Code (GLM-5.3-Flash)
(cherry picked from commit c270cc0)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The install phase copied system76.ko into the output by hand, bypassing
the Kbuild module installation.  Since NixOS#571181, kernelModuleMakeFlags
makes Kbuild sign each module with kmodigest during modules_install,
which also writes a certificate next to the module, and aggregateModules
merges the certificates of all external modules into modules.cer.  The
hand-copied module has neither, so building a NixOS system with
hardware.system76.enableAll fails:

    cat: misc/system76.ko.cer: No such file or directory

The upstream Makefile has no install target, so call the Kbuild
modules_install target directly, as suggested for zenpower in NixOS#575192.
It strips, signs, and compresses the module and writes its certificate.
Keep the module under misc and leave depmod to aggregateModules.  Set
INSTALL_MOD_STRIP=1, as compression now happens before the strip phase,
which used to remove the debug information.  The hwdb file moves to
postInstall.

Assisted-by: Claude (claude-opus-5-5)
(cherry picked from commit e5d3094)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The install phase copied system76-io.ko and system76-thelio-io.ko into
the output by hand, bypassing the Kbuild module installation.
Since NixOS#571181, kernelModuleMakeFlags makes Kbuild sign each module with
kmodigest during modules_install, which also writes a certificate next
to the module, and aggregateModules merges the certificates of all
external modules into modules.cer.  The hand-copied modules have
neither, so building a NixOS system with hardware.system76.enableAll
fails:

    cat: misc/system76-thelio-io.ko.cer: No such file or directory
    cat: misc/system76-io.ko.cer: No such file or directory

The upstream Makefile has no install target, so call the Kbuild
modules_install target directly, as suggested for zenpower in NixOS#575192.
It strips, signs, and compresses the modules and writes their
certificates.  Keep the modules under misc and leave depmod to
aggregateModules.  Set INSTALL_MOD_STRIP=1, as compression now happens
before the strip phase, which used to remove the debug information.

Assisted-by: Claude (claude-opus-5-5)
(cherry picked from commit 8043407)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
…nstall

Installing the module by hand bypasses Kbuild's module installation
flow, which since NixOS#571181 is what signs each module with kmodigest and
installs its per-module certificate. The package therefore only
produced `framework_laptop.ko`, and building `system.modulesTree`
failed while concatenating the certificates of external modules:

    cat: extra/framework_laptop.ko.cer: No such file or directory

Install via `modules_install` so the module is signed and its
certificate is installed alongside it, matching the other kernel
module packages fixed in this way.

See NixOS#575192.

(cherry picked from commit e81ffa2)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The bundled Makefile-footer.gmk passes
"CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL=" to the kernel's modules_install, so
the modules were installed unsigned and without the per-module certificate that
the kmod aggregator expects next to every external module since PR NixOS#571181.

Set VBOX_ALLOW_MODULE_SIGNING=1 and propagate kernelModuleMakeFlags (which
routes the signing rule to the deterministic kmodigest), so modinst
signs the modules and emits vboxdrv.ko.cer and friends alongside them.

Assisted-by: Kilo Code (GLM-5.3-Flash)
(cherry picked from commit 7bd4fa6)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The custom installPhase copied acpi_call.ko manually, bypassing
scripts/Makefile.modinst. The module was therefore not stripped, not
compressed, and — since the kernel now signs modules deterministically
with kmodigest (PR NixOS#571181) — not signed and missing the per-module
certificate that the kmod aggregator expects next to every external
module, breaking the module closure of hosts using acpi_call.

Use the upstream install target, which runs the kernel's
modules_install, so modinst strips, signs and compresses the module and
emits acpi_call.ko.cer alongside it.

Assisted-by: Kilo Code (GLM-5.3-Flash)
(cherry picked from commit c270cc0)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The install phase copied system76.ko into the output by hand, bypassing
the Kbuild module installation.  Since NixOS#571181, kernelModuleMakeFlags
makes Kbuild sign each module with kmodigest during modules_install,
which also writes a certificate next to the module, and aggregateModules
merges the certificates of all external modules into modules.cer.  The
hand-copied module has neither, so building a NixOS system with
hardware.system76.enableAll fails:

    cat: misc/system76.ko.cer: No such file or directory

The upstream Makefile has no install target, so call the Kbuild
modules_install target directly, as suggested for zenpower in NixOS#575192.
It strips, signs, and compresses the module and writes its certificate.
Keep the module under misc and leave depmod to aggregateModules.  Set
INSTALL_MOD_STRIP=1, as compression now happens before the strip phase,
which used to remove the debug information.  The hwdb file moves to
postInstall.

Assisted-by: Claude (claude-opus-5-5)
(cherry picked from commit e5d3094)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
The install phase copied system76-io.ko and system76-thelio-io.ko into
the output by hand, bypassing the Kbuild module installation.
Since NixOS#571181, kernelModuleMakeFlags makes Kbuild sign each module with
kmodigest during modules_install, which also writes a certificate next
to the module, and aggregateModules merges the certificates of all
external modules into modules.cer.  The hand-copied modules have
neither, so building a NixOS system with hardware.system76.enableAll
fails:

    cat: misc/system76-thelio-io.ko.cer: No such file or directory
    cat: misc/system76-io.ko.cer: No such file or directory

The upstream Makefile has no install target, so call the Kbuild
modules_install target directly, as suggested for zenpower in NixOS#575192.
It strips, signs, and compresses the modules and writes their
certificates.  Keep the modules under misc and leave depmod to
aggregateModules.  Set INSTALL_MOD_STRIP=1, as compression now happens
before the strip phase, which used to remove the debug information.

Assisted-by: Claude (claude-opus-5-5)
(cherry picked from commit 8043407)
Mic92 pushed a commit to Mic92/nixpkgs that referenced this pull request Oct 22, 2026
…nstall

Installing the module by hand bypasses Kbuild's module installation
flow, which since NixOS#571181 is what signs each module with kmodigest and
installs its per-module certificate. The package therefore only
produced `framework_laptop.ko`, and building `system.modulesTree`
failed while concatenating the certificates of external modules:

    cat: extra/framework_laptop.ko.cer: No such file or directory

Install via `modules_install` so the module is signed and its
certificate is installed alongside it, matching the other kernel
module packages fixed in this way.

See NixOS#575192.

(cherry picked from commit e81ffa2)
B4dM4n added a commit to B4dM4n/nixpkgs that referenced this pull request Oct 23, 2026
The install already runs the kernel's `modules_install`, but without
a `cmd_sign` override the module was left unsigned and without the
per-module certificate that the kmod aggregator expects next to every
external module since PR NixOS#571181. Pass `kernelModuleMakeFlags`, which
routes the signing rule to the deterministic kmodigest.

Assisted-by: Kilo Code (GLM-5.3-Flash)
B4dM4n added a commit to B4dM4n/nixpkgs that referenced this pull request Oct 23, 2026
The install already runs the kernel's `modules_install`, but without
a `cmd_sign` override the module was left unsigned and without the
per-module certificate that the kmod aggregator expects next to every
external module since PR NixOS#571181. Pass `kernelModuleMakeFlags`, which
routes the signing rule to the deterministic kmodigest.

Assisted-by: Kilo Code (GLM-5.3-Flash)
B4dM4n added a commit to B4dM4n/nixpkgs that referenced this pull request Oct 23, 2026
Installing the module manually bypasses scripts/Makefile.modinst, so
it was neither stripped and compressed nor signed with the
deterministic kmodigest that the kernel uses since PR NixOS#571181, and no
per-module certificate was emitted. The kmod aggregator requires a
<module>.ko.cer next to every external module, breaking the module
closure of hosts using it.

Install through the new linuxPackages.kernelModuleInstallHook, so the
kernel's `modules_install` strips, signs and compresses the module and
emits the certificate.

Assisted-by: Kilo Code (GLM-5.3-Flash)
B4dM4n added a commit to B4dM4n/nixpkgs that referenced this pull request Oct 23, 2026
Installing the module manually bypasses scripts/Makefile.modinst, so
it was neither stripped and compressed nor signed with the
deterministic kmodigest that the kernel uses since PR NixOS#571181, and no
per-module certificate was emitted. The kmod aggregator requires a
<module>.ko.cer next to every external module, breaking the module
closure of hosts using it.

Install through the new linuxPackages.kernelModuleInstallHook, so the
kernel's `modules_install` strips, signs and compresses the module and
emits the certificate.

Assisted-by: Kilo Code (GLM-5.3-Flash)
B4dM4n added a commit to B4dM4n/nixpkgs that referenced this pull request Oct 23, 2026
Installing the module manually bypasses scripts/Makefile.modinst, so
it was neither stripped and compressed nor signed with the
deterministic kmodigest that the kernel uses since PR NixOS#571181, and no
per-module certificate was emitted. The kmod aggregator requires a
<module>.ko.cer next to every external module, breaking the module
closure of hosts using it.

Install through the new linuxPackages.kernelModuleInstallHook, so the
kernel's `modules_install` strips, signs and compresses the module and
emits the certificate.

Assisted-by: Kilo Code (GLM-5.3-Flash)
@sh4k095 sh4k095 mentioned this pull request Oct 24, 2026
4 of 13 tasks
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/hanging-on-boot-after-update-unstable-nixpkgs-last-week/80907/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants