I write a simple hello world kernel module in Linux and I tried to load it to the kernel. but it was not possible because I get this error while I want to load it.
module verification failed: signature and/or required key missing - tainting kernel
I tried to find a solution for that but all of that found was about VM and not a real system.
my secure boot is disabled and I don't want to change kernel config and rebuild it.
I also tried to create a key with openssl and MOK and enroll it but in the last step that tries to sign module, I stopped because of No such file or directory error.
I can't find /scripts/sign-file in /usr/lib/linux-headers-5.11.0-16-generic
I followed the answer to this question:
https://unix.stackexchange.com/questions/560895/sign-kernel-modules
I am completely confused!
can anyone help me??
my os is ubuntu and the kernel version is 5.11.0-16
UPDATE: now I understand my module seems to be signed via command modinfo hello.ko and this is the result:
$ modinfo hello.ko
filename: /home/###/Documents/kernel/hello.ko
description: This is the module description.
author: ###
license: Dual BSD/GPL
depends:
retpoline: Y
name: hello
vermagic: 5.11.0-16-generic SMP mod_unload modversions
sig_id: PKCS#7
signer: ###
sig_key: 58:26:4E:F2:6A:5F:2F:DB:F0:21:E0:8C:79:60:E9:C8:78:38:01:3F
sig_hashalgo: sha256
signature: 67:F2:74:BF:6A:AB:D4:AD:6C:EA:BD:35:D6:7A:9A:94:0F:C7:0F:6B:
AD:10:18:26:D1:D9:8A:07:DD:89:36:03:D0:C9:AA:10:A1:52:71:A0:
CF:D0:7D:C6:2E:D7:E2:B1:AF:1D:45:A4:97:13:23:23:C8:B7:99:6D:
4A:F9:60:B7:64:D0:E4:3C:EE:74:9F:68:D2:C5:EC:C0:C9:F3:09:76:
EF:B5:C4:46:62:36:1B:95:EC:4A:D3:4D:B7:2F:87:71:E1:D2:D7:ED:
EE:F3:04:58:3F:F9:EA:16:4C:39:BD:B5:50:60:FC:A7:96:AF:03:74:
F0:03:76:98:95:91:A9:5A:1B:50:17:8A:71:A2:C0:D6:B4:DD:D3:50:
FE:2A:05:29:03:D6:E6:A0:69:F4:18:44:2B:EC:F6:41:6D:A3:E7:EF:
10:3D:98:A8:33:21:56:0E:D6:8E:67:88:18:7F:31:DB:2E:CA:70:F7:
7E:03:42:04:F5:99:64:BD:EE:0F:04:DA:56:50:B5:2E:7A:B7:AE:D0:
ED:07:6B:86:89:45:38:B4:7C:FE:B9:B3:F4:5D:17:1B:6F:04:33:52:
BE:0E:1F:D3:CA:F1:9D:17:AD:EC:A4:DC:84:25:47:73:ED:02:9E:74:
4C:AD:25:35:2B:E4:C0:BE:15:F2:FF:99:CE:89:82:E6
but still I get error while inserting module:
$ sudo insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Invalid module format
A workaround is to build the module with that line in Makefile:
#this line fix the problem. tomrtc
CONFIG_MODULE_SIG=n
Related
I followed the instructions in this video to compile the Linux kernel for WSL with video drivers. The kernel is running and I do have access to /dev/video0 which was the whole point.
I can also confirm that the correct kernel is running with uname -a, which gives the following output:
Linux DESKTOP-V575QHO 5.15.74.2-microsoft-standard-WSL2+ #1 SMP Wed Dec 7 14:57:03 CET 2022 x86_64 x86_64 x86_64 GNU/Linux
I now installed dkms and used it to compile the akvcam module (a virtual camera driver). Both make and make dkms_install exited successfully.
However, when I'm actually trying to install the module using insmod /lib/modules/$(uname -r)/updates/dkms/akvcam.ko I get the following error:
insmod: ERROR: could not insert module /lib/modules/5.15.74.2-microsoft-standard-WSL2+/updates/dkms/akvcam.ko: Operation not permitted
I've seen here that this might be related to Secure Boot, but I don't really understand how this would translate to WSL2 and how this problem could be solved here.
Any help is greatly appreciated!
When i want to load driver module of Wo Mic on Ubuntu 14.04 i get this error in Terminal :
insmod: ERROR: could not insert module wo_snd_capture-x86_64.ko: Invalid parameters
I follow the Wo Mic instruction for load module like the official website of Wo Mic.
In Wo Mic Official websit :
Change client program to be executable
$ chmod a+x micclient-ubuntu-x86_64
Load driver module
$ sudo insmod wo_snd_capture-x86_64.ko
But when i enter this sudo insmod wo_snd_capture-x86_64.ko in Terminal i get above Error .
How can i solve this problem ?
This is because wo_snd_capture-x86_64.ko module was compiled for different kernel version than yours.
$ modinfo ./wo_snd_capture-x86_64.ko
filename: .../wo_snd_capture-x86_64.ko
license: GPL
srcversion: E535A4C547FF773D30C0B16
depends: snd-pcm,snd
vermagic: 4.4.0-62-generic SMP mod_unload modversions
Note that version in vermagic. You can check your kernel version with uname -a. Your version is different.
As you can see, it is GPL licenced, so just ask authors of this module for source code and you will be able to recompile this module by yourself every time you upgrade your kernel.
I have a problem with one of my kernel modules for Linux 4 tegra on the Jetson tk1. I'm trying to integrate a Camera driver into the kernel
I'm trying to insert a module into the kernel and I've compiled everything on the target machine. Here's the modinfo of the kernel module.
filename: /home/ubuntu/mymodule.ko
license: GPL v2
author: John Doe
description: SoC Camera driver
alias: of:N*T*Cnvidia,mymodule*
alias: i2c:mymodule
depends:
vermagic: 3.10.40-svn469 SMP preempt mod_unload ARMv7 p2v8
parm: test_pattern:int
The uname -r command outputs this :
3.10.40-svn469
I still get this output when I am running sudo insmod mymodule.ko
insmod: ERROR: could not insert module mymodule.ko: Invalid module format
I've tried looking into the dmesg/syslog/kern log files but there's no information about why my module insertion is failing. I also looked around on other threads and it usually says to verify that the module was compiled using the correct headers. From my understanding, is the "vermagic" and the "uname -r" are similar I'm assuming that the versions are correct (I might be very wrong about that).
I'm running out of ideas and I'd like to know if I missed something.
Cheers.
I have cross compiled a simple helloworld kernel module, the host is a x86 machine and the target an ARM board. When I do modprobe to install the module in the target i get this message:
FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
I have make sure that the module is compiled with the same version as the target.
uname -a : 3.14.0-xilinx-13567-g906a2c9-dirty
modinfo: vermagic: 3.14.0-xilinx-13567-g906a2c9-dirty SMP preempt mod_unload modversions ARMv7 p2v8
What can be the problem? What does that error means?
Apparently, you are missing the file specifying module dependencies (generated at build time and installed with make module_install).
The simplest solution is, if your mdule does not have external dependencies, insert it with insmod rather than with modprobe.
Try to run:
depmod -a
on the ARM board.
it should solve your problem.
I would suggest the following steps.
Do insmod $module-name
Check the dmesg commands output. If you see the following message
version magic '3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxx' should be
'3.14.0-xilinx-13567-g906a2c9-dirty xxxxxxxxxx'
then the problem is because of the changes made to the kernel.
Commit the changes to the git repository and re-build the kernel.
Create a new kernel image and then boot the target with the updated kernel.
I have got one of the small raspberry pi computers, and i am having my first play with creating a kernel module. I have downloaded the source, and managed to compile my test module but when i try and load it i get this error:
insmod: error inserting 'hello.ko': -1 Invalid module format
and when i look in dmesg i see this error:
hello: version magic '3.1.9+ mod_unload modversions ARMv6 p2v8 ' should be '3.1.9+ mod_unload modversions ARMv6 '
Can anyone point me in the right direction, i'm not sure what its telling me?
Cheers
Luke
It sounds like the kernel source you downloaded does not match the kernel installed on your Pi.
Where did you download it from?
To get the correct source for your kernel type the following on the command line:
sudo apt-get install linux-source
This should download the correct kernel source for you kernel (it is a meta-package). You should now see a directory under /lib/modules/ that matches your kernel version (the version printed out when you type uname -r)
Recompile and link you code - make sure you pick up the correct kernel source by having a line like this in your Makefile:
all:
make -C /lib/modules/$(shell uname -r)/build M=${PWD} modules
You newly compiled .ko module should now match you kernel and insert without complaints.
Good luck!