Kernel Security Module Loading Denied Fix on Linux
When you get 'operation not permitted' loading a kernel module, it's usually SELinux or lockdown blocking you. Here's the quick fix.
Quick answer for advanced users: Run sudo setenforce 0 to temporarily disable SELinux, or check cat /sys/kernel/security/lockdown — if it says 'integrity' or 'confidentiality', reboot and add lockdown=none to your kernel command line. Then try sudo modprobe again.
Now the full story. You're trying to load a kernel module — maybe a network driver, a filesystem module, or something like vboxdrv for VirtualBox — and you get operation not permitted. No helpful details. Just a cold wall. This happens most often on Fedora, RHEL, CentOS, or Ubuntu with SELinux enforcing. Or on systems with kernel lockdown enabled (modern Ubuntu, Debian with secure boot). The kernel says 'no' and doesn't tell you why. But we can figure it out.
Step-by-step fix
- Check the exact error. Run
sudo modprobe <module-name> 2>&1. For example:sudo modprobe vboxdrvIf you seemodprobe: ERROR: could not insert 'vboxdrv': Operation not permitted, that's our target. - Check SELinux first. SELinux is the number one reason. Run
getenforce. If it saysEnforcing, that's your problem. Temporarily set it to permissive:sudo setenforce 0. Then try your modprobe again. If it works, SELinux was blocking you. You can either write a proper SELinux policy (more work) or keep it permissive (not recommended for production). On a test box, permissive is fine to get things running. - Check kernel lockdown. If SELinux wasn't the issue (or after setting permissive it still fails), check lockdown:
cat /sys/kernel/security/lockdown. It will saynone,integrity, orconfidentiality. If it's anything other thannone, that's blocking unsigned modules. This is common on systems with UEFI Secure Boot. To fix temporarily:sudo mokutil --disable-validationand reboot. But that turns off module signing checks. A better fix for one module: sign the module with a key enrolled in MOK (Machine Owner Key). That's more advanced — see the alternative fixes below. - Check if the module is already in kernel but blacklisted. Run
lsmod | grep <module-name>. Also check/etc/modprobe.d/for blacklist files. Sometimes modules are blacklisted to prevent loading. Comment out the line withblacklist <module-name>in files like/etc/modprobe.d/blacklist.conf. - Try loading with explicit path. Use
sudo insmod /lib/modules/$(uname -r)/kernel/drivers/.../module.ko. If insmod works but modprobe doesn't, the issue is with module dependencies or aliases. Checkdepmod -aand rerun modprobe.
Alternative fixes if the main one fails
If SELinux and lockdown aren't the problem, check these:
- File permissions on the .ko file. The module file itself must be readable by root. Run
ls -l /lib/modules/$(uname -r)/.../module.ko. If it's owned by some user or has restrictive permissions,sudo chmod 644it. That's rare but happens if you copied a module manually. - Module signature check. On systems with module signing enforced, only signed modules load. Check if signing is required:
cat /proc/config.gz | gunzip | grep CONFIG_MODULE_SIG. If it saysy, you need a signed module. Runsudo modprobe --dump-modversions module.koto see version magic — if it doesn't match your kernel, get the right version. You can also build the module from source with your kernel headers. - Kernel version mismatch. You compiled a module for kernel 5.15 but you're running 6.1? That won't load. Run
uname -rand check the module's path — it should be in/lib/modules/$(uname -r)/. If not, recompile for the right kernel.
Prevention tip
Stop this from happening again. The real fix is to set up your system right from the start. If you're running a server with SELinux, learn to write custom policies. Don't just setenforce 0 — that turns off all SELinux protection. Instead, create a policy module. Example: sudo ausearch -m avc -ts recent | audit2allow -M mymodule then sudo semodule -i mymodule.pp. That allows only the specific operation your module needs.
For kernel lockdown: enroll a signing key. On Ubuntu with Secure Boot, you can do sudo mokutil --import module-sign.der after creating a key pair with openssl req -new -x509 -newkey rsa:2048 -keyout module-sign.key -out module-sign.der. Reboot, enroll the key, then sign modules with sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 module-sign.key module-sign.der module.ko. It's a few steps but it works forever after that.
One last thing: don't forget to check
dmesg | tailright after a failed modprobe. The kernel often prints a detailed reason there — like "module verification failed" or "locking" or "permission denied". That single line tells you exactly what to fix. I've wasted hours on SELinux when the real issue was a missing module dependency that showed up in dmesg within seconds.
Was this solution helpful?