0

I have a gentoo installation, where I previously issued make mrproper inside /usr/src/linux.

I wanted to install VirtualBox modules so I copied /boot/System.map and /boot/config to /usr/src/linux (the config was copied to /usr/src/linux/.config).

I then ran:

 emerge -1 =app-emulation/virtualbox-modules-4.3.32

Which issued the following warning:

make[3]: Entering directory '/usr/src/linux-3.18.25-gentoo-r1'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
echo >&2;                           \
echo >&2 "  ERROR: Kernel configuration is invalid.";       \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
echo >&2 ;                          \
/bin/false)
mkdir -p /var/tmp/portage/app-emulation/virtualbox-modules-4.3.32/work/vboxpci/.tmp_versions ; rm -f /var/tmp/portage/app-emulation/virtualbox-modules-4.3.32/work/vboxpci/.tmp_versions/*

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

emerge didn't fail, but when it finished, I failed to load the module:

 # modprobe -v vboxdrv
insmod /lib/modules/3.18.25-gentoo-r1-09-07-2015/misc/vboxdrv.ko 
modprobe: ERROR: could not insert 'vboxdrv': Exec format error

Can anyone give me an advice how to solve this problem?

1

you most likely have the module signing option enabled in the kernel. VirtualBox modules are not automatically signed and everytime I build a new kernel I rebuild the modules and sign them.

If that is the case - type into terminal the following (if you embedded the kernel config in proc):

zcat /proc/config.gz | grep CONFIG_MODULE_SIG

If you didn't embed the kernel config, find your kernel configuration - it may be in /usr/src/linux/.config or /etc/kernels/kernel-config-<the-corresponding-kernel-version>

For example, you should see the following or similar output (YMMV):

CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_FORCE=y
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
# CONFIG_MODULE_SIG_SHA256 is not set
# CONFIG_MODULE_SIG_SHA384 is not set
CONFIG_MODULE_SIG_SHA512=y
CONFIG_MODULE_SIG_HASH="sha512"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

Depending on what hash function is chosen, you should use the same hashing function to sign your modules. There is a utility called sign-file.
In earlier versions this sign-file was located in /usr/src/linux/, as for 4.5 kernels it is now located in /usr/src/linux/scripts/ (again YMMV).

Having signed modules enabled and actually booting a system with signed modules should usually mean that you already have a generated key and a x509 file (you can generate a signing key yourself).

Executing the following command:

/usr/src/linux/scripts/sign-file sha512 /usr/src/linux/certs/signing_key.pem /usr/src/linux/certs/signing_key.x509 /lib/modules/<your-kernel-version>/misc/vboxdrv.ko

should effectively sign your modules and should be ready for modprobe.

Locate the x509 file and your signing key, and replace the paths in the command above.

  • FYI there are 4 virtualbox modules that need signing - vboxdrv, vboxnetflt, vboxnetadp and vboxpci.

Link to the official Gentoo Module signing article

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.