@@ -270,9 +270,12 @@ config MODULE_SIG
270270 debuginfo strip done by some packagers (such as rpmbuild) and
271271 inclusion into an initramfs that wants the module size reduced.
272272
273+ config MODULE_SIG_POLICY
274+ def_bool MODULE_SIG || MODULE_HASHES
275+
273276config MODULE_SIG_FORCE
274277 bool "Require modules to be validly signed"
275- depends on MODULE_SIG
278+ depends on MODULE_SIG_POLICY
276279 help
277280 Reject unsigned modules or signed modules for which we don't have a
278281 key. Without this, such modules will simply taint the kernel.
@@ -286,7 +289,7 @@ config MODULE_SIG_ALL
286289 modules must be signed manually, using the scripts/sign-file tool.
287290
288291comment "Do not forget to sign required modules with scripts/sign-file"
289- depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL
292+ depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL && !MODULE_HASHES
290293
291294choice
292295 prompt "Hash algorithm to sign modules"
@@ -405,6 +408,28 @@ config MODULE_DECOMPRESS
405408
406409 If unsure, say N.
407410
411+ config MODULE_HASHES
412+ bool "Module hash validation"
413+ depends on !MODULE_SIG_ALL
414+ depends on !IMA_APPRAISE_MODSIG
415+ select MODULE_SIG_FORMAT
416+ select CRYPTO_LIB_SHA256
417+ help
418+ Validate modules by their hashes.
419+ Only modules built together with the main kernel image can be
420+ validated that way.
421+
422+ This is a reproducible-build compatible alternative to a build-time
423+ generated module keyring, as enabled by
424+ CONFIG_MODULE_SIG_KEY=certs/signing_key.pem.
425+
426+ Also see the warning in MODULE_SIG about stripping modules.
427+
428+ # To validate the consistency of INSTALL_MOD_STRIP for MODULE_HASHES
429+ config MODULE_INSTALL_STRIP
430+ string
431+ default "$(INSTALL_MOD_STRIP)"
432+
408433config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS
409434 bool "Allow loading of modules with missing namespace imports"
410435 help
0 commit comments