Replacing kernel functions - kernel symtab
Hi
I am working on a module which provides dynamic instrumentation for some of the kernel
functions. My module is not ready yet from dynamic instrumentation perspective.
In order to test basic functionality, I am planning to hijack calls like kmalloc in order to provide
some profiling information. I was thinking of replacing the symbols in the kernel symbol table
just for testing purposes. I know this is not a clean approach.
Would it possible to replace kmalloc with my_kmalloc in my modules init function? This way, after
my module is loaded all mallocs are routed to my module. What could go wrong here? Logically,
this is just point replacement in symtab which should be atomic, right?
Is there any other way to trap calls like kmalloc without making changes in mm subsystem or compiling
kernel/rebooting? In user space we have multiple options like usage of LD_PRELOAD etc, are there
any loading time tricks which we can use in kernel space?
-Leo.