[英]insmod error in kernel module programming
我只是從模塊化編程開始。
以上是我的兩個文件:
你好ç
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk(KERN_ALERT "TEST: Hello world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "TEST: Good Bye");
}
module_init(hello_init);
module_exit(hello_exit);
生成文件
obj-m += hello.o
KDIR = /usr/src/linux-headers-3.13.0-46-generic
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.o *.ko *.mod.* *.symvers *.order
這是我的終端輸出顯示 insmod 命令中的錯誤,請幫忙。
anubhav@anubhav-Inspiron-3421:~/Desktop/os$ make
make -C /usr/src/linux-headers-3.13.0-46-generic SUBDIRS=/home/anubhav/Desktop/os modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-46-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-46-generic'
anubhav@anubhav-Inspiron-3421:~/Desktop/os$ insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Operation not permitted
如果您啟用了安全啟動,則較新的內核將不允許插入任意內核模塊。 因此,您可以在 BIOS 中禁用安全啟動,或者需要對要安裝的內核模塊進行簽名。
安全簽署內核模塊的步驟:
您需要以 root 身份執行第 2 步和第 4 步。詳細過程在一個不錯的Ubuntu 博客中有所描述。
正如 isowen 提到的,只有 root 可以加載或卸載模塊。
你看在打印hello_init()
當你做insmod hello
,你會看到在打印hello_exit()
當你rmmod hello
。
執行cat /proc/sys/kernel/modules_disabled
,如果看到結果1
則執行echo 'kernel.modules_disabled=1' >> /etc/sysctl.d/99-custom.conf
然后重新啟動echo 'kernel.modules_disabled=1' >> /etc/sysctl.d/99-custom.conf
試。 ;) BR nu11secur1ty
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.