Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH RFC 0/2] module: Introduce hash-based integrity checking
@ 2024-12-25 22:51 Thomas Weißschuh
  2024-12-25 22:51 ` [PATCH RFC 1/2] kbuild: add stamp file for vmlinux BTF data Thomas Weißschuh
  2024-12-25 22:52 ` [PATCH RFC 2/2] module: Introduce hash-based integrity checking Thomas Weißschuh
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2024-12-25 22:51 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier, Arnd Bergmann,
	Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez
  Cc: linux-kbuild, linux-kernel, linux-arch, linux-modules,
	Thomas Weißschuh

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 key is used, which precludes
rebuilds by third parties and makes the whole build and packaging
process much more complicated.
Introduce a new mechanism to ensure only well-known modules are loaded
by embedding a list of hashes of all modules built as part of the full
kernel build into vmlinux.

To properly test the reproducibility in combination with BTF the patch
"[PATCH bpf-next] kbuild, bpf: Enable reproducible BTF generation" [0]
is also needed.

Questions for current patch:
* Naming
* Can the number of built-in modules be retrieved while building
  kernel/module/hashes.o? This would remove the need for the
  preallocation step in link-vmlinux.sh.

Further improvements:
* Use a LSM/IMA/Keyring to store and validate hashes
* Make compatible with lockdown
* Use MODULE_SIG_HASH for configuration
* Enable coexistence with MODULE_SIG
* Set mod->sig_ok()
* UAPI for discovery?

[0] https://lore.kernel.org/lkml/20241211-pahole-reproducible-v1-1-22feae19bad9@weissschuh.net/

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (2):
      kbuild: add stamp file for vmlinux BTF data
      module: Introduce hash-based integrity checking

 Makefile                          |  8 +++++-
 include/asm-generic/vmlinux.lds.h | 11 +++++++++
 include/linux/module_hashes.h     | 17 +++++++++++++
 kernel/module/Kconfig             | 11 +++++++++
 kernel/module/Makefile            |  1 +
 kernel/module/hashes.c            | 51 +++++++++++++++++++++++++++++++++++++++
 kernel/module/internal.h          |  9 +++++++
 kernel/module/main.c              |  4 +++
 scripts/Makefile.modfinal         |  4 +--
 scripts/Makefile.vmlinux          |  5 ++++
 scripts/link-vmlinux.sh           | 31 +++++++++++++++++++++++-
 scripts/module-hashes.sh          | 26 ++++++++++++++++++++
 12 files changed, 174 insertions(+), 4 deletions(-)
---
base-commit: f722972b5df307d8c93c706c62d2e27e963c8f66
change-id: 20241225-module-hashes-7a50a7cc2a30

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-01-13 15:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-25 22:51 [PATCH RFC 0/2] module: Introduce hash-based integrity checking Thomas Weißschuh
2024-12-25 22:51 ` [PATCH RFC 1/2] kbuild: add stamp file for vmlinux BTF data Thomas Weißschuh
2024-12-25 22:52 ` [PATCH RFC 2/2] module: Introduce hash-based integrity checking Thomas Weißschuh
2025-01-04  1:37   ` Luis Chamberlain
2025-01-04  6:30     ` Thomas Weißschuh
2025-01-08 19:08       ` Luis Chamberlain
2025-01-13  9:15     ` Fabian Grünbichler
2025-01-09 10:52   ` Arnout Engelen
2025-01-10 19:16     ` Luis Chamberlain
2025-01-13 15:09       ` Petr Pavlu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox