I think I found a way to make disabling kernel module loading (via /proc/sys/kernel/modules_disabled
) easier for server admins. Right now there’s kind of a weird problem on some distros where reading /etc/modules
races with reading /etc/sysctl.{conf,d}
. In these cases, you can’t just put “kernel.modules_disabled=1
” in the latter since you might not have finished loading modules from /etc/modules
.
Before now, on my own systems, I’d added the sysctl call to my /etc/rc.local
, which seems like a hack — that file is related to neither sysctl nor modules and both subsystems have their own configuration files, but it does happen absolutely last.
Instead, I’ve now defined “disable
” as a modprobe alias via /etc/modprobe.d/disable.conf
:
# To disable module loading after boot, "modprobe disable" can be used to # set the sysctl that controls module loading. install disable /sbin/sysctl kernel.modules_disabled=1
And then in /etc/modules
I can list all the modules I actually need, and then put “disable
” on the last line. (Or, if I want to not remember the sysctl path, I can manually run “modprobe disable
” to turn off modules at some later point.)
I think it’d be cool this this become an internal alias in upstream kmod.
© 2012, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 License.