@@ -271,9 +271,12 @@ config MODULE_SIG
271271 debuginfo strip done by some packagers (such as rpmbuild) and
272272 inclusion into an initramfs that wants the module size reduced.
273273
274+ config MODULE_AUTH
275+ def_bool MODULE_SIG || MODULE_HASHES
276+
274277config MODULE_SIG_FORCE
275278 bool "Require modules to be validly signed"
276- depends on MODULE_SIG
279+ depends on MODULE_AUTH
277280 help
278281 Reject unsigned modules or signed modules for which we don't have a
279282 key. Without this, such modules will simply taint the kernel.
@@ -288,7 +291,7 @@ config MODULE_SIG_ALL
288291 modules must be signed manually, using the scripts/sign-file tool.
289292
290293comment "Do not forget to sign required modules with scripts/sign-file"
291- depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL
294+ depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL && !MODULE_HASHES
292295
293296choice
294297 prompt "Hash algorithm to sign modules"
@@ -403,6 +406,28 @@ config MODULE_DECOMPRESS
403406
404407endif # MODULE_COMPRESS
405408
409+ config MODULE_HASHES
410+ bool "Hash-based module authentication"
411+ depends on !MODULE_SIG_ALL
412+ depends on !IMA_APPRAISE_MODSIG
413+ select MODULE_SIG_FORMAT
414+ select CRYPTO_LIB_SHA256
415+ help
416+ Validate modules by their hashes.
417+ Only modules built together with the main kernel image can be
418+ validated that way.
419+
420+ This is a reproducible-build compatible alternative to a build-time
421+ generated module keyring, as enabled by
422+ CONFIG_MODULE_SIG_KEY=certs/signing_key.pem.
423+
424+ Also see the warning in MODULE_SIG about stripping modules.
425+
426+ # To validate the consistency of INSTALL_MOD_STRIP for MODULE_HASHES
427+ config MODULE_INSTALL_STRIP
428+ string
429+ default "$(INSTALL_MOD_STRIP)"
430+
406431config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS
407432 bool "Allow loading of modules with missing namespace imports"
408433 help
0 commit comments