Skip to content

Commit 80006db

Browse files
mhiramatIngo Molnar
authored andcommitted
kprobes/x86: Remove jprobe implementation
Remove arch dependent setjump/longjump functions and unused fields in kprobe_ctlblk for jprobes from arch/x86. Signed-off-by: Masami Hiramatsu <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/lkml/152942433578.15209.14034551799624757792.stgit@devbox Signed-off-by: Ingo Molnar <[email protected]>
1 parent 5a6cf77 commit 80006db

File tree

2 files changed

+3
-96
lines changed

2 files changed

+3
-96
lines changed

arch/x86/include/asm/kprobes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ struct kprobe_ctlblk {
111111
unsigned long kprobe_status;
112112
unsigned long kprobe_old_flags;
113113
unsigned long kprobe_saved_flags;
114-
unsigned long *jprobe_saved_sp;
115-
struct pt_regs jprobe_saved_regs;
116-
kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
117114
struct prev_kprobe prev_kprobe;
118115
};
119116

arch/x86/kernel/kprobes/core.c

Lines changed: 3 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666

6767
#include "common.h"
6868

69-
void jprobe_return_end(void);
70-
7169
DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
7270
DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
7371

@@ -690,10 +688,9 @@ int kprobe_int3_handler(struct pt_regs *regs)
690688
/*
691689
* If we have no pre-handler or it returned 0, we
692690
* continue with normal processing. If we have a
693-
* pre-handler and it returned non-zero, it prepped
694-
* for calling the break_handler below on re-entry
695-
* for jprobe processing, so get out doing nothing
696-
* more here.
691+
* pre-handler and it returned non-zero, that means
692+
* user handler setup registers to exit to another
693+
* instruction, we must skip the single stepping.
697694
*/
698695
if (!p->pre_handler || !p->pre_handler(p, regs))
699696
setup_singlestep(p, regs, kcb, 0);
@@ -1083,93 +1080,6 @@ int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val,
10831080
}
10841081
NOKPROBE_SYMBOL(kprobe_exceptions_notify);
10851082

1086-
int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
1087-
{
1088-
struct jprobe *jp = container_of(p, struct jprobe, kp);
1089-
unsigned long addr;
1090-
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
1091-
1092-
kcb->jprobe_saved_regs = *regs;
1093-
kcb->jprobe_saved_sp = stack_addr(regs);
1094-
addr = (unsigned long)(kcb->jprobe_saved_sp);
1095-
1096-
/*
1097-
* As Linus pointed out, gcc assumes that the callee
1098-
* owns the argument space and could overwrite it, e.g.
1099-
* tailcall optimization. So, to be absolutely safe
1100-
* we also save and restore enough stack bytes to cover
1101-
* the argument area.
1102-
* Use __memcpy() to avoid KASAN stack out-of-bounds reports as we copy
1103-
* raw stack chunk with redzones:
1104-
*/
1105-
__memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr, MIN_STACK_SIZE(addr));
1106-
regs->ip = (unsigned long)(jp->entry);
1107-
1108-
/*
1109-
* jprobes use jprobe_return() which skips the normal return
1110-
* path of the function, and this messes up the accounting of the
1111-
* function graph tracer to get messed up.
1112-
*
1113-
* Pause function graph tracing while performing the jprobe function.
1114-
*/
1115-
pause_graph_tracing();
1116-
return 1;
1117-
}
1118-
NOKPROBE_SYMBOL(setjmp_pre_handler);
1119-
1120-
void jprobe_return(void)
1121-
{
1122-
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
1123-
1124-
/* Unpoison stack redzones in the frames we are going to jump over. */
1125-
kasan_unpoison_stack_above_sp_to(kcb->jprobe_saved_sp);
1126-
1127-
asm volatile (
1128-
#ifdef CONFIG_X86_64
1129-
" xchg %%rbx,%%rsp \n"
1130-
#else
1131-
" xchgl %%ebx,%%esp \n"
1132-
#endif
1133-
" int3 \n"
1134-
" .globl jprobe_return_end\n"
1135-
" jprobe_return_end: \n"
1136-
" nop \n"::"b"
1137-
(kcb->jprobe_saved_sp):"memory");
1138-
}
1139-
NOKPROBE_SYMBOL(jprobe_return);
1140-
NOKPROBE_SYMBOL(jprobe_return_end);
1141-
1142-
int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
1143-
{
1144-
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
1145-
u8 *addr = (u8 *) (regs->ip - 1);
1146-
struct jprobe *jp = container_of(p, struct jprobe, kp);
1147-
void *saved_sp = kcb->jprobe_saved_sp;
1148-
1149-
if ((addr > (u8 *) jprobe_return) &&
1150-
(addr < (u8 *) jprobe_return_end)) {
1151-
if (stack_addr(regs) != saved_sp) {
1152-
struct pt_regs *saved_regs = &kcb->jprobe_saved_regs;
1153-
printk(KERN_ERR
1154-
"current sp %p does not match saved sp %p\n",
1155-
stack_addr(regs), saved_sp);
1156-
printk(KERN_ERR "Saved registers for jprobe %p\n", jp);
1157-
show_regs(saved_regs);
1158-
printk(KERN_ERR "Current registers\n");
1159-
show_regs(regs);
1160-
BUG();
1161-
}
1162-
/* It's OK to start function graph tracing again */
1163-
unpause_graph_tracing();
1164-
*regs = kcb->jprobe_saved_regs;
1165-
__memcpy(saved_sp, kcb->jprobes_stack, MIN_STACK_SIZE(saved_sp));
1166-
preempt_enable_no_resched();
1167-
return 1;
1168-
}
1169-
return 0;
1170-
}
1171-
NOKPROBE_SYMBOL(longjmp_break_handler);
1172-
11731083
bool arch_within_kprobe_blacklist(unsigned long addr)
11741084
{
11751085
bool is_in_entry_trampoline_section = false;

0 commit comments

Comments
 (0)