Skip to content

module: Introduce hash-based integrity checking

Thomas Weißschuh bpf linux-arch linux-doc linux-integrity linux-kbuild linux-modules linux-security-module linuxppc-dev lkml sashiko 5 versions – In review

Get series with b4
b4 am [email protected] change-id 20241225-module-hashes-7a50a7cc2a30

Versions newest first

  1. v5 Latest14 patches 13 repliesIn review
  2. v417 patches 61 repliesSuperseded
  3. v39 patches 23 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v26 patches10 repliesSuperseded
v1 RFC2 patches7 repliesSuperseded

Changes in v5 from the cover letter

- Document tree layout.
- Make scripts/module-merkle-tree more robust.
- Remove all changes to link-vmlinux.sh, use vmlinux.unstripped instead.
- Clean up types and logic in modules-merkle-tree.c.
- Use "auth" over "integrity" naming scheme.
- Reduce the changes to the existing authentication flow.
- Explicitly send the series to BTF folks for review of BTF changes.
- Link to v4: https://patch.msgid.link/[email protected]

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14kbuild: generate module BTF based on vmlinux.unstrippedscripts/Makefile.modfinal+7 -50 replies
2/14lockdown: Make the relationship to MODULE_SIG a dependencysecurity/lockdown/Kconfig+1 -11 reply
3/14kbuild: rename the strip_relocs commandscripts/Makefile.vmlinux+4 -40 replies
4/14module: Drop pointless debugging messagekernel/module/signing.c+0 -20 replies
5/14module: Make mod_verify_sig() statickernel/module/internal.h kernel/module/signing.c+1 -20 replies
6/14module: Switch load_info::len to size_tkernel/module/internal.h kernel/module/main.c+2 -22 replies
7/14module: Make module authentication usable without MODULE_SIGcrypto/algapi.c include/linux/module.h kernel/module/Kconfig +5 more+54 -393 replies
8/14module: Move authentication logic into dedicated new filekernel/module/auth.c kernel/module/internal.h kernel/module/main.c +1 more+103 -921 reply
9/14module: Move signature type check out of mod_check_sig()kernel/module/auth.c kernel/module_signature.c security/integrity/ima/ima_modsig.c+11 -71 reply
10/14module: Prepare for additional module authentication mechanismskernel/module/auth.c kernel/module/internal.h+14 -111 reply
11/14module: update timestamp of modules.order after modules are builtscripts/Makefile.modfinal+7 -00 replies
12/14module: Introduce hash-based integrity checking.gitignore Documentation/kbuild/reproducible-builds.rst Makefile +18 more+677 -60 replies
13/14kbuild: move handling of module stripping to Makefile.libscripts/Makefile.lib scripts/Makefile.modinst+37 -321 reply
14/14kbuild: make CONFIG_MODULE_HASHES compatible with module stripping.gitignore kernel/module/Kconfig scripts/Makefile.modfinal +2 more+18 -31 reply

Reviews trailers per patch

9 of 14 patches have a Reviewed-by or Acked-by.

PatchNicolas SchierPaul MooreAaron TomlinEric BiggersPetr Pavlu
1/14R-b
2/14R-b A-b
3/14
4/14
5/14R-b R-b R-b
6/14R-b A-b
7/14
8/14R-b
9/14R-b
10/14R-b
11/14
12/14
13/14R-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/14] module: Introduce hash-based integrity checking

The current signature-based module integrity checking has some drawbacks in combination with reproducible builds. Either the module signing key is generated at build time, which makes the build unreproducible, or a static signing key is used, which precludes rebuilds by third parties and makes the whole build and packaging process much more complicated.

The goal is to reach bit-for-bit reproducibility. Excluding certain parts of the build output from the reproducibility analysis would be error-prone and force each downstream consumer to introduce new tooling.

Introduce a new mechanism to ensure only well-known modules are loaded by embedding a merkle tree root of all modules built as part of the full kernel build into vmlinux.

Interest has been proclaimed by Arch Linux, Debian, Proxmox, SUSE, NixOS and the general reproducible builds community.

Compatibility with IMA modsig is not provided yet. It is still unclear to me if it should be hooked up transparently without any changes to the policy or it should require new policy options.

BPF/BTF folks, please take a look at patch 1.

Further improvements:
* Use MODULE_SIG_HASH for configuration
* UAPI for discovery?

