|
66 | 66 |
|
67 | 67 | #include "common.h" |
68 | 68 |
|
69 | | -void jprobe_return_end(void); |
70 | | - |
71 | 69 | DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; |
72 | 70 | DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); |
73 | 71 |
|
@@ -690,10 +688,9 @@ int kprobe_int3_handler(struct pt_regs *regs) |
690 | 688 | /* |
691 | 689 | * If we have no pre-handler or it returned 0, we |
692 | 690 | * 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. |
697 | 694 | */ |
698 | 695 | if (!p->pre_handler || !p->pre_handler(p, regs)) |
699 | 696 | setup_singlestep(p, regs, kcb, 0); |
@@ -1083,93 +1080,6 @@ int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, |
1083 | 1080 | } |
1084 | 1081 | NOKPROBE_SYMBOL(kprobe_exceptions_notify); |
1085 | 1082 |
|
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 | | - |
1173 | 1083 | bool arch_within_kprobe_blacklist(unsigned long addr) |
1174 | 1084 | { |
1175 | 1085 | bool is_in_entry_trampoline_section = false; |
|
0 commit comments