core.c 34 KB

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