Commit fb8830e7 authored by Abhishek Sagar's avatar Abhishek Sagar Committed by Ingo Molnar

x86: fix singlestep handling in reenter_kprobe

Highlight peculiar cases in singles-step kprobe handling.

In reenter_kprobe(), a breakpoint in KPROBE_HIT_SS case can only occur
when single-stepping a breakpoint on which a probe was installed. Since
such probes are single-stepped inline, identifying these cases is
unambiguous. All other cases leading up to KPROBE_HIT_SS are possible
bugs. Identify and WARN_ON such cases.
Signed-off-by: default avatarAbhishek Sagar <sagar.abhishek@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 0723a69a
...@@ -443,17 +443,6 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, ...@@ -443,17 +443,6 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
*sara = (unsigned long) &kretprobe_trampoline; *sara = (unsigned long) &kretprobe_trampoline;
} }
static void __kprobes recursive_singlestep(struct kprobe *p,
struct pt_regs *regs,
struct kprobe_ctlblk *kcb)
{
save_previous_kprobe(kcb);
set_current_kprobe(p, regs, kcb);
kprobes_inc_nmissed_count(p);
prepare_singlestep(p, regs);
kcb->kprobe_status = KPROBE_REENTER;
}
static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs, static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
struct kprobe_ctlblk *kcb) struct kprobe_ctlblk *kcb)
{ {
...@@ -492,20 +481,29 @@ static int __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs, ...@@ -492,20 +481,29 @@ static int __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs,
break; break;
#endif #endif
case KPROBE_HIT_ACTIVE: case KPROBE_HIT_ACTIVE:
recursive_singlestep(p, regs, kcb); save_previous_kprobe(kcb);
set_current_kprobe(p, regs, kcb);
kprobes_inc_nmissed_count(p);
prepare_singlestep(p, regs);
kcb->kprobe_status = KPROBE_REENTER;
break; break;
case KPROBE_HIT_SS: case KPROBE_HIT_SS:
if (*p->ainsn.insn == BREAKPOINT_INSTRUCTION) { if (p == kprobe_running()) {
regs->flags &= ~TF_MASK; regs->flags &= ~TF_MASK;
regs->flags |= kcb->kprobe_saved_flags; regs->flags |= kcb->kprobe_saved_flags;
return 0; return 0;
} else { } else {
recursive_singlestep(p, regs, kcb); /* A probe has been hit in the codepath leading up
* to, or just after, single-stepping of a probed
* instruction. This entire codepath should strictly
* reside in .kprobes.text section. Raise a warning
* to highlight this peculiar case.
*/
} }
break;
default: default:
/* impossible cases */ /* impossible cases */
WARN_ON(1); WARN_ON(1);
return 0;
} }
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment