Replacing kernel functions - kernel symtab

From: Leonidas .
Date: Wed Mar 03 2010 - 12:19:19 EST


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?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at