aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2006-11-08 20:44:49 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-11-08 21:29:24 -0500
commit8bdc052eccdc7893d075d3f1f7103594a458c8c4 (patch)
tree33bc012cebe8c3e012c533aade5e9d6ced34cce0 /arch/i386/kernel
parent4b438a23fb05b6566393f9f0a3987ea3dcc1c0c4 (diff)
[PATCH] kretprobe: fix kretprobe-booster to save regs and set status
There are two bugs in the kretprobe-booster. 1) It doesn't make room for gs registers. 2) It doesn't change status of the current kprobe. This status will effect the fault handling. This patch fixes these bugs and, additionally, saves skipped registers for compatibility with the original kretprobe. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r--arch/i386/kernel/kprobes.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index d98e44b16fe2..fc79e1e859c4 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -361,8 +361,11 @@ no_kprobe:
361 asm volatile ( ".global kretprobe_trampoline\n" 361 asm volatile ( ".global kretprobe_trampoline\n"
362 "kretprobe_trampoline: \n" 362 "kretprobe_trampoline: \n"
363 " pushf\n" 363 " pushf\n"
364 /* skip cs, eip, orig_eax, es, ds */ 364 /* skip cs, eip, orig_eax */
365 " subl $20, %esp\n" 365 " subl $12, %esp\n"
366 " pushl %gs\n"
367 " pushl %ds\n"
368 " pushl %es\n"
366 " pushl %eax\n" 369 " pushl %eax\n"
367 " pushl %ebp\n" 370 " pushl %ebp\n"
368 " pushl %edi\n" 371 " pushl %edi\n"
@@ -373,10 +376,10 @@ no_kprobe:
373 " movl %esp, %eax\n" 376 " movl %esp, %eax\n"
374 " call trampoline_handler\n" 377 " call trampoline_handler\n"
375 /* move eflags to cs */ 378 /* move eflags to cs */
376 " movl 48(%esp), %edx\n" 379 " movl 52(%esp), %edx\n"
377 " movl %edx, 44(%esp)\n" 380 " movl %edx, 48(%esp)\n"
378 /* save true return address on eflags */ 381 /* save true return address on eflags */
379 " movl %eax, 48(%esp)\n" 382 " movl %eax, 52(%esp)\n"
380 " popl %ebx\n" 383 " popl %ebx\n"
381 " popl %ecx\n" 384 " popl %ecx\n"
382 " popl %edx\n" 385 " popl %edx\n"
@@ -384,8 +387,8 @@ no_kprobe:
384 " popl %edi\n" 387 " popl %edi\n"
385 " popl %ebp\n" 388 " popl %ebp\n"
386 " popl %eax\n" 389 " popl %eax\n"
387 /* skip eip, orig_eax, es, ds */ 390 /* skip eip, orig_eax, es, ds, gs */
388 " addl $16, %esp\n" 391 " addl $20, %esp\n"
389 " popf\n" 392 " popf\n"
390 " ret\n"); 393 " ret\n");
391} 394}
@@ -404,6 +407,10 @@ fastcall void *__kprobes trampoline_handler(struct pt_regs *regs)
404 INIT_HLIST_HEAD(&empty_rp); 407 INIT_HLIST_HEAD(&empty_rp);
405 spin_lock_irqsave(&kretprobe_lock, flags); 408 spin_lock_irqsave(&kretprobe_lock, flags);
406 head = kretprobe_inst_table_head(current); 409 head = kretprobe_inst_table_head(current);
410 /* fixup registers */
411 regs->xcs = __KERNEL_CS;
412 regs->eip = trampoline_address;
413 regs->orig_eax = 0xffffffff;
407 414
408 /* 415 /*
409 * It is possible to have multiple instances associated with a given 416 * It is possible to have multiple instances associated with a given
@@ -425,6 +432,7 @@ fastcall void *__kprobes trampoline_handler(struct pt_regs *regs)
425 432
426 if (ri->rp && ri->rp->handler){ 433 if (ri->rp && ri->rp->handler){
427 __get_cpu_var(current_kprobe) = &ri->rp->kp; 434 __get_cpu_var(current_kprobe) = &ri->rp->kp;
435 get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
428 ri->rp->handler(ri, regs); 436 ri->rp->handler(ri, regs);
429 __get_cpu_var(current_kprobe) = NULL; 437 __get_cpu_var(current_kprobe) = NULL;
430 } 438 }