Skip to contentSkip to conversation

x86: fix kprobe_handler reenable preemption

PATCH In review Masami Hiramatsu 2 participants 4 messages Dec 18, 2007 – Dec 19, 2007 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: fix kprobe_handler reenable preemption

Fix a preemption bug in kprobe_handler(). It has to call preempt_enable() before returning.
I think this is critical on preemptive kernel.

---
 arch/x86/kernel/kprobes.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/kprobes.c +3 -2
Index: b/arch/x86/kernel/kprobes.c
===================================================================
@@ -467,7 +467,8 @@
 				arch_disarm_kprobe(p);
 				regs->ip = (unsigned long)p->addr;
 				reset_current_kprobe();
-				return 1;
+				ret = 1;
+				goto no_kprobe;
 #endif
 			}
 			/* We have reentered the kprobe_handler(), since
@@ -481,7 +482,7 @@
 			kprobes_inc_nmissed_count(p);
 			prepare_singlestep(p, regs);
 			kcb->kprobe_status = KPROBE_REENTER;
-			return 1;
+			ret = 1;
 		} else {
 			if (*addr != BREAKPOINT_INSTRUCTION) {
 			/* The breakpoint instruction was removed by
Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected], [email protected]
#1 lore raw

Hi

Quoted 3 lines · Masami Hiramatsu

Fix a preemption bug in kprobe_handler(). It has to call preempt_enable() before returning.
I think this is critical on preemptive kernel.

Sorry, this patch has a mistake.

Quoted 21 lines
---
 arch/x86/kernel/kprobes.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: b/arch/x86/kernel/kprobes.c
===================================================================

arch/x86/kernel/kprobes.c +2 -1
@@ -467,7 +467,8 @@
 				arch_disarm_kprobe(p);
 				regs->ip = (unsigned long)p->addr;
 				reset_current_kprobe();
-				return 1;
+				ret = 1;
+				goto no_kprobe;
 #endif
 			}
 			/* We have reentered the kprobe_handler(), since

arch/x86/kernel/kprobes.c line 485

Quoted 5 lines
arch/x86/kernel/kprobes.c +1 -1
@@ -481,7 +482,7 @@
 			kprobes_inc_nmissed_count(p);
 			prepare_singlestep(p, regs);
 			kcb->kprobe_status = KPROBE_REENTER;
-			return 1;
+			ret = 1;

Here, "return 1;" is correct. After single step is done, preemption is enabled in post_kprobe_handler().

Quoted 4 lines
arch/x86/kernel/kprobes.c +0 -0
 		} else {
 			if (*addr != BREAKPOINT_INSTRUCTION) {
 			/* The breakpoint instruction was removed by
Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected], [email protected]
#2 lore raw
Quoted 5 lines · Masami Hiramatsu

Review

Quoted 2 lines
(quoted diff) +1 -1
-			return 1;
+			ret = 1;

Here, "return 1;" is correct. After single step is done, preemption is enabled in post_kprobe_handler().

could you resend the fixed patch? (instead of me fixing it up by hand - which is error-prone)

also, this seems like .24 material as well - could you send the fix against -rc5 too?

Ingo

#3 lore raw

Hi Ingo,

Quoted 9 lines · Ingo Molnar
Quoted 4 lines · Masami Hiramatsu

Review

Quoted 2 lines
(quoted diff) +1 -1
-			return 1;
+			ret = 1;

Here, "return 1;" is correct. After single step is done, preemption is enabled in post_kprobe_handler().

could you resend the fixed patch? (instead of me fixing it up by hand - which is error-prone)

Sure, I'll resend asap.

Quoted 3 lines

also, this seems like .24 material as well - could you send the fix against -rc5 too?

-rc tree is fine. Actually, it was introduced by my cleanup patch. Thanks!

Quoted 2 lines

Ingo

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected], [email protected]