To: Nathan Chancellor <[email protected]>
To: Nicolas Schier <[email protected]>
To: Arnd Bergmann <[email protected]>
To: Luis Chamberlain <[email protected]>
To: Petr Pavlu <[email protected]>
To: Sami Tolvanen <[email protected]>
To: Daniel Gomez <[email protected]>
To: Paul Moore <[email protected]>
To: James Morris <[email protected]>
To: Serge E. Hallyn <[email protected]>
To: Jonathan Corbet <[email protected]>
To: Madhavan Srinivasan <[email protected]>
To: Michael Ellerman <[email protected]>
To: Nicholas Piggin <[email protected]>
To: Christophe Leroy <[email protected]>
To: Naveen N Rao <[email protected]>
To: Mimi Zohar <[email protected]>
To: Roberto Sassu <[email protected]>
To: Dmitry Kasatkin <[email protected]>
To: Eric Snowberg <[email protected]>
To: Nicolas Schier <[email protected]>
To: Daniel Gomez <[email protected]>
To: Aaron Tomlin <[email protected]>
To: Christophe Leroy (CS GROUP) <[email protected]>
To: Nicolas Schier <[email protected]>
To: Nicolas Bouchinet <[email protected]>
To: Xiu Jianfeng <[email protected]>

---
Changes in v5:
- Document tree layout.
- Make scripts/module-merkle-tree more robust.
- Remove all changes to link-vmlinux.sh, use vmlinux.unstripped instead.
- Clean up types and logic in modules-merkle-tree.c.
- Use "auth" over "integrity" naming scheme.
- Reduce the changes to the existing authentication flow.
- Explicitly send the series to BTF folks for review of BTF changes.
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
- Use as Merkle tree over a linera list of hashes.
- Provide compatibilith with INSTALL_MOD_STRIP
- Rework commit messages.
- Use vmlinux.unstripped over plain "vmlinux".
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Rebase on v6.15-rc1
- Use openssl to calculate hash
- Avoid warning if no modules are built
- Simplify module_integrity_check() a bit
- Make incompatibility with INSTALL_MOD_STRIP explicit
- Update docs
- Add IMA cleanups
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Drop RFC state
- Mention interested parties in cover letter
- Expand Kconfig description
- Add compatibility with CONFIG_MODULE_SIG
- Parallelize module-hashes.sh
- Update Documentation/kbuild/reproducible-builds.rst
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Thomas Weißschuh (14):
kbuild: generate module BTF based on vmlinux.unstripped
lockdown: Make the relationship to MODULE_SIG a dependency
kbuild: rename the strip_relocs command
module: Drop pointless debugging message
module: Make mod_verify_sig() static
module: Switch load_info::len to size_t
module: Make module authentication usable without MODULE_SIG
module: Move authentication logic into dedicated new file
module: Move signature type check out of mod_check_sig()
module: Prepare for additional module authentication mechanisms
module: update timestamp of modules.order after modules are built
module: Introduce hash-based integrity checking
kbuild: move handling of module stripping to Makefile.lib
kbuild: make CONFIG_MODULE_HASHES compatible with module stripping

 .gitignore                                   |   2 +
 Documentation/kbuild/reproducible-builds.rst |   5 +-
 Makefile                                     |   7 +-
 crypto/algapi.c                              |   4 +-
 include/asm-generic/vmlinux.lds.h            |  11 +
 include/linux/module.h                       |  18 +-
 include/linux/module_hashes.h                |  29 ++
 include/uapi/linux/module_signature.h        |   1 +
 kernel/module/Kconfig                        |  29 +-
 kernel/module/Makefile                       |   2 +
 kernel/module/auth.c                         | 139 +++++++++
 kernel/module/hashes.c                       |  95 ++++++
 kernel/module/hashes_root.c                  |   6 +
 kernel/module/internal.h                     |  18 +-
 kernel/module/main.c                         |  16 +-
 kernel/module/signing.c                      | 113 +-------
 kernel/module_signature.c                    |   8 +-
 scripts/.gitignore                           |   1 +
 scripts/Makefile                             |   4 +
 scripts/Makefile.lib                         |  32 +++
 scripts/Makefile.modfinal                    |  28 +-
 scripts/Makefile.modinst                     |  44 +--
 scripts/Makefile.vmlinux                     |  40 ++-
 scripts/include/xalloc.h                     |  29 ++
 scripts/link-vmlinux.sh                      |   3 +-
 scripts/modules-merkle-tree.c                | 416 +++++++++++++++++++++++++++
 security/integrity/ima/ima_modsig.c          |   5 +
 security/lockdown/Kconfig                    |   2 +-
 tools/include/uapi/linux/module_signature.h  |   1 +
 29 files changed, 919 insertions(+), 189 deletions(-)

---
base-commit: 585c2e775b12ef45bdf9cef5f679dcb1220e0d65
change-id: 20241225-module-hashes-7a50a7cc2a30

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>