core.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. /*
  2. * Kernel Probes (KProbes)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright (C) IBM Corporation, 2002, 2004
  19. *
  20. * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
  21. * Probes initial implementation ( includes contributions from
  22. * Rusty Russell).
  23. * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
  24. * interface to access function arguments.
  25. * 2004-Oct Jim Keniston <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
  26. * <prasanna@in.ibm.com> adapted for x86_64 from i386.
  27. * 2005-Mar Roland McGrath <roland@redhat.com>
  28. * Fixed to handle %rip-relative addressing mode correctly.
  29. * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston
  30. * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
  31. * <prasanna@in.ibm.com> added function-return probes.
  32. * 2005-May Rusty Lynch <rusty.lynch@intel.com>
  33. * Added function return probes functionality
  34. * 2006-Feb Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp> added
  35. * kprobe-booster and kretprobe-booster for i386.
  36. * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com> added kprobe-booster
  37. * and kretprobe-booster for x86-64
  38. * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com>, Arjan van de Ven
  39. * <arjan@infradead.org> and Jim Keniston <jkenisto@us.ibm.com>
  40. * unified x86 kprobes code.
  41. */
  42. #include <linux/kprobes.h>
  43. #include <linux/ptrace.h>
  44. #include <linux/string.h>
  45. #include <linux/slab.h>
  46. #include <linux/hardirq.h>
  47. #include <linux/preempt.h>
  48. #include <linux/extable.h>
  49. #include <linux/kdebug.h>
  50. #include <linux/kallsyms.h>
  51. #include <linux/ftrace.h>
  52. #include <linux/frame.h>
  53. #include <linux/kasan.h>
  54. #include <asm/text-patching.h>
  55. #include <asm/cacheflush.h>
  56. #include <asm/desc.h>
  57. #include <asm/pgtable.h>
  58. #include <linux/uaccess.h>
  59. #include <asm/alternative.h>
  60. #include <asm/insn.h>
  61. #include <asm/debugreg.h>
  62. #include "common.h"
  63. void jprobe_return_end(void);
  64. DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
  65. DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
  66. #define stack_addr(regs) ((unsigned long *)kernel_stack_pointer(regs))
  67. #define W(row, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf)\
  68. (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \
  69. (b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) | \
  70. (b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) | \
  71. (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \
  72. << (row % 32))
  73. /*
  74. * Undefined/reserved opcodes, conditional jump, Opcode Extension
  75. * Groups, and some special opcodes can not boost.
  76. * This is non-const and volatile to keep gcc from statically
  77. * optimizing it out, as variable_test_bit makes gcc think only
  78. * *(unsigned long*) is used.
  79. */
  80. static volatile u32 twobyte_is_boostable[256 / 32] = {
  81. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  82. /* ---------------------------------------------- */
  83. W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
  84. W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
  85. W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
  86. W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
  87. W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
  88. W(0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 50 */
  89. W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1) | /* 60 */
  90. W(0x70, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) , /* 70 */
  91. W(0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 80 */
  92. W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
  93. W(0xa0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* a0 */
  94. W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1) , /* b0 */
  95. W(0xc0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */
  96. W(0xd0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) , /* d0 */
  97. W(0xe0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1) | /* e0 */
  98. W(0xf0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0) /* f0 */
  99. /* ----------------------------------------------- */
  100. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  101. };
  102. #undef W
  103. struct kretprobe_blackpoint kretprobe_blacklist[] = {
  104. {"__switch_to", }, /* This function switches only current task, but
  105. doesn't switch kernel stack.*/
  106. {NULL, NULL} /* Terminator */
  107. };
  108. const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist);
  109. static nokprobe_inline void
  110. __synthesize_relative_insn(void *from, void *to, u8 op)
  111. {
  112. struct __arch_relative_insn {
  113. u8 op;
  114. s32 raddr;
  115. } __packed *insn;
  116. insn = (struct __arch_relative_insn *)from;
  117. insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
  118. insn->op = op;
  119. }
  120. /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
  121. void synthesize_reljump(void *from, void *to)
  122. {
  123. __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE);
  124. }
  125. NOKPROBE_SYMBOL(synthesize_reljump);
  126. /* Insert a call instruction at address 'from', which calls address 'to'.*/
  127. void synthesize_relcall(void *from, void *to)
  128. {
  129. __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE);
  130. }
  131. NOKPROBE_SYMBOL(synthesize_relcall);
  132. /*
  133. * Skip the prefixes of the instruction.
  134. */
  135. static kprobe_opcode_t *skip_prefixes(kprobe_opcode_t *insn)
  136. {
  137. insn_attr_t attr;
  138. attr = inat_get_opcode_attribute((insn_byte_t)*insn);
  139. while (inat_is_legacy_prefix(attr)) {
  140. insn++;
  141. attr = inat_get_opcode_attribute((insn_byte_t)*insn);
  142. }
  143. #ifdef CONFIG_X86_64
  144. if (inat_is_rex_prefix(attr))
  145. insn++;
  146. #endif
  147. return insn;
  148. }
  149. NOKPROBE_SYMBOL(skip_prefixes);
  150. /*
  151. * Returns non-zero if opcode is boostable.
  152. * RIP relative instructions are adjusted at copying time in 64 bits mode
  153. */
  154. int can_boost(kprobe_opcode_t *opcodes)
  155. {
  156. kprobe_opcode_t opcode;
  157. kprobe_opcode_t *orig_opcodes = opcodes;
  158. if (search_exception_tables((unsigned long)opcodes))
  159. return 0; /* Page fault may occur on this address. */
  160. retry:
  161. if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1)
  162. return 0;
  163. opcode = *(opcodes++);
  164. /* 2nd-byte opcode */
  165. if (opcode == 0x0f) {
  166. if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1)
  167. return 0;
  168. return test_bit(*opcodes,
  169. (unsigned long *)twobyte_is_boostable);
  170. }
  171. switch (opcode & 0xf0) {
  172. #ifdef CONFIG_X86_64
  173. case 0x40:
  174. goto retry; /* REX prefix is boostable */
  175. #endif
  176. case 0x60:
  177. if (0x63 < opcode && opcode < 0x67)
  178. goto retry; /* prefixes */
  179. /* can't boost Address-size override and bound */
  180. return (opcode != 0x62 && opcode != 0x67);
  181. case 0x70:
  182. return 0; /* can't boost conditional jump */
  183. case 0xc0:
  184. /* can't boost software-interruptions */
  185. return (0xc1 < opcode && opcode < 0xcc) || opcode == 0xcf;
  186. case 0xd0:
  187. /* can boost AA* and XLAT */
  188. return (opcode == 0xd4 || opcode == 0xd5 || opcode == 0xd7);
  189. case 0xe0:
  190. /* can boost in/out and absolute jmps */
  191. return ((opcode & 0x04) || opcode == 0xea);
  192. case 0xf0:
  193. if ((opcode & 0x0c) == 0 && opcode != 0xf1)
  194. goto retry; /* lock/rep(ne) prefix */
  195. /* clear and set flags are boostable */
  196. return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe));
  197. default:
  198. /* segment override prefixes are boostable */
  199. if (opcode == 0x26 || opcode == 0x36 || opcode == 0x3e)
  200. goto retry; /* prefixes */
  201. /* CS override prefix and call are not boostable */
  202. return (opcode != 0x2e && opcode != 0x9a);
  203. }
  204. }
  205. static unsigned long
  206. __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
  207. {
  208. struct kprobe *kp;
  209. unsigned long faddr;
  210. kp = get_kprobe((void *)addr);
  211. faddr = ftrace_location(addr);
  212. /*
  213. * Addresses inside the ftrace location are refused by
  214. * arch_check_ftrace_location(). Something went terribly wrong
  215. * if such an address is checked here.
  216. */
  217. if (WARN_ON(faddr && faddr != addr))
  218. return 0UL;
  219. /*
  220. * Use the current code if it is not modified by Kprobe
  221. * and it cannot be modified by ftrace.
  222. */
  223. if (!kp && !faddr)
  224. return addr;
  225. /*
  226. * Basically, kp->ainsn.insn has an original instruction.
  227. * However, RIP-relative instruction can not do single-stepping
  228. * at different place, __copy_instruction() tweaks the displacement of
  229. * that instruction. In that case, we can't recover the instruction
  230. * from the kp->ainsn.insn.
  231. *
  232. * On the other hand, in case on normal Kprobe, kp->opcode has a copy
  233. * of the first byte of the probed instruction, which is overwritten
  234. * by int3. And the instruction at kp->addr is not modified by kprobes
  235. * except for the first byte, we can recover the original instruction
  236. * from it and kp->opcode.
  237. *
  238. * In case of Kprobes using ftrace, we do not have a copy of
  239. * the original instruction. In fact, the ftrace location might
  240. * be modified at anytime and even could be in an inconsistent state.
  241. * Fortunately, we know that the original code is the ideal 5-byte
  242. * long NOP.
  243. */
  244. memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
  245. if (faddr)
  246. memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
  247. else
  248. buf[0] = kp->opcode;
  249. return (unsigned long)buf;
  250. }
  251. /*
  252. * Recover the probed instruction at addr for further analysis.
  253. * Caller must lock kprobes by kprobe_mutex, or disable preemption
  254. * for preventing to release referencing kprobes.
  255. * Returns zero if the instruction can not get recovered.
  256. */
  257. unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
  258. {
  259. unsigned long __addr;
  260. __addr = __recover_optprobed_insn(buf, addr);
  261. if (__addr != addr)
  262. return __addr;
  263. return __recover_probed_insn(buf, addr);
  264. }
  265. /* Check if paddr is at an instruction boundary */
  266. static int can_probe(unsigned long paddr)
  267. {
  268. unsigned long addr, __addr, offset = 0;
  269. struct insn insn;
  270. kprobe_opcode_t buf[MAX_INSN_SIZE];
  271. if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
  272. return 0;
  273. /* Decode instructions */
  274. addr = paddr - offset;
  275. while (addr < paddr) {
  276. /*
  277. * Check if the instruction has been modified by another
  278. * kprobe, in which case we replace the breakpoint by the
  279. * original instruction in our buffer.
  280. * Also, jump optimization will change the breakpoint to
  281. * relative-jump. Since the relative-jump itself is
  282. * normally used, we just go through if there is no kprobe.
  283. */
  284. __addr = recover_probed_instruction(buf, addr);
  285. if (!__addr)
  286. return 0;
  287. kernel_insn_init(&insn, (void *)__addr, MAX_INSN_SIZE);
  288. insn_get_length(&insn);
  289. /*
  290. * Another debugging subsystem might insert this breakpoint.
  291. * In that case, we can't recover it.
  292. */
  293. if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
  294. return 0;
  295. addr += insn.length;
  296. }
  297. return (addr == paddr);
  298. }
  299. /*
  300. * Returns non-zero if opcode modifies the interrupt flag.
  301. */
  302. static int is_IF_modifier(kprobe_opcode_t *insn)
  303. {
  304. /* Skip prefixes */
  305. insn = skip_prefixes(insn);
  306. switch (*insn) {
  307. case 0xfa: /* cli */
  308. case 0xfb: /* sti */
  309. case 0xcf: /* iret/iretd */
  310. case 0x9d: /* popf/popfd */
  311. return 1;
  312. }
  313. return 0;
  314. }
  315. /*
  316. * Copy an instruction and adjust the displacement if the instruction
  317. * uses the %rip-relative addressing mode.
  318. * If it does, Return the address of the 32-bit displacement word.
  319. * If not, return null.
  320. * Only applicable to 64-bit x86.
  321. */
  322. int __copy_instruction(u8 *dest, u8 *src)
  323. {
  324. struct insn insn;
  325. kprobe_opcode_t buf[MAX_INSN_SIZE];
  326. int length;
  327. unsigned long recovered_insn =
  328. recover_probed_instruction(buf, (unsigned long)src);
  329. if (!recovered_insn)
  330. return 0;
  331. kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
  332. insn_get_length(&insn);
  333. length = insn.length;
  334. /* Another subsystem puts a breakpoint, failed to recover */
  335. if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
  336. return 0;
  337. memcpy(dest, insn.kaddr, length);
  338. #ifdef CONFIG_X86_64
  339. if (insn_rip_relative(&insn)) {
  340. s64 newdisp;
  341. u8 *disp;
  342. kernel_insn_init(&insn, dest, length);
  343. insn_get_displacement(&insn);
  344. /*
  345. * The copied instruction uses the %rip-relative addressing
  346. * mode. Adjust the displacement for the difference between
  347. * the original location of this instruction and the location
  348. * of the copy that will actually be run. The tricky bit here
  349. * is making sure that the sign extension happens correctly in
  350. * this calculation, since we need a signed 32-bit result to
  351. * be sign-extended to 64 bits when it's added to the %rip
  352. * value and yield the same 64-bit result that the sign-
  353. * extension of the original signed 32-bit displacement would
  354. * have given.
  355. */
  356. newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
  357. if ((s64) (s32) newdisp != newdisp) {
  358. pr_err("Kprobes error: new displacement does not fit into s32 (%llx)\n", newdisp);
  359. pr_err("\tSrc: %p, Dest: %p, old disp: %x\n", src, dest, insn.displacement.value);
  360. return 0;
  361. }
  362. disp = (u8 *) dest + insn_offset_displacement(&insn);
  363. *(s32 *) disp = (s32) newdisp;
  364. }
  365. #endif
  366. return length;
  367. }
  368. static int arch_copy_kprobe(struct kprobe *p)
  369. {
  370. int ret;
  371. /* Copy an instruction with recovering if other optprobe modifies it.*/
  372. ret = __copy_instruction(p->ainsn.insn, p->addr);
  373. if (!ret)
  374. return -EINVAL;
  375. /*
  376. * __copy_instruction can modify the displacement of the instruction,
  377. * but it doesn't affect boostable check.
  378. */
  379. if (can_boost(p->ainsn.insn))
  380. p->ainsn.boostable = 0;
  381. else
  382. p->ainsn.boostable = -1;
  383. /* Check whether the instruction modifies Interrupt Flag or not */
  384. p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn);
  385. /* Also, displacement change doesn't affect the first byte */
  386. p->opcode = p->ainsn.insn[0];
  387. return 0;
  388. }
  389. int arch_prepare_kprobe(struct kprobe *p)
  390. {
  391. if (alternatives_text_reserved(p->addr, p->addr))
  392. return -EINVAL;
  393. if (!can_probe((unsigned long)p->addr))
  394. return -EILSEQ;
  395. /* insn: must be on special executable page on x86. */
  396. p->ainsn.insn = get_insn_slot();
  397. if (!p->ainsn.insn)
  398. return -ENOMEM;
  399. return arch_copy_kprobe(p);
  400. }
  401. void arch_arm_kprobe(struct kprobe *p)
  402. {
  403. text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
  404. }
  405. void arch_disarm_kprobe(struct kprobe *p)
  406. {
  407. text_poke(p->addr, &p->opcode, 1);
  408. }
  409. void arch_remove_kprobe(struct kprobe *p)
  410. {
  411. if (p->ainsn.insn) {
  412. free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1));
  413. p->ainsn.insn = NULL;
  414. }
  415. }
  416. static nokprobe_inline void
  417. save_previous_kprobe(struct kprobe_ctlblk *kcb)
  418. {
  419. kcb->prev_kprobe.kp = kprobe_running();
  420. kcb->prev_kprobe.status = kcb->kprobe_status;
  421. kcb->prev_kprobe.old_flags = kcb->kprobe_old_flags;
  422. kcb->prev_kprobe.saved_flags = kcb->kprobe_saved_flags;
  423. }
  424. static nokprobe_inline void
  425. restore_previous_kprobe(struct kprobe_ctlblk *kcb)
  426. {
  427. __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
  428. kcb->kprobe_status = kcb->prev_kprobe.status;
  429. kcb->kprobe_old_flags = kcb->prev_kprobe.old_flags;
  430. kcb->kprobe_saved_flags = kcb->prev_kprobe.saved_flags;
  431. }
  432. static nokprobe_inline void
  433. set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
  434. struct kprobe_ctlblk *kcb)
  435. {
  436. __this_cpu_write(current_kprobe, p);
  437. kcb->kprobe_saved_flags = kcb->kprobe_old_flags
  438. = (regs->flags & (X86_EFLAGS_TF | X86_EFLAGS_IF));
  439. if (p->ainsn.if_modifier)
  440. kcb->kprobe_saved_flags &= ~X86_EFLAGS_IF;
  441. }
  442. static nokprobe_inline void clear_btf(void)
  443. {
  444. if (test_thread_flag(TIF_BLOCKSTEP)) {
  445. unsigned long debugctl = get_debugctlmsr();
  446. debugctl &= ~DEBUGCTLMSR_BTF;
  447. update_debugctlmsr(debugctl);
  448. }
  449. }
  450. static nokprobe_inline void restore_btf(void)
  451. {
  452. if (test_thread_flag(TIF_BLOCKSTEP)) {
  453. unsigned long debugctl = get_debugctlmsr();
  454. debugctl |= DEBUGCTLMSR_BTF;
  455. update_debugctlmsr(debugctl);
  456. }
  457. }
  458. void arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs)
  459. {
  460. unsigned long *sara = stack_addr(regs);
  461. ri->ret_addr = (kprobe_opcode_t *) *sara;
  462. /* Replace the return addr with trampoline addr */
  463. *sara = (unsigned long) &kretprobe_trampoline;
  464. }
  465. NOKPROBE_SYMBOL(arch_prepare_kretprobe);
  466. static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
  467. struct kprobe_ctlblk *kcb, int reenter)
  468. {
  469. if (setup_detour_execution(p, regs, reenter))
  470. return;
  471. #if !defined(CONFIG_PREEMPT)
  472. if (p->ainsn.boostable == 1 && !p->post_handler) {
  473. /* Boost up -- we can execute copied instructions directly */
  474. if (!reenter)
  475. reset_current_kprobe();
  476. /*
  477. * Reentering boosted probe doesn't reset current_kprobe,
  478. * nor set current_kprobe, because it doesn't use single
  479. * stepping.
  480. */
  481. regs->ip = (unsigned long)p->ainsn.insn;
  482. preempt_enable_no_resched();
  483. return;
  484. }
  485. #endif
  486. if (reenter) {
  487. save_previous_kprobe(kcb);
  488. set_current_kprobe(p, regs, kcb);
  489. kcb->kprobe_status = KPROBE_REENTER;
  490. } else
  491. kcb->kprobe_status = KPROBE_HIT_SS;
  492. /* Prepare real single stepping */
  493. clear_btf();
  494. regs->flags |= X86_EFLAGS_TF;
  495. regs->flags &= ~X86_EFLAGS_IF;
  496. /* single step inline if the instruction is an int3 */
  497. if (p->opcode == BREAKPOINT_INSTRUCTION)
  498. regs->ip = (unsigned long)p->addr;
  499. else
  500. regs->ip = (unsigned long)p->ainsn.insn;
  501. }
  502. NOKPROBE_SYMBOL(setup_singlestep);
  503. /*
  504. * We have reentered the kprobe_handler(), since another probe was hit while
  505. * within the handler. We save the original kprobes variables and just single
  506. * step on the instruction of the new probe without calling any user handlers.
  507. */
  508. static int reenter_kprobe(struct kprobe *p, struct pt_regs *regs,
  509. struct kprobe_ctlblk *kcb)
  510. {
  511. switch (kcb->kprobe_status) {
  512. case KPROBE_HIT_SSDONE:
  513. case KPROBE_HIT_ACTIVE:
  514. case KPROBE_HIT_SS:
  515. kprobes_inc_nmissed_count(p);
  516. setup_singlestep(p, regs, kcb, 1);
  517. break;
  518. case KPROBE_REENTER:
  519. /* A probe has been hit in the codepath leading up to, or just
  520. * after, single-stepping of a probed instruction. This entire
  521. * codepath should strictly reside in .kprobes.text section.
  522. * Raise a BUG or we'll continue in an endless reentering loop
  523. * and eventually a stack overflow.
  524. */
  525. printk(KERN_WARNING "Unrecoverable kprobe detected at %p.\n",
  526. p->addr);
  527. dump_kprobe(p);
  528. BUG();
  529. default:
  530. /* impossible cases */
  531. WARN_ON(1);
  532. return 0;
  533. }
  534. return 1;
  535. }
  536. NOKPROBE_SYMBOL(reenter_kprobe);
  537. /*
  538. * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  539. * remain disabled throughout this function.
  540. */
  541. int kprobe_int3_handler(struct pt_regs *regs)
  542. {
  543. kprobe_opcode_t *addr;
  544. struct kprobe *p;
  545. struct kprobe_ctlblk *kcb;
  546. if (user_mode(regs))
  547. return 0;
  548. addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t));
  549. /*
  550. * We don't want to be preempted for the entire
  551. * duration of kprobe processing. We conditionally
  552. * re-enable preemption at the end of this function,
  553. * and also in reenter_kprobe() and setup_singlestep().
  554. */
  555. preempt_disable();
  556. kcb = get_kprobe_ctlblk();
  557. p = get_kprobe(addr);
  558. if (p) {
  559. if (kprobe_running()) {
  560. if (reenter_kprobe(p, regs, kcb))
  561. return 1;
  562. } else {
  563. set_current_kprobe(p, regs, kcb);
  564. kcb->kprobe_status = KPROBE_HIT_ACTIVE;
  565. /*
  566. * If we have no pre-handler or it returned 0, we
  567. * continue with normal processing. If we have a
  568. * pre-handler and it returned non-zero, it prepped
  569. * for calling the break_handler below on re-entry
  570. * for jprobe processing, so get out doing nothing
  571. * more here.
  572. */
  573. if (!p->pre_handler || !p->pre_handler(p, regs))
  574. setup_singlestep(p, regs, kcb, 0);
  575. return 1;
  576. }
  577. } else if (*addr != BREAKPOINT_INSTRUCTION) {
  578. /*
  579. * The breakpoint instruction was removed right
  580. * after we hit it. Another cpu has removed
  581. * either a probepoint or a debugger breakpoint
  582. * at this address. In either case, no further
  583. * handling of this interrupt is appropriate.
  584. * Back up over the (now missing) int3 and run
  585. * the original instruction.
  586. */
  587. regs->ip = (unsigned long)addr;
  588. preempt_enable_no_resched();
  589. return 1;
  590. } else if (kprobe_running()) {
  591. p = __this_cpu_read(current_kprobe);
  592. if (p->break_handler && p->break_handler(p, regs)) {
  593. if (!skip_singlestep(p, regs, kcb))
  594. setup_singlestep(p, regs, kcb, 0);
  595. return 1;
  596. }
  597. } /* else: not a kprobe fault; let the kernel handle it */
  598. preempt_enable_no_resched();
  599. return 0;
  600. }
  601. NOKPROBE_SYMBOL(kprobe_int3_handler);
  602. /*
  603. * When a retprobed function returns, this code saves registers and
  604. * calls trampoline_handler() runs, which calls the kretprobe's handler.
  605. */
  606. asm(
  607. ".global kretprobe_trampoline\n"
  608. ".type kretprobe_trampoline, @function\n"
  609. "kretprobe_trampoline:\n"
  610. #ifdef CONFIG_X86_64
  611. /* We don't bother saving the ss register */
  612. " pushq %rsp\n"
  613. " pushfq\n"
  614. SAVE_REGS_STRING
  615. " movq %rsp, %rdi\n"
  616. " call trampoline_handler\n"
  617. /* Replace saved sp with true return address. */
  618. " movq %rax, 152(%rsp)\n"
  619. RESTORE_REGS_STRING
  620. " popfq\n"
  621. #else
  622. " pushf\n"
  623. SAVE_REGS_STRING
  624. " movl %esp, %eax\n"
  625. " call trampoline_handler\n"
  626. /* Move flags to cs */
  627. " movl 56(%esp), %edx\n"
  628. " movl %edx, 52(%esp)\n"
  629. /* Replace saved flags with true return address. */
  630. " movl %eax, 56(%esp)\n"
  631. RESTORE_REGS_STRING
  632. " popf\n"
  633. #endif
  634. " ret\n"
  635. ".size kretprobe_trampoline, .-kretprobe_trampoline\n"
  636. );
  637. NOKPROBE_SYMBOL(kretprobe_trampoline);
  638. STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
  639. /*
  640. * Called from kretprobe_trampoline
  641. */
  642. __visible __used void *trampoline_handler(struct pt_regs *regs)
  643. {
  644. struct kretprobe_instance *ri = NULL;
  645. struct hlist_head *head, empty_rp;
  646. struct hlist_node *tmp;
  647. unsigned long flags, orig_ret_address = 0;
  648. unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;
  649. kprobe_opcode_t *correct_ret_addr = NULL;
  650. INIT_HLIST_HEAD(&empty_rp);
  651. kretprobe_hash_lock(current, &head, &flags);
  652. /* fixup registers */
  653. #ifdef CONFIG_X86_64
  654. regs->cs = __KERNEL_CS;
  655. #else
  656. regs->cs = __KERNEL_CS | get_kernel_rpl();
  657. regs->gs = 0;
  658. #endif
  659. regs->ip = trampoline_address;
  660. regs->orig_ax = ~0UL;
  661. /*
  662. * It is possible to have multiple instances associated with a given
  663. * task either because multiple functions in the call path have
  664. * return probes installed on them, and/or more than one
  665. * return probe was registered for a target function.
  666. *
  667. * We can handle this because:
  668. * - instances are always pushed into the head of the list
  669. * - when multiple return probes are registered for the same
  670. * function, the (chronologically) first instance's ret_addr
  671. * will be the real return address, and all the rest will
  672. * point to kretprobe_trampoline.
  673. */
  674. hlist_for_each_entry_safe(ri, tmp, head, hlist) {
  675. if (ri->task != current)
  676. /* another task is sharing our hash bucket */
  677. continue;
  678. orig_ret_address = (unsigned long)ri->ret_addr;
  679. if (orig_ret_address != trampoline_address)
  680. /*
  681. * This is the real return address. Any other
  682. * instances associated with this task are for
  683. * other calls deeper on the call stack
  684. */
  685. break;
  686. }
  687. kretprobe_assert(ri, orig_ret_address, trampoline_address);
  688. correct_ret_addr = ri->ret_addr;
  689. hlist_for_each_entry_safe(ri, tmp, head, hlist) {
  690. if (ri->task != current)
  691. /* another task is sharing our hash bucket */
  692. continue;
  693. orig_ret_address = (unsigned long)ri->ret_addr;
  694. if (ri->rp && ri->rp->handler) {
  695. __this_cpu_write(current_kprobe, &ri->rp->kp);
  696. get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
  697. ri->ret_addr = correct_ret_addr;
  698. ri->rp->handler(ri, regs);
  699. __this_cpu_write(current_kprobe, NULL);
  700. }
  701. recycle_rp_inst(ri, &empty_rp);
  702. if (orig_ret_address != trampoline_address)
  703. /*
  704. * This is the real return address. Any other
  705. * instances associated with this task are for
  706. * other calls deeper on the call stack
  707. */
  708. break;
  709. }
  710. kretprobe_hash_unlock(current, &flags);
  711. hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
  712. hlist_del(&ri->hlist);
  713. kfree(ri);
  714. }
  715. return (void *)orig_ret_address;
  716. }
  717. NOKPROBE_SYMBOL(trampoline_handler);
  718. /*
  719. * Called after single-stepping. p->addr is the address of the
  720. * instruction whose first byte has been replaced by the "int 3"
  721. * instruction. To avoid the SMP problems that can occur when we
  722. * temporarily put back the original opcode to single-step, we
  723. * single-stepped a copy of the instruction. The address of this
  724. * copy is p->ainsn.insn.
  725. *
  726. * This function prepares to return from the post-single-step
  727. * interrupt. We have to fix up the stack as follows:
  728. *
  729. * 0) Except in the case of absolute or indirect jump or call instructions,
  730. * the new ip is relative to the copied instruction. We need to make
  731. * it relative to the original instruction.
  732. *
  733. * 1) If the single-stepped instruction was pushfl, then the TF and IF
  734. * flags are set in the just-pushed flags, and may need to be cleared.
  735. *
  736. * 2) If the single-stepped instruction was a call, the return address
  737. * that is atop the stack is the address following the copied instruction.
  738. * We need to make it the address following the original instruction.
  739. *
  740. * If this is the first time we've single-stepped the instruction at
  741. * this probepoint, and the instruction is boostable, boost it: add a
  742. * jump instruction after the copied instruction, that jumps to the next
  743. * instruction after the probepoint.
  744. */
  745. static void resume_execution(struct kprobe *p, struct pt_regs *regs,
  746. struct kprobe_ctlblk *kcb)
  747. {
  748. unsigned long *tos = stack_addr(regs);
  749. unsigned long copy_ip = (unsigned long)p->ainsn.insn;
  750. unsigned long orig_ip = (unsigned long)p->addr;
  751. kprobe_opcode_t *insn = p->ainsn.insn;
  752. /* Skip prefixes */
  753. insn = skip_prefixes(insn);
  754. regs->flags &= ~X86_EFLAGS_TF;
  755. switch (*insn) {
  756. case 0x9c: /* pushfl */
  757. *tos &= ~(X86_EFLAGS_TF | X86_EFLAGS_IF);
  758. *tos |= kcb->kprobe_old_flags;
  759. break;
  760. case 0xc2: /* iret/ret/lret */
  761. case 0xc3:
  762. case 0xca:
  763. case 0xcb:
  764. case 0xcf:
  765. case 0xea: /* jmp absolute -- ip is correct */
  766. /* ip is already adjusted, no more changes required */
  767. p->ainsn.boostable = 1;
  768. goto no_change;
  769. case 0xe8: /* call relative - Fix return addr */
  770. *tos = orig_ip + (*tos - copy_ip);
  771. break;
  772. #ifdef CONFIG_X86_32
  773. case 0x9a: /* call absolute -- same as call absolute, indirect */
  774. *tos = orig_ip + (*tos - copy_ip);
  775. goto no_change;
  776. #endif
  777. case 0xff:
  778. if ((insn[1] & 0x30) == 0x10) {
  779. /*
  780. * call absolute, indirect
  781. * Fix return addr; ip is correct.
  782. * But this is not boostable
  783. */
  784. *tos = orig_ip + (*tos - copy_ip);
  785. goto no_change;
  786. } else if (((insn[1] & 0x31) == 0x20) ||
  787. ((insn[1] & 0x31) == 0x21)) {
  788. /*
  789. * jmp near and far, absolute indirect
  790. * ip is correct. And this is boostable
  791. */
  792. p->ainsn.boostable = 1;
  793. goto no_change;
  794. }
  795. default:
  796. break;
  797. }
  798. if (p->ainsn.boostable == 0) {
  799. if ((regs->ip > copy_ip) &&
  800. (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) {
  801. /*
  802. * These instructions can be executed directly if it
  803. * jumps back to correct address.
  804. */
  805. synthesize_reljump((void *)regs->ip,
  806. (void *)orig_ip + (regs->ip - copy_ip));
  807. p->ainsn.boostable = 1;
  808. } else {
  809. p->ainsn.boostable = -1;
  810. }
  811. }
  812. regs->ip += orig_ip - copy_ip;
  813. no_change:
  814. restore_btf();
  815. }
  816. NOKPROBE_SYMBOL(resume_execution);
  817. /*
  818. * Interrupts are disabled on entry as trap1 is an interrupt gate and they
  819. * remain disabled throughout this function.
  820. */
  821. int kprobe_debug_handler(struct pt_regs *regs)
  822. {
  823. struct kprobe *cur = kprobe_running();
  824. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  825. if (!cur)
  826. return 0;
  827. resume_execution(cur, regs, kcb);
  828. regs->flags |= kcb->kprobe_saved_flags;
  829. if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
  830. kcb->kprobe_status = KPROBE_HIT_SSDONE;
  831. cur->post_handler(cur, regs, 0);
  832. }
  833. /* Restore back the original saved kprobes variables and continue. */
  834. if (kcb->kprobe_status == KPROBE_REENTER) {
  835. restore_previous_kprobe(kcb);
  836. goto out;
  837. }
  838. reset_current_kprobe();
  839. out:
  840. preempt_enable_no_resched();
  841. /*
  842. * if somebody else is singlestepping across a probe point, flags
  843. * will have TF set, in which case, continue the remaining processing
  844. * of do_debug, as if this is not a probe hit.
  845. */
  846. if (regs->flags & X86_EFLAGS_TF)
  847. return 0;
  848. return 1;
  849. }
  850. NOKPROBE_SYMBOL(kprobe_debug_handler);
  851. int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
  852. {
  853. struct kprobe *cur = kprobe_running();
  854. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  855. if (unlikely(regs->ip == (unsigned long)cur->ainsn.insn)) {
  856. /* This must happen on single-stepping */
  857. WARN_ON(kcb->kprobe_status != KPROBE_HIT_SS &&
  858. kcb->kprobe_status != KPROBE_REENTER);
  859. /*
  860. * We are here because the instruction being single
  861. * stepped caused a page fault. We reset the current
  862. * kprobe and the ip points back to the probe address
  863. * and allow the page fault handler to continue as a
  864. * normal page fault.
  865. */
  866. regs->ip = (unsigned long)cur->addr;
  867. /*
  868. * Trap flag (TF) has been set here because this fault
  869. * happened where the single stepping will be done.
  870. * So clear it by resetting the current kprobe:
  871. */
  872. regs->flags &= ~X86_EFLAGS_TF;
  873. /*
  874. * If the TF flag was set before the kprobe hit,
  875. * don't touch it:
  876. */
  877. regs->flags |= kcb->kprobe_old_flags;
  878. if (kcb->kprobe_status == KPROBE_REENTER)
  879. restore_previous_kprobe(kcb);
  880. else
  881. reset_current_kprobe();
  882. preempt_enable_no_resched();
  883. } else if (kcb->kprobe_status == KPROBE_HIT_ACTIVE ||
  884. kcb->kprobe_status == KPROBE_HIT_SSDONE) {
  885. /*
  886. * We increment the nmissed count for accounting,
  887. * we can also use npre/npostfault count for accounting
  888. * these specific fault cases.
  889. */
  890. kprobes_inc_nmissed_count(cur);
  891. /*
  892. * We come here because instructions in the pre/post
  893. * handler caused the page_fault, this could happen
  894. * if handler tries to access user space by
  895. * copy_from_user(), get_user() etc. Let the
  896. * user-specified handler try to fix it first.
  897. */
  898. if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
  899. return 1;
  900. /*
  901. * In case the user-specified fault handler returned
  902. * zero, try to fix up.
  903. */
  904. if (fixup_exception(regs, trapnr))
  905. return 1;
  906. /*
  907. * fixup routine could not handle it,
  908. * Let do_page_fault() fix it.
  909. */
  910. }
  911. return 0;
  912. }
  913. NOKPROBE_SYMBOL(kprobe_fault_handler);
  914. /*
  915. * Wrapper routine for handling exceptions.
  916. */
  917. int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val,
  918. void *data)
  919. {
  920. struct die_args *args = data;
  921. int ret = NOTIFY_DONE;
  922. if (args->regs && user_mode(args->regs))
  923. return ret;
  924. if (val == DIE_GPF) {
  925. /*
  926. * To be potentially processing a kprobe fault and to
  927. * trust the result from kprobe_running(), we have
  928. * be non-preemptible.
  929. */
  930. if (!preemptible() && kprobe_running() &&
  931. kprobe_fault_handler(args->regs, args->trapnr))
  932. ret = NOTIFY_STOP;
  933. }
  934. return ret;
  935. }
  936. NOKPROBE_SYMBOL(kprobe_exceptions_notify);
  937. int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
  938. {
  939. struct jprobe *jp = container_of(p, struct jprobe, kp);
  940. unsigned long addr;
  941. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  942. kcb->jprobe_saved_regs = *regs;
  943. kcb->jprobe_saved_sp = stack_addr(regs);
  944. addr = (unsigned long)(kcb->jprobe_saved_sp);
  945. /*
  946. * As Linus pointed out, gcc assumes that the callee
  947. * owns the argument space and could overwrite it, e.g.
  948. * tailcall optimization. So, to be absolutely safe
  949. * we also save and restore enough stack bytes to cover
  950. * the argument area.
  951. * Use __memcpy() to avoid KASAN stack out-of-bounds reports as we copy
  952. * raw stack chunk with redzones:
  953. */
  954. __memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr, MIN_STACK_SIZE(addr));
  955. regs->flags &= ~X86_EFLAGS_IF;
  956. trace_hardirqs_off();
  957. regs->ip = (unsigned long)(jp->entry);
  958. /*
  959. * jprobes use jprobe_return() which skips the normal return
  960. * path of the function, and this messes up the accounting of the
  961. * function graph tracer to get messed up.
  962. *
  963. * Pause function graph tracing while performing the jprobe function.
  964. */
  965. pause_graph_tracing();
  966. return 1;
  967. }
  968. NOKPROBE_SYMBOL(setjmp_pre_handler);
  969. void jprobe_return(void)
  970. {
  971. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  972. /* Unpoison stack redzones in the frames we are going to jump over. */
  973. kasan_unpoison_stack_above_sp_to(kcb->jprobe_saved_sp);
  974. asm volatile (
  975. #ifdef CONFIG_X86_64
  976. " xchg %%rbx,%%rsp \n"
  977. #else
  978. " xchgl %%ebx,%%esp \n"
  979. #endif
  980. " int3 \n"
  981. " .globl jprobe_return_end\n"
  982. " jprobe_return_end: \n"
  983. " nop \n"::"b"
  984. (kcb->jprobe_saved_sp):"memory");
  985. }
  986. NOKPROBE_SYMBOL(jprobe_return);
  987. NOKPROBE_SYMBOL(jprobe_return_end);
  988. int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
  989. {
  990. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  991. u8 *addr = (u8 *) (regs->ip - 1);
  992. struct jprobe *jp = container_of(p, struct jprobe, kp);
  993. void *saved_sp = kcb->jprobe_saved_sp;
  994. if ((addr > (u8 *) jprobe_return) &&
  995. (addr < (u8 *) jprobe_return_end)) {
  996. if (stack_addr(regs) != saved_sp) {
  997. struct pt_regs *saved_regs = &kcb->jprobe_saved_regs;
  998. printk(KERN_ERR
  999. "current sp %p does not match saved sp %p\n",
  1000. stack_addr(regs), saved_sp);
  1001. printk(KERN_ERR "Saved registers for jprobe %p\n", jp);
  1002. show_regs(saved_regs);
  1003. printk(KERN_ERR "Current registers\n");
  1004. show_regs(regs);
  1005. BUG();
  1006. }
  1007. /* It's OK to start function graph tracing again */
  1008. unpause_graph_tracing();
  1009. *regs = kcb->jprobe_saved_regs;
  1010. __memcpy(saved_sp, kcb->jprobes_stack, MIN_STACK_SIZE(saved_sp));
  1011. preempt_enable_no_resched();
  1012. return 1;
  1013. }
  1014. return 0;
  1015. }
  1016. NOKPROBE_SYMBOL(longjmp_break_handler);
  1017. bool arch_within_kprobe_blacklist(unsigned long addr)
  1018. {
  1019. return (addr >= (unsigned long)__kprobes_text_start &&
  1020. addr < (unsigned long)__kprobes_text_end) ||
  1021. (addr >= (unsigned long)__entry_text_start &&
  1022. addr < (unsigned long)__entry_text_end);
  1023. }
  1024. int __init arch_init_kprobes(void)
  1025. {
  1026. return 0;
  1027. }
  1028. int arch_trampoline_kprobe(struct kprobe *p)
  1029. {
  1030. return 0;
  1031. }