r/kernel • • 4d ago

Locking down unnecessary kernel mods

/r/linux/comments/1xzkx9o/locking_down_unnecessary_kernel_mods/
0 Upvotes

4 comments sorted by

4

u/gmes78 4d ago

slop

3

u/nuxi 4d ago

You can also just run this after boot completes and all the relevant modules are loaded:

echo 1 > /proc/sys/kernel/modules_disabled

Warning: this setting is a one way hatch, once enabled it can't be disabled without rebooting.

1

u/uziam 4d ago

I have a brilliant idea for you. Move the insmod and modprobe binaries to a flash drive and only plug it in when you want to load modules. Problem solved.

1

u/Ok_Green5623 1d ago

Interesting, didn't know you can use 'modprobe --ignore-install', but I guess it doesn't matter. What are you trying to protect against? If someone can load modules with ignore install, the same attacker can remove the blacklist, hence already have root. Module blacklist prevents implicit module loading. If you want to protect yourself against modules not in the system and not against compiling your custom kernel - just force module signature:

CONFIG_MODULE_SIG=y

CONFIG_MODULE_SIG_FORCE=y

CONFIG_MODULE_SIG_ALL=y
After that through away the signing key: rm /usr/src/linux/certs/signing_key.pem
As a bonus - you can compile just the modules you need.