What is the right way of calling kernel functions in a C file from a kernel module in Linux?
I want to call exit_task_namespaces
in linux/nsproxy.c
from my first ever kernel module
I am doing this:
#include <linux/nsproxy.h>…static ssize_t device_read(struct file *flip, char *buffer, size_t len, loff_t *offset){ struct task_struct *task = current;… exit_task_namespaces(task);…}
when I try to make
I get the following error:
ERROR: "exit_task_namespaces" [/home/.../lkm_example.ko] undefined!make[2]: *** [scripts/Makefile.modpost:94: __modpost] Error 1make[1]: *** [Makefile:1673: modules] Error 2make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-73-generic'make: *** [Makefile:3: all] Error 2
I can see that in the file /usr/src/linux-headers-5.4.0-73-generic/include/linux/nsproxy.h
the method exists.
This is my Makefile:
obj-m += lkm_example.oall: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules