I am wanting to use the function getname
in my kernel module. It is not exported. Since I am running into this problem right now, I would like to know how to access and use any kernel symbol that is not exported. I figure that the steps necessary to use one will differ depending what the symbol is, so I'd like to see how it would be done for a type (e.g., a struct), a variable, a table of pointers (like the system call table), and a function. How can these be done in either of these cases:
- When I know the address of the symbol from
System.map
or/proc/kallsyms
. - When I know the name of the symbol and want to use
kallsyms_lookup_name
in retrieving it.
I currently know how to hijack system calls and this requires declaring something like
asmlinkage <return_type> (*<name_for_system_call>)(<the types of the its arguments separated by commas>);
Would something like that be used? In this answer to another question, the example presented by the poster is
#include <linux/kallsyms.h>
static void (*machine_power_off_p)(void);
machine_power_off = (void*) kallsyms_lookup_name("machine_power_off");
But what if the symbol returns a pointer? Would I place an asterisk to the left of (*machine_power_off_p)
?