Код: Выделить всё
olej@nvme:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: LMDE 5 (elsie)
Release: 5
Codename: elsie
Код: Выделить всё
olej@nvme:~$ uname -a
Linux nvme 5.10.0-16-amd64 #1 SMP Debian 5.10.127-2 (2022-07-23) x86_64 GNU/Linux
Код: Выделить всё
olej@nvme:~/2022/OwnBooks/BHV.kernel/examples/tools/signed$ make
make -C /lib/modules/5.10.0-16-amd64/build M=/home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed modules
make[1]: вход в каталог «/usr/src/linux-headers-5.10.0-16-amd64»
CC [M] /home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed/hello_printk.o
MODPOST /home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed/Module.symvers
CC [M] /home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed/hello_printk.mod.o
LD [M] /home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed/hello_printk.ko
make[1]: выход из каталога «/usr/src/linux-headers-5.10.0-16-amd64»
Код: Выделить всё
olej@nvme:~/2022/OwnBooks/BHV.kernel/examples/tools/signed$ sudo insmod hello_printk.ko
[sudo] пароль для olej:
Код: Выделить всё
olej@nvme:~/2022/OwnBooks/BHV.kernel/examples/tools/signed$ dmesg | tail -n4
[ 2911.727484] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[ 5397.637583] hello_printk: loading out-of-tree module taints kernel.
[ 5397.637613] hello_printk: module verification failed: signature and/or required key missing - tainting kernel
[ 5397.637804] Hello, world!
И помним, что любые, даже предупреждения, крайне опасны в программировании модулей ядра!
Код: Выделить всё
olej@nvme:~/2022/OwnBooks/BHV.kernel/examples/tools/signed$ lsmod | head -n2
Module Size Used by
hello_printk 16384 0
Код: Выделить всё
olej@nvme:~/2022/OwnBooks/BHV.kernel/examples/tools/signed$ modinfo hello_printk.ko
filename: /home/olej/2022/OwnBooks/BHV.kernel/examples/tools/signed/hello_printk.ko
author: Oleg Tsiliuric <olej.tsil@gmail.com>>
license: GPL
depends:
retpoline: Y
name: hello_printk
vermagic: 5.10.0-16-amd64 SMP mod_unload modversions