.koをビルドしたけど、insmodできない
エラー
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$ make
make -C /lib/modules/5.15.0-46-generic/build M=/home/mozaki/001_build/201_DEVICE_DRIVER_STUDY modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-46-generic'
CC [M] /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/hello.o
MODPOST /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/Module.symvers
CC [M] /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/hello.mod.o
LD [M] /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/hello.ko
BTF [M] /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/hello.ko
Skipping BTF generation for /home/mozaki/001_build/201_DEVICE_DRIVER_STUDY/hello.ko due to unavailability of vmlinux # このメッセージに着目
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-46-generic'
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$ sudo /sbin/insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Operation not permitted
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$
解決方法
Step1 ビルドエラーの改善
https://askubuntu.com/questions/1348250/skipping-btf-generation-xxx-due-to-unavailability-of-vmlinux-on-ubuntu-21-04
sudo apt install dwarves
sudo cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/
Step2 Certificateされていないモジュールのロードの許可を設定(Secure bootを無効化)
https://support.avira.com/hc/en-us/articles/360003038074-How-do-I-disable-UEFI-Secure-Boot-modules
改善後
mozaki@shibusawa:~/001_build/201_DEVICE_DRIVER_STUDY$ sudo insmod ./hello.ko