A Kees Cook implementou um sysctl para preencher essa necessidade no início de 2009. Conforme documentado em Documentation / sysctl / kernel .txt :
modules_disabled
:A toggle value indicating if modules are allowed to be loaded in an otherwise modular kernel. This toggle defaults to off (
0
), but can be set true (1
). Once true, modules can be neither loaded nor unloaded, and the toggle cannot be set back to false. Generally used with the "kexec_load_disabled" toggle.
Como mencionado, isso deve ser usado com kexec_load_disabled
se o objetivo for controlar qual código está ativo no kernelspace:
kexec_load_disabled
:A toggle indicating if the kexec_load syscall has been disabled. This value defaults to
0
(false: kexec_load enabled), but can be set to1
(true: kexec_load disabled). Once true, kexec can no longer be used, and the toggle cannot be set back to false. This allows a kexec image to be loaded before disabling the syscall, allowing a system to set up (and later use) an image without it being altered. Generally used together with the "modules_disabled" sysctl.