2005-04-23 10:11:39

by Juergen Quade

[permalink] [raw]
Subject: system-freeze: kprobe and do_gettimeofday

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");


2005-04-25 16:00:12

by S. P. Prasanna

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday

On Sat, Apr 23, 2005 at 12:12:51PM +0200, Juergen Quade wrote:
> 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

Kprobe on "do_gettimeofday" seems to work fine on 4-way SMP i386 box.
What is configuration of your machine?

Thanks
Prasanna

--

Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<[email protected]>

2005-04-25 16:22:53

by Juergen Quade

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday

On Mon, Apr 25, 2005 at 09:26:49PM +0530, Prasanna S Panchamukhi wrote:
> On Sat, Apr 23, 2005 at 12:12:51PM +0200, Juergen Quade wrote:
> > 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
>
> Kprobe on "do_gettimeofday" seems to work fine on 4-way SMP i386 box.
> What is configuration of your machine?

Thank you for your answer!
Find my kernel-config attached.
The processor of the system is an Pentium M
(1400MHz, 512MByte Memory - nothing specific).

Juergen.


Attachments:
(No filename) (596.00 B)
config-2.6.12rc3 (32.00 kB)
Download all attachments

2005-04-26 14:52:29

by S. P. Prasanna

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday


On Mon, Apr 25, 2005 at 06:08:59PM +0200, Juergen Quade wrote:
> On Mon, Apr 25, 2005 at 09:26:49PM +0530, Prasanna S Panchamukhi wrote:
> > On Sat, Apr 23, 2005 at 12:12:51PM +0200, Juergen Quade wrote:
> > > 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
> >
> > Kprobe on "do_gettimeofday" seems to work fine on 4-way SMP i386 box.
> > What is configuration of your machine?
>
> Thank you for your answer!
> Find my kernel-config attached.
> The processor of the system is an Pentium M
> (1400MHz, 512MByte Memory - nothing specific).
>

I tested with your configuration file and it still
works fine. Can you get some more info about current tasks
using Alt+SysRq+t and Alt+SysRq+d keys.

Thanks
Prasanna
--

Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<[email protected]>

2005-04-26 19:33:34

by Juergen Quade

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday

On Tue, Apr 26, 2005 at 08:22:10PM +0530, Prasanna S Panchamukhi wrote:
>
> On Mon, Apr 25, 2005 at 06:08:59PM +0200, Juergen Quade wrote:
> > On Mon, Apr 25, 2005 at 09:26:49PM +0530, Prasanna S Panchamukhi wrote:
> > > On Sat, Apr 23, 2005 at 12:12:51PM +0200, Juergen Quade wrote:
> > > > 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
> > >
> > > Kprobe on "do_gettimeofday" seems to work fine on 4-way SMP i386 box.
> > > What is configuration of your machine?
> >
> > Thank you for your answer!
> > Find my kernel-config attached.
> > The processor of the system is an Pentium M
> > (1400MHz, 512MByte Memory - nothing specific).
> >
>
> I tested with your configuration file and it still
> works fine. Can you get some more info about current tasks
> using Alt+SysRq+t and Alt+SysRq+d keys.

I did now a lot of additional tests. When running
"insmod kgettime.ko" from the console (not from x-windows)
I get:

kprobe registered address c0107bd0 // output from the module
double fault, gdt at c049bd00 [255 bytes]
double fault, tss at c03d4060
eip = c0103c86, esp = db932000
eax = ffffffff, ebx = db932134, ecx = 0000000d, edx = 00000000
esi = db932080, edi = 0000000d

Alt+SysRq did not work...

Then I removed all my modules (except 2) I was able to load the module
without problems. I added module by module and checked every time with
"insmod kgettime.ko". When loading the "ohci1394" module it crashed
again. But next time I loaded the "ohci"-module first - no crash. (So I
don't think it is the ohci-module). I was able to load all modules and
it still worked.

Hmmm. What else to check?

Juergen.

2005-04-29 11:18:54

by S. P. Prasanna

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday

Juergen,

>
> I did now a lot of additional tests. When running
> "insmod kgettime.ko" from the console (not from x-windows)
> I get:
>
> kprobe registered address c0107bd0 // output from the module
> double fault, gdt at c049bd00 [255 bytes]
> double fault, tss at c03d4060
> eip = c0103c86, esp = db932000
> eax = ffffffff, ebx = db932134, ecx = 0000000d, edx = 00000000
> esi = db932080, edi = 0000000d
>
> Alt+SysRq did not work...
>
> Then I removed all my modules (except 2) I was able to load the module
> without problems. I added module by module and checked every time with
> "insmod kgettime.ko". When loading the "ohci1394" module it crashed
> again. But next time I loaded the "ohci"-module first - no crash. (So I
> don't think it is the ohci-module). I was able to load all modules and
> it still worked.
>
> Hmmm. What else to check?
>
Thanks for providing the information, we are not able to reproduce this
problem here. Can you pls write a similar fault handler for kprobes as shown
below and get us the log messages.

int fault_probe(struct kprobe *p, struct pt_regs *regs, int trapnr) {
printk("fault_handler:p->addr=0x%p, eflags=0x%lx\n", p->addr, regs->eflags);
return 0;
}

Thanks
Prasanna

--

Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<[email protected]>

2005-04-29 17:28:02

by Juergen Quade

[permalink] [raw]
Subject: Re: system-freeze: kprobe and do_gettimeofday

> > ...
> Thanks for providing the information, we are not able to reproduce this
> problem here. Can you pls write a similar fault handler for kprobes as shown
> below and get us the log messages.
>
> int fault_probe(struct kprobe *p, struct pt_regs *regs, int trapnr) {
> printk("fault_handler:p->addr=0x%p, eflags=0x%lx\n", p->addr, regs->eflags);
> return 0;

I tried it a few time, system freezes but the fault handler
has not been called. First time the system rebooted completly,
second time I got no output at all.

I added the proposed line into the pre-handler. Here is the
output:

kprobe registered address c0107bd0
pre_handler:p->addr=0xc0107bd0, eflags=0x282
root@esz-mobil:/tmp/kprobes# double fault, gdt
at c049bd00 ...

The first line is the output of "init_module". The second
line is the output of the pre_handler. As you can see,
before the "double fault" message I get one prompt. Could
there be a problem with the timer interrupt?

Juergen.