Your Linux system has +6,000 kernel modules which can be autoloaded. You use 80 of them. ModuleJail blacklist all of the unused ones. Server and desktop profiles and much more in a simple shell script.

Posted by Vegetable-Escape7412@reddit | linuxadmin | View on Reddit | 19 comments

Hey r/linuxadmin. I'm the author of this so I'm flagging that up front - this is a "would love feedback from people running real fleets" post.

The problem. Modern distro kernels ship with thousands of loadable modules. Almost all of them are attack surface that you're paying for in availability (autoload via udev, hotplug, dependency resolution) but not using. With AI-assisted kernel vulnerability discovery accelerating, every module a host can load but doesn't need to load is a problem you'd rather not have.

ModuleJail walks lsmod, treats whatever is loaded right now as "necessary," and writes a modprobe.d blacklist file for everything else. Optionally adds a --whitelist-file for modules you want preserved even if they're not currently loaded (think: rarely-used filesystem drivers you mount once a quarter).

What it isn't.

- Not a vulnerability scanner. The model is "unused, therefore blacklisted," not "vulnerable, therefore blacklisted."

- Not a defense against an attacker who already has root - they can rm the file. It's about reducing the unprivileged-trigger / autoload paths.

- Not initramfs-aware. Modules baked into the initrd are out of scope.

- Not a daemon, not a monitor. Single POSIX shell script, runs once, writes one file in /etc/modprobe.d/.

Revert.

rm /etc/modprobe.d/modulejail-blacklist.conf

and you're back. No reboot needed - the kernel reads modprobe.d at load time. Explicit sudo modprobe foo always wins over the blacklist, by design.

What I want feedback on. What does this need before you'd run it across a fleet? Things I've heard so far: an Ansible role, a --dry-run flag, JSON output for diff-friendly state tracking, kernel-version pinning in the generated file header. What else?

Repo: github.com/jnuyens/modulejail

License: GPL-3.0

Packaging: .deb and .rpm on the releases page; AUR package today.