所有 DKMS 管理的模块均因“Exec 格式错误”而失败

所有 DKMS 管理的模块均因“Exec 格式错误”而失败

在我的 Ubuntu 18.04 机器上,所有 DKMS 管理的内核模块在加载时都开始失败。我注意到了这一点,acpi_call所以让我用它来演示一下:

# uname -r
4.15.0-99-generic

# modinfo acpi_call.ko 
filename:       /lib/modules/4.15.0-99-generic/updates/dkms/acpi_call.ko
license:        GPL
srcversion:     72B6FB9451F0D2139482F11
depends:        
retpoline:      Y
name:           acpi_call
vermagic:       4.15.0-99-generic SMP mod_unload 
signat:         PKCS#7
signer:         
sig_key:        
sig_hashalgo:   md4

# modprobe acpi_call
modprobe: ERROR: could not insert 'acpi_call': Exec format error

我尝试使用 DKMS 重新安装它,但无济于事:

# dkms status acpi-call
acpi-call, 1.1.0, 4.15.0-99-generic, x86_64: installed

# dkms remove acpi-call/1.1.0 --all

-------- Uninstall Beginning --------
Module:  acpi-call
Version: 1.1.0
Kernel:  4.15.0-99-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

acpi_call.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.15.0-99-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod...

DKMS: uninstall completed.

------------------------------
Deleting module version: 1.1.0
completely from the DKMS tree.
------------------------------
Done.

# dkms install acpi-call/1.1.0

Creating symlink /var/lib/dkms/acpi-call/1.1.0/source ->
                 /usr/src/acpi-call-1.1.0

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j8 KERNELRELEASE=4.15.0-99-generic -C /lib/modules/4.15.0-99-generic/build M=/var/lib/dkms/acpi-call/1.1.0/build...
Signing module:
 - /var/lib/dkms/acpi-call/1.1.0/4.15.0-99-generic/x86_64/module/acpi_call.ko
Nothing to do.
cleaning build area...

DKMS: build completed.

acpi_call.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.15.0-99-generic/updates/dkms/

depmod...

DKMS: install completed.

# modprobe acpi_call
modprobe: ERROR: could not insert 'acpi_call': Exec format error

其他模块也/lib/modules/4.15.0-99-generic/updates/dkms表现出完全相同的问题。

我也尝试过modprobe -f,但出现了不同的错误信息:

# modprobe -f acpi_call
modprobe: ERROR: could not insert 'acpi_call': Required key not available

这让我MOK兔子洞但即使在注册了新的 MOK 并sign-file检查了.ko文件后,我仍然收到Required key not available错误。如果我禁用验证,则modprobe -f仍然会失败Exec format error

另外,我注意到了这一行dmesg

[  617.320431] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 0000000057734886, val ffffffffc0d56a43

这里出了什么问题?我该如何解决?

答案1

事实证明,问题在于我的系统上的默认 GCC 已更改为 GCC-9(由于freehdl升级失败,但无论如何)。这导致用于使用 DKMS 构建模块的 GCC 版本与用于构建 Ubuntu 内核的 GCC 版本不同(并且显然不兼容 ABI?)。

降级回 GCC-7(并重建所有 DKMS 模块)后,一切现在都像以前一样运行,包括安全启动支持。

相关内容