system-freeze: kprobe and do_gettimeofday

Juergen Quade
2005-04-23T10:11:39Z

Playing around with kprobe I noticed, that "kprobing"
the function "do_gettimeofday" completly freezes the
system (2.6.12-rc3). Other functions like "do_fork" or
"do_settimeofday" are doing well.

Does anybody know the reason for it?

Juergen.

=================================
// BEWARE: THIS CODE MAY FREEZE YOUR SYSTEM
#include <linux/module.h>
#include <linux/kprobes.h>
#include <linux/kallsyms.h>

static int call_count = 0;

static int pre_probe(struct kprobe *p, struct pt_regs *regs)
{
++call_count;
return 0;
}

static struct kprobe kp = {
.pre_handler = pre_probe,
.post_handler = NULL,
.fault_handler = NULL,
.addr = (kprobe_opcode_t *) NULL,
};

static int __init probe_init(void)
{
kp.addr = (kprobe_opcode_t *) kallsyms_lookup_name("do_gettimeofday");

if (kp.addr == NULL) {
printk("kallsyms_lookup_name could not find address"
"for the specified symbol name\n");
return 1;
}
register_kprobe(&kp);
printk("kprobe registered address %p\n", kp.addr);
return 0;
}

static void __exit probe_exit(void)
{
unregister_kprobe(&kp);
printk("do_gettimeofday() called %d times.\n", call_count);
}

module_init( probe_init );
module_exit( probe_exit );
MODULE_LICENSE("GPL");