insmod: ERROR could not insert module: Operation not permitted in WSL2 Ubuntu - wsl-2

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!

Related

Kernel version not correct on ubuntu

I have this situation:
Ubuntu 16.04;
When I called uname -a result is Linux pi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux.
The problem is when I want to compile new drivers, the system gives me the error:
make[1]: *** /lib/modules/4.1.19-v7+/build: No such file or directory. Stop.
But when I looked at /lib/modules/, I find only version 4.4.38-v7+.
Maybe someone knows what it can be?
Thanks.
You need to have kernel-headers installed for the kernel version that you are trying to compile for.
sudo apt-get install linux-headers-$(uname -r)
You have kernel headers for 4.4.38-v7+, but not for your booted kernel of 4.1.19-v7+ (uname -r)
If you don't want to install 4.1.19-v7+ kernel-headers, reboot the system and boot into 4.4.38-v7+, and then try make, and it would compile the module for that particular kernel.

Invalid module format with matching vermagic value

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.

Error when loading cross compiled kernel module

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.

Video4Linux Loopback Device on Linux4Tegera

I am interfacing Bumblebee2 camera with Nvidia Tegra TK1 board. I have installed firewire1394 driver along with coriander 2.0.2 to get the camera output and it is working fine. But I am not able to load the video for Linux module. I have installed the following two packages as well using synaptic
v4l2loopback-utils
qv4l2
I have following version of Linux kernel on Nvida Tegra TK1 board.
uname -a
Linux tegra-ubuntu 3.10.40-grinch-21.3.4 #1 SMP PREEMPT Fri May 1 10:41:09 UTC 2015 armv7l armv7l armv7l GNU/Linux
I downloaded the stable version of Video4Linux Loopback Device from here
I follow the steps mentioned in the readme file and when I tried to make it, I got the following errors.
make -C /lib/modules/3.10.40-grinch-21.3.4/build SUBDIRS=/home/ubuntu/vloopback modules
make: *** /lib/modules/3.10.40-grinch-21.3.4/build: No such file or directory. Stop.
make: *** [all] Error 2
I would appreciate if someone can help me to install video for Linux loopback device.
Current running kernel Linux tegra-ubuntu 3.10.40-grinch-21.3.4 does not have v4l2loopback support. I used module assistant to compile v4l2loopback module.
sudo aptitude install v4l2loopback-source module-assistant
sudo module-assistant auto-install v4l2loopback-source
Don't forget to mention the current running kernel headers. Then build and make v4l2loopback from here

Make kernel module for BeagleBoneBlack

I have a BBB with Linux pre-installed from the vendor. Here is output from uname -a:
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
I am trying to make a Kernel Module, for example HelloWorld.ko for it.
I cloned code from git://github.com/RobertCNelson/linux-dev.git and checkout origin/am33x-v3.8. After I built a module on it and tried to insmod it on my BBB, I got error message:
Error: could not insert module Hello.ko: Invalid module format,
I double checked version of the kernel, it is 3.8.13-bone53. Is this the root cause? Where can I get the "exactly" matched kernel source tree for it? There is no version named 3.8.13 in my cloned git commit tree.
Thanks for your help!

Resources