I am unable to compile the following kernel module. I am trying to implement a litte syscall with SYSCALL_DEFINE0
which does pretty much nothing. Here is the kernel module:
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/syscalls.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include <linux/kthread.h>
#include <linux/wait.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/slab.h>
MODULE_LICENSE("GPL");
#ifndef __NR_TESTSYSCALL
#define __NR_TESTSYSCALL 436
#endif
char *addr;
SYSCALL_DEFINE0(testsyscall) {
printk(KERN_INFO "Test\n");
return 0;
}
int init_module() {
addr = kmalloc(32, GFP_KERNEL);
return 0;
}
void cleanup_module() {
printk(KERN_INFO "Module removed\n");
}
I already checked the syscall number 436 is not used. However I can't compile this. I get this error:
make -C /lib/modules/5.4.0-72-generic/build M=/root/beginner modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-72-generic'
CC [M] /root/beginner/testme.o
Building modules, stage 2.
MODPOST 1 modules
ERROR: "enter_syscall_print_funcs" [/root/beginner/testme.ko] undefined!
ERROR: "event_class_syscall_enter" [/root/beginner/testme.ko] undefined!
ERROR: "exit_syscall_print_funcs" [/root/beginner/testme.ko] undefined!
ERROR: "event_class_syscall_exit" [/root/beginner/testme.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:94: __modpost] Error 1
make[1]: *** [Makefile:1667: modules] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-72-generic'
make: *** [Makefile:4: all] Error 2
I used this script to compile:
obj-m += testme.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Can someone help me?