uprobes.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. /*
  2. * User-space Probes (UProbes) for x86
  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, 2008-2011
  19. * Authors:
  20. * Srikar Dronamraju
  21. * Jim Keniston
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/sched.h>
  25. #include <linux/ptrace.h>
  26. #include <linux/uprobes.h>
  27. #include <linux/uaccess.h>
  28. #include <linux/kdebug.h>
  29. #include <asm/processor.h>
  30. #include <asm/insn.h>
  31. /* Post-execution fixups. */
  32. /* Adjust IP back to vicinity of actual insn */
  33. #define UPROBE_FIX_IP 0x01
  34. /* Adjust the return address of a call insn */
  35. #define UPROBE_FIX_CALL 0x02
  36. /* Instruction will modify TF, don't change it */
  37. #define UPROBE_FIX_SETF 0x04
  38. #define UPROBE_FIX_RIP_SI 0x08
  39. #define UPROBE_FIX_RIP_DI 0x10
  40. #define UPROBE_FIX_RIP_BX 0x20
  41. #define UPROBE_FIX_RIP_MASK \
  42. (UPROBE_FIX_RIP_SI | UPROBE_FIX_RIP_DI | UPROBE_FIX_RIP_BX)
  43. #define UPROBE_TRAP_NR UINT_MAX
  44. /* Adaptations for mhiramat x86 decoder v14. */
  45. #define OPCODE1(insn) ((insn)->opcode.bytes[0])
  46. #define OPCODE2(insn) ((insn)->opcode.bytes[1])
  47. #define OPCODE3(insn) ((insn)->opcode.bytes[2])
  48. #define MODRM_REG(insn) X86_MODRM_REG((insn)->modrm.value)
  49. #define W(row, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf)\
  50. (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \
  51. (b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) | \
  52. (b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) | \
  53. (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \
  54. << (row % 32))
  55. /*
  56. * Good-instruction tables for 32-bit apps. This is non-const and volatile
  57. * to keep gcc from statically optimizing it out, as variable_test_bit makes
  58. * some versions of gcc to think only *(unsigned long*) is used.
  59. *
  60. * Opcodes we'll probably never support:
  61. * 6c-6f - ins,outs. SEGVs if used in userspace
  62. * e4-e7 - in,out imm. SEGVs if used in userspace
  63. * ec-ef - in,out acc. SEGVs if used in userspace
  64. * cc - int3. SIGTRAP if used in userspace
  65. * ce - into. Not used in userspace - no kernel support to make it useful. SEGVs
  66. * (why we support bound (62) then? it's similar, and similarly unused...)
  67. * f1 - int1. SIGTRAP if used in userspace
  68. * f4 - hlt. SEGVs if used in userspace
  69. * fa - cli. SEGVs if used in userspace
  70. * fb - sti. SEGVs if used in userspace
  71. *
  72. * Opcodes which need some work to be supported:
  73. * 07,17,1f - pop es/ss/ds
  74. * Normally not used in userspace, but would execute if used.
  75. * Can cause GP or stack exception if tries to load wrong segment descriptor.
  76. * We hesitate to run them under single step since kernel's handling
  77. * of userspace single-stepping (TF flag) is fragile.
  78. * We can easily refuse to support push es/cs/ss/ds (06/0e/16/1e)
  79. * on the same grounds that they are never used.
  80. * cd - int N.
  81. * Used by userspace for "int 80" syscall entry. (Other "int N"
  82. * cause GP -> SEGV since their IDT gates don't allow calls from CPL 3).
  83. * Not supported since kernel's handling of userspace single-stepping
  84. * (TF flag) is fragile.
  85. * cf - iret. Normally not used in userspace. Doesn't SEGV unless arguments are bad
  86. */
  87. #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
  88. static volatile u32 good_insns_32[256 / 32] = {
  89. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  90. /* ---------------------------------------------- */
  91. W(0x00, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* 00 */
  92. W(0x10, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) , /* 10 */
  93. W(0x20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 20 */
  94. W(0x30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 30 */
  95. W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
  96. W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
  97. W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */
  98. W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */
  99. W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
  100. W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
  101. W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */
  102. W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
  103. W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */
  104. W(0xd0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
  105. W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* e0 */
  106. W(0xf0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */
  107. /* ---------------------------------------------- */
  108. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  109. };
  110. #else
  111. #define good_insns_32 NULL
  112. #endif
  113. /* Good-instruction tables for 64-bit apps.
  114. *
  115. * Genuinely invalid opcodes:
  116. * 06,07 - formerly push/pop es
  117. * 0e - formerly push cs
  118. * 16,17 - formerly push/pop ss
  119. * 1e,1f - formerly push/pop ds
  120. * 27,2f,37,3f - formerly daa/das/aaa/aas
  121. * 60,61 - formerly pusha/popa
  122. * 62 - formerly bound. EVEX prefix for AVX512 (not yet supported)
  123. * 82 - formerly redundant encoding of Group1
  124. * 9a - formerly call seg:ofs
  125. * ce - formerly into
  126. * d4,d5 - formerly aam/aad
  127. * d6 - formerly undocumented salc
  128. * ea - formerly jmp seg:ofs
  129. *
  130. * Opcodes we'll probably never support:
  131. * 6c-6f - ins,outs. SEGVs if used in userspace
  132. * e4-e7 - in,out imm. SEGVs if used in userspace
  133. * ec-ef - in,out acc. SEGVs if used in userspace
  134. * cc - int3. SIGTRAP if used in userspace
  135. * f1 - int1. SIGTRAP if used in userspace
  136. * f4 - hlt. SEGVs if used in userspace
  137. * fa - cli. SEGVs if used in userspace
  138. * fb - sti. SEGVs if used in userspace
  139. *
  140. * Opcodes which need some work to be supported:
  141. * cd - int N.
  142. * Used by userspace for "int 80" syscall entry. (Other "int N"
  143. * cause GP -> SEGV since their IDT gates don't allow calls from CPL 3).
  144. * Not supported since kernel's handling of userspace single-stepping
  145. * (TF flag) is fragile.
  146. * cf - iret. Normally not used in userspace. Doesn't SEGV unless arguments are bad
  147. */
  148. #if defined(CONFIG_X86_64)
  149. static volatile u32 good_insns_64[256 / 32] = {
  150. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  151. /* ---------------------------------------------- */
  152. W(0x00, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1) | /* 00 */
  153. W(0x10, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 10 */
  154. W(0x20, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) | /* 20 */
  155. W(0x30, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) , /* 30 */
  156. W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
  157. W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
  158. W(0x60, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */
  159. W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */
  160. W(0x80, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
  161. W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1) , /* 90 */
  162. W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */
  163. W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
  164. W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */
  165. W(0xd0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
  166. W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0) | /* e0 */
  167. W(0xf0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */
  168. /* ---------------------------------------------- */
  169. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  170. };
  171. #else
  172. #define good_insns_64 NULL
  173. #endif
  174. /* Using this for both 64-bit and 32-bit apps.
  175. * Opcodes we don't support:
  176. * 0f 00 - SLDT/STR/LLDT/LTR/VERR/VERW/-/- group. System insns
  177. * 0f 01 - SGDT/SIDT/LGDT/LIDT/SMSW/-/LMSW/INVLPG group.
  178. * Also encodes tons of other system insns if mod=11.
  179. * Some are in fact non-system: xend, xtest, rdtscp, maybe more
  180. * 0f 05 - syscall
  181. * 0f 06 - clts (CPL0 insn)
  182. * 0f 07 - sysret
  183. * 0f 08 - invd (CPL0 insn)
  184. * 0f 09 - wbinvd (CPL0 insn)
  185. * 0f 0b - ud2
  186. * 0f 30 - wrmsr (CPL0 insn) (then why rdmsr is allowed, it's also CPL0 insn?)
  187. * 0f 34 - sysenter
  188. * 0f 35 - sysexit
  189. * 0f 37 - getsec
  190. * 0f 78 - vmread (Intel VMX. CPL0 insn)
  191. * 0f 79 - vmwrite (Intel VMX. CPL0 insn)
  192. * Note: with prefixes, these two opcodes are
  193. * extrq/insertq/AVX512 convert vector ops.
  194. * 0f ae - group15: [f]xsave,[f]xrstor,[v]{ld,st}mxcsr,clflush[opt],
  195. * {rd,wr}{fs,gs}base,{s,l,m}fence.
  196. * Why? They are all user-executable.
  197. */
  198. static volatile u32 good_2byte_insns[256 / 32] = {
  199. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  200. /* ---------------------------------------------- */
  201. W(0x00, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1) | /* 00 */
  202. W(0x10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 10 */
  203. W(0x20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 20 */
  204. W(0x30, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) , /* 30 */
  205. W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
  206. W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
  207. W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 60 */
  208. W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1) , /* 70 */
  209. W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
  210. W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
  211. W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1) | /* a0 */
  212. W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
  213. W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */
  214. W(0xd0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
  215. W(0xe0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* e0 */
  216. W(0xf0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /* f0 */
  217. /* ---------------------------------------------- */
  218. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  219. };
  220. #undef W
  221. /*
  222. * opcodes we may need to refine support for:
  223. *
  224. * 0f - 2-byte instructions: For many of these instructions, the validity
  225. * depends on the prefix and/or the reg field. On such instructions, we
  226. * just consider the opcode combination valid if it corresponds to any
  227. * valid instruction.
  228. *
  229. * 8f - Group 1 - only reg = 0 is OK
  230. * c6-c7 - Group 11 - only reg = 0 is OK
  231. * d9-df - fpu insns with some illegal encodings
  232. * f2, f3 - repnz, repz prefixes. These are also the first byte for
  233. * certain floating-point instructions, such as addsd.
  234. *
  235. * fe - Group 4 - only reg = 0 or 1 is OK
  236. * ff - Group 5 - only reg = 0-6 is OK
  237. *
  238. * others -- Do we need to support these?
  239. *
  240. * 0f - (floating-point?) prefetch instructions
  241. * 07, 17, 1f - pop es, pop ss, pop ds
  242. * 26, 2e, 36, 3e - es:, cs:, ss:, ds: segment prefixes --
  243. * but 64 and 65 (fs: and gs:) seem to be used, so we support them
  244. * 67 - addr16 prefix
  245. * ce - into
  246. * f0 - lock prefix
  247. */
  248. /*
  249. * TODO:
  250. * - Where necessary, examine the modrm byte and allow only valid instructions
  251. * in the different Groups and fpu instructions.
  252. */
  253. static bool is_prefix_bad(struct insn *insn)
  254. {
  255. int i;
  256. for (i = 0; i < insn->prefixes.nbytes; i++) {
  257. switch (insn->prefixes.bytes[i]) {
  258. case 0x26: /* INAT_PFX_ES */
  259. case 0x2E: /* INAT_PFX_CS */
  260. case 0x36: /* INAT_PFX_DS */
  261. case 0x3E: /* INAT_PFX_SS */
  262. case 0xF0: /* INAT_PFX_LOCK */
  263. return true;
  264. }
  265. }
  266. return false;
  267. }
  268. static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool x86_64)
  269. {
  270. u32 volatile *good_insns;
  271. insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64);
  272. /* has the side-effect of processing the entire instruction */
  273. insn_get_length(insn);
  274. if (WARN_ON_ONCE(!insn_complete(insn)))
  275. return -ENOEXEC;
  276. if (is_prefix_bad(insn))
  277. return -ENOTSUPP;
  278. if (x86_64)
  279. good_insns = good_insns_64;
  280. else
  281. good_insns = good_insns_32;
  282. if (test_bit(OPCODE1(insn), (unsigned long *)good_insns))
  283. return 0;
  284. if (insn->opcode.nbytes == 2) {
  285. if (test_bit(OPCODE2(insn), (unsigned long *)good_2byte_insns))
  286. return 0;
  287. }
  288. return -ENOTSUPP;
  289. }
  290. #ifdef CONFIG_X86_64
  291. static inline bool is_64bit_mm(struct mm_struct *mm)
  292. {
  293. return !config_enabled(CONFIG_IA32_EMULATION) ||
  294. !(mm->context.ia32_compat == TIF_IA32);
  295. }
  296. /*
  297. * If arch_uprobe->insn doesn't use rip-relative addressing, return
  298. * immediately. Otherwise, rewrite the instruction so that it accesses
  299. * its memory operand indirectly through a scratch register. Set
  300. * defparam->fixups accordingly. (The contents of the scratch register
  301. * will be saved before we single-step the modified instruction,
  302. * and restored afterward).
  303. *
  304. * We do this because a rip-relative instruction can access only a
  305. * relatively small area (+/- 2 GB from the instruction), and the XOL
  306. * area typically lies beyond that area. At least for instructions
  307. * that store to memory, we can't execute the original instruction
  308. * and "fix things up" later, because the misdirected store could be
  309. * disastrous.
  310. *
  311. * Some useful facts about rip-relative instructions:
  312. *
  313. * - There's always a modrm byte with bit layout "00 reg 101".
  314. * - There's never a SIB byte.
  315. * - The displacement is always 4 bytes.
  316. * - REX.B=1 bit in REX prefix, which normally extends r/m field,
  317. * has no effect on rip-relative mode. It doesn't make modrm byte
  318. * with r/m=101 refer to register 1101 = R13.
  319. */
  320. static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn)
  321. {
  322. u8 *cursor;
  323. u8 reg;
  324. u8 reg2;
  325. if (!insn_rip_relative(insn))
  326. return;
  327. /*
  328. * insn_rip_relative() would have decoded rex_prefix, vex_prefix, modrm.
  329. * Clear REX.b bit (extension of MODRM.rm field):
  330. * we want to encode low numbered reg, not r8+.
  331. */
  332. if (insn->rex_prefix.nbytes) {
  333. cursor = auprobe->insn + insn_offset_rex_prefix(insn);
  334. /* REX byte has 0100wrxb layout, clearing REX.b bit */
  335. *cursor &= 0xfe;
  336. }
  337. /*
  338. * Similar treatment for VEX3 prefix.
  339. * TODO: add XOP/EVEX treatment when insn decoder supports them
  340. */
  341. if (insn->vex_prefix.nbytes == 3) {
  342. /*
  343. * vex2: c5 rvvvvLpp (has no b bit)
  344. * vex3/xop: c4/8f rxbmmmmm wvvvvLpp
  345. * evex: 62 rxbR00mm wvvvv1pp zllBVaaa
  346. * (evex will need setting of both b and x since
  347. * in non-sib encoding evex.x is 4th bit of MODRM.rm)
  348. * Setting VEX3.b (setting because it has inverted meaning):
  349. */
  350. cursor = auprobe->insn + insn_offset_vex_prefix(insn) + 1;
  351. *cursor |= 0x20;
  352. }
  353. /*
  354. * Convert from rip-relative addressing to register-relative addressing
  355. * via a scratch register.
  356. *
  357. * This is tricky since there are insns with modrm byte
  358. * which also use registers not encoded in modrm byte:
  359. * [i]div/[i]mul: implicitly use dx:ax
  360. * shift ops: implicitly use cx
  361. * cmpxchg: implicitly uses ax
  362. * cmpxchg8/16b: implicitly uses dx:ax and bx:cx
  363. * Encoding: 0f c7/1 modrm
  364. * The code below thinks that reg=1 (cx), chooses si as scratch.
  365. * mulx: implicitly uses dx: mulx r/m,r1,r2 does r1:r2 = dx * r/m.
  366. * First appeared in Haswell (BMI2 insn). It is vex-encoded.
  367. * Example where none of bx,cx,dx can be used as scratch reg:
  368. * c4 e2 63 f6 0d disp32 mulx disp32(%rip),%ebx,%ecx
  369. * [v]pcmpistri: implicitly uses cx, xmm0
  370. * [v]pcmpistrm: implicitly uses xmm0
  371. * [v]pcmpestri: implicitly uses ax, dx, cx, xmm0
  372. * [v]pcmpestrm: implicitly uses ax, dx, xmm0
  373. * Evil SSE4.2 string comparison ops from hell.
  374. * maskmovq/[v]maskmovdqu: implicitly uses (ds:rdi) as destination.
  375. * Encoding: 0f f7 modrm, 66 0f f7 modrm, vex-encoded: c5 f9 f7 modrm.
  376. * Store op1, byte-masked by op2 msb's in each byte, to (ds:rdi).
  377. * AMD says it has no 3-operand form (vex.vvvv must be 1111)
  378. * and that it can have only register operands, not mem
  379. * (its modrm byte must have mode=11).
  380. * If these restrictions will ever be lifted,
  381. * we'll need code to prevent selection of di as scratch reg!
  382. *
  383. * Summary: I don't know any insns with modrm byte which
  384. * use SI register implicitly. DI register is used only
  385. * by one insn (maskmovq) and BX register is used
  386. * only by one too (cmpxchg8b).
  387. * BP is stack-segment based (may be a problem?).
  388. * AX, DX, CX are off-limits (many implicit users).
  389. * SP is unusable (it's stack pointer - think about "pop mem";
  390. * also, rsp+disp32 needs sib encoding -> insn length change).
  391. */
  392. reg = MODRM_REG(insn); /* Fetch modrm.reg */
  393. reg2 = 0xff; /* Fetch vex.vvvv */
  394. if (insn->vex_prefix.nbytes == 2)
  395. reg2 = insn->vex_prefix.bytes[1];
  396. else if (insn->vex_prefix.nbytes == 3)
  397. reg2 = insn->vex_prefix.bytes[2];
  398. /*
  399. * TODO: add XOP, EXEV vvvv reading.
  400. *
  401. * vex.vvvv field is in bits 6-3, bits are inverted.
  402. * But in 32-bit mode, high-order bit may be ignored.
  403. * Therefore, let's consider only 3 low-order bits.
  404. */
  405. reg2 = ((reg2 >> 3) & 0x7) ^ 0x7;
  406. /*
  407. * Register numbering is ax,cx,dx,bx, sp,bp,si,di, r8..r15.
  408. *
  409. * Choose scratch reg. Order is important: must not select bx
  410. * if we can use si (cmpxchg8b case!)
  411. */
  412. if (reg != 6 && reg2 != 6) {
  413. reg2 = 6;
  414. auprobe->defparam.fixups |= UPROBE_FIX_RIP_SI;
  415. } else if (reg != 7 && reg2 != 7) {
  416. reg2 = 7;
  417. auprobe->defparam.fixups |= UPROBE_FIX_RIP_DI;
  418. /* TODO (paranoia): force maskmovq to not use di */
  419. } else {
  420. reg2 = 3;
  421. auprobe->defparam.fixups |= UPROBE_FIX_RIP_BX;
  422. }
  423. /*
  424. * Point cursor at the modrm byte. The next 4 bytes are the
  425. * displacement. Beyond the displacement, for some instructions,
  426. * is the immediate operand.
  427. */
  428. cursor = auprobe->insn + insn_offset_modrm(insn);
  429. /*
  430. * Change modrm from "00 reg 101" to "10 reg reg2". Example:
  431. * 89 05 disp32 mov %eax,disp32(%rip) becomes
  432. * 89 86 disp32 mov %eax,disp32(%rsi)
  433. */
  434. *cursor = 0x80 | (reg << 3) | reg2;
  435. }
  436. static inline unsigned long *
  437. scratch_reg(struct arch_uprobe *auprobe, struct pt_regs *regs)
  438. {
  439. if (auprobe->defparam.fixups & UPROBE_FIX_RIP_SI)
  440. return &regs->si;
  441. if (auprobe->defparam.fixups & UPROBE_FIX_RIP_DI)
  442. return &regs->di;
  443. return &regs->bx;
  444. }
  445. /*
  446. * If we're emulating a rip-relative instruction, save the contents
  447. * of the scratch register and store the target address in that register.
  448. */
  449. static void riprel_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  450. {
  451. if (auprobe->defparam.fixups & UPROBE_FIX_RIP_MASK) {
  452. struct uprobe_task *utask = current->utask;
  453. unsigned long *sr = scratch_reg(auprobe, regs);
  454. utask->autask.saved_scratch_register = *sr;
  455. *sr = utask->vaddr + auprobe->defparam.ilen;
  456. }
  457. }
  458. static void riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  459. {
  460. if (auprobe->defparam.fixups & UPROBE_FIX_RIP_MASK) {
  461. struct uprobe_task *utask = current->utask;
  462. unsigned long *sr = scratch_reg(auprobe, regs);
  463. *sr = utask->autask.saved_scratch_register;
  464. }
  465. }
  466. #else /* 32-bit: */
  467. static inline bool is_64bit_mm(struct mm_struct *mm)
  468. {
  469. return false;
  470. }
  471. /*
  472. * No RIP-relative addressing on 32-bit
  473. */
  474. static void riprel_analyze(struct arch_uprobe *auprobe, struct insn *insn)
  475. {
  476. }
  477. static void riprel_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  478. {
  479. }
  480. static void riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  481. {
  482. }
  483. #endif /* CONFIG_X86_64 */
  484. struct uprobe_xol_ops {
  485. bool (*emulate)(struct arch_uprobe *, struct pt_regs *);
  486. int (*pre_xol)(struct arch_uprobe *, struct pt_regs *);
  487. int (*post_xol)(struct arch_uprobe *, struct pt_regs *);
  488. void (*abort)(struct arch_uprobe *, struct pt_regs *);
  489. };
  490. static inline int sizeof_long(void)
  491. {
  492. return is_ia32_task() ? 4 : 8;
  493. }
  494. static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
  495. {
  496. riprel_pre_xol(auprobe, regs);
  497. return 0;
  498. }
  499. static int push_ret_address(struct pt_regs *regs, unsigned long ip)
  500. {
  501. unsigned long new_sp = regs->sp - sizeof_long();
  502. if (copy_to_user((void __user *)new_sp, &ip, sizeof_long()))
  503. return -EFAULT;
  504. regs->sp = new_sp;
  505. return 0;
  506. }
  507. /*
  508. * We have to fix things up as follows:
  509. *
  510. * Typically, the new ip is relative to the copied instruction. We need
  511. * to make it relative to the original instruction (FIX_IP). Exceptions
  512. * are return instructions and absolute or indirect jump or call instructions.
  513. *
  514. * If the single-stepped instruction was a call, the return address that
  515. * is atop the stack is the address following the copied instruction. We
  516. * need to make it the address following the original instruction (FIX_CALL).
  517. *
  518. * If the original instruction was a rip-relative instruction such as
  519. * "movl %edx,0xnnnn(%rip)", we have instead executed an equivalent
  520. * instruction using a scratch register -- e.g., "movl %edx,0xnnnn(%rsi)".
  521. * We need to restore the contents of the scratch register
  522. * (FIX_RIP_reg).
  523. */
  524. static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
  525. {
  526. struct uprobe_task *utask = current->utask;
  527. riprel_post_xol(auprobe, regs);
  528. if (auprobe->defparam.fixups & UPROBE_FIX_IP) {
  529. long correction = utask->vaddr - utask->xol_vaddr;
  530. regs->ip += correction;
  531. } else if (auprobe->defparam.fixups & UPROBE_FIX_CALL) {
  532. regs->sp += sizeof_long(); /* Pop incorrect return address */
  533. if (push_ret_address(regs, utask->vaddr + auprobe->defparam.ilen))
  534. return -ERESTART;
  535. }
  536. /* popf; tell the caller to not touch TF */
  537. if (auprobe->defparam.fixups & UPROBE_FIX_SETF)
  538. utask->autask.saved_tf = true;
  539. return 0;
  540. }
  541. static void default_abort_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
  542. {
  543. riprel_post_xol(auprobe, regs);
  544. }
  545. static struct uprobe_xol_ops default_xol_ops = {
  546. .pre_xol = default_pre_xol_op,
  547. .post_xol = default_post_xol_op,
  548. .abort = default_abort_op,
  549. };
  550. static bool branch_is_call(struct arch_uprobe *auprobe)
  551. {
  552. return auprobe->branch.opc1 == 0xe8;
  553. }
  554. #define CASE_COND \
  555. COND(70, 71, XF(OF)) \
  556. COND(72, 73, XF(CF)) \
  557. COND(74, 75, XF(ZF)) \
  558. COND(78, 79, XF(SF)) \
  559. COND(7a, 7b, XF(PF)) \
  560. COND(76, 77, XF(CF) || XF(ZF)) \
  561. COND(7c, 7d, XF(SF) != XF(OF)) \
  562. COND(7e, 7f, XF(ZF) || XF(SF) != XF(OF))
  563. #define COND(op_y, op_n, expr) \
  564. case 0x ## op_y: DO((expr) != 0) \
  565. case 0x ## op_n: DO((expr) == 0)
  566. #define XF(xf) (!!(flags & X86_EFLAGS_ ## xf))
  567. static bool is_cond_jmp_opcode(u8 opcode)
  568. {
  569. switch (opcode) {
  570. #define DO(expr) \
  571. return true;
  572. CASE_COND
  573. #undef DO
  574. default:
  575. return false;
  576. }
  577. }
  578. static bool check_jmp_cond(struct arch_uprobe *auprobe, struct pt_regs *regs)
  579. {
  580. unsigned long flags = regs->flags;
  581. switch (auprobe->branch.opc1) {
  582. #define DO(expr) \
  583. return expr;
  584. CASE_COND
  585. #undef DO
  586. default: /* not a conditional jmp */
  587. return true;
  588. }
  589. }
  590. #undef XF
  591. #undef COND
  592. #undef CASE_COND
  593. static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
  594. {
  595. unsigned long new_ip = regs->ip += auprobe->branch.ilen;
  596. unsigned long offs = (long)auprobe->branch.offs;
  597. if (branch_is_call(auprobe)) {
  598. /*
  599. * If it fails we execute this (mangled, see the comment in
  600. * branch_clear_offset) insn out-of-line. In the likely case
  601. * this should trigger the trap, and the probed application
  602. * should die or restart the same insn after it handles the
  603. * signal, arch_uprobe_post_xol() won't be even called.
  604. *
  605. * But there is corner case, see the comment in ->post_xol().
  606. */
  607. if (push_ret_address(regs, new_ip))
  608. return false;
  609. } else if (!check_jmp_cond(auprobe, regs)) {
  610. offs = 0;
  611. }
  612. regs->ip = new_ip + offs;
  613. return true;
  614. }
  615. static int branch_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
  616. {
  617. BUG_ON(!branch_is_call(auprobe));
  618. /*
  619. * We can only get here if branch_emulate_op() failed to push the ret
  620. * address _and_ another thread expanded our stack before the (mangled)
  621. * "call" insn was executed out-of-line. Just restore ->sp and restart.
  622. * We could also restore ->ip and try to call branch_emulate_op() again.
  623. */
  624. regs->sp += sizeof_long();
  625. return -ERESTART;
  626. }
  627. static void branch_clear_offset(struct arch_uprobe *auprobe, struct insn *insn)
  628. {
  629. /*
  630. * Turn this insn into "call 1f; 1:", this is what we will execute
  631. * out-of-line if ->emulate() fails. We only need this to generate
  632. * a trap, so that the probed task receives the correct signal with
  633. * the properly filled siginfo.
  634. *
  635. * But see the comment in ->post_xol(), in the unlikely case it can
  636. * succeed. So we need to ensure that the new ->ip can not fall into
  637. * the non-canonical area and trigger #GP.
  638. *
  639. * We could turn it into (say) "pushf", but then we would need to
  640. * divorce ->insn[] and ->ixol[]. We need to preserve the 1st byte
  641. * of ->insn[] for set_orig_insn().
  642. */
  643. memset(auprobe->insn + insn_offset_immediate(insn),
  644. 0, insn->immediate.nbytes);
  645. }
  646. static struct uprobe_xol_ops branch_xol_ops = {
  647. .emulate = branch_emulate_op,
  648. .post_xol = branch_post_xol_op,
  649. };
  650. /* Returns -ENOSYS if branch_xol_ops doesn't handle this insn */
  651. static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
  652. {
  653. u8 opc1 = OPCODE1(insn);
  654. int i;
  655. switch (opc1) {
  656. case 0xeb: /* jmp 8 */
  657. case 0xe9: /* jmp 32 */
  658. case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */
  659. break;
  660. case 0xe8: /* call relative */
  661. branch_clear_offset(auprobe, insn);
  662. break;
  663. case 0x0f:
  664. if (insn->opcode.nbytes != 2)
  665. return -ENOSYS;
  666. /*
  667. * If it is a "near" conditional jmp, OPCODE2() - 0x10 matches
  668. * OPCODE1() of the "short" jmp which checks the same condition.
  669. */
  670. opc1 = OPCODE2(insn) - 0x10;
  671. default:
  672. if (!is_cond_jmp_opcode(opc1))
  673. return -ENOSYS;
  674. }
  675. /*
  676. * 16-bit overrides such as CALLW (66 e8 nn nn) are not supported.
  677. * Intel and AMD behavior differ in 64-bit mode: Intel ignores 66 prefix.
  678. * No one uses these insns, reject any branch insns with such prefix.
  679. */
  680. for (i = 0; i < insn->prefixes.nbytes; i++) {
  681. if (insn->prefixes.bytes[i] == 0x66)
  682. return -ENOTSUPP;
  683. }
  684. auprobe->branch.opc1 = opc1;
  685. auprobe->branch.ilen = insn->length;
  686. auprobe->branch.offs = insn->immediate.value;
  687. auprobe->ops = &branch_xol_ops;
  688. return 0;
  689. }
  690. /**
  691. * arch_uprobe_analyze_insn - instruction analysis including validity and fixups.
  692. * @mm: the probed address space.
  693. * @arch_uprobe: the probepoint information.
  694. * @addr: virtual address at which to install the probepoint
  695. * Return 0 on success or a -ve number on error.
  696. */
  697. int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long addr)
  698. {
  699. struct insn insn;
  700. u8 fix_ip_or_call = UPROBE_FIX_IP;
  701. int ret;
  702. ret = uprobe_init_insn(auprobe, &insn, is_64bit_mm(mm));
  703. if (ret)
  704. return ret;
  705. ret = branch_setup_xol_ops(auprobe, &insn);
  706. if (ret != -ENOSYS)
  707. return ret;
  708. /*
  709. * Figure out which fixups default_post_xol_op() will need to perform,
  710. * and annotate defparam->fixups accordingly.
  711. */
  712. switch (OPCODE1(&insn)) {
  713. case 0x9d: /* popf */
  714. auprobe->defparam.fixups |= UPROBE_FIX_SETF;
  715. break;
  716. case 0xc3: /* ret or lret -- ip is correct */
  717. case 0xcb:
  718. case 0xc2:
  719. case 0xca:
  720. case 0xea: /* jmp absolute -- ip is correct */
  721. fix_ip_or_call = 0;
  722. break;
  723. case 0x9a: /* call absolute - Fix return addr, not ip */
  724. fix_ip_or_call = UPROBE_FIX_CALL;
  725. break;
  726. case 0xff:
  727. switch (MODRM_REG(&insn)) {
  728. case 2: case 3: /* call or lcall, indirect */
  729. fix_ip_or_call = UPROBE_FIX_CALL;
  730. break;
  731. case 4: case 5: /* jmp or ljmp, indirect */
  732. fix_ip_or_call = 0;
  733. break;
  734. }
  735. /* fall through */
  736. default:
  737. riprel_analyze(auprobe, &insn);
  738. }
  739. auprobe->defparam.ilen = insn.length;
  740. auprobe->defparam.fixups |= fix_ip_or_call;
  741. auprobe->ops = &default_xol_ops;
  742. return 0;
  743. }
  744. /*
  745. * arch_uprobe_pre_xol - prepare to execute out of line.
  746. * @auprobe: the probepoint information.
  747. * @regs: reflects the saved user state of current task.
  748. */
  749. int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  750. {
  751. struct uprobe_task *utask = current->utask;
  752. if (auprobe->ops->pre_xol) {
  753. int err = auprobe->ops->pre_xol(auprobe, regs);
  754. if (err)
  755. return err;
  756. }
  757. regs->ip = utask->xol_vaddr;
  758. utask->autask.saved_trap_nr = current->thread.trap_nr;
  759. current->thread.trap_nr = UPROBE_TRAP_NR;
  760. utask->autask.saved_tf = !!(regs->flags & X86_EFLAGS_TF);
  761. regs->flags |= X86_EFLAGS_TF;
  762. if (test_tsk_thread_flag(current, TIF_BLOCKSTEP))
  763. set_task_blockstep(current, false);
  764. return 0;
  765. }
  766. /*
  767. * If xol insn itself traps and generates a signal(Say,
  768. * SIGILL/SIGSEGV/etc), then detect the case where a singlestepped
  769. * instruction jumps back to its own address. It is assumed that anything
  770. * like do_page_fault/do_trap/etc sets thread.trap_nr != -1.
  771. *
  772. * arch_uprobe_pre_xol/arch_uprobe_post_xol save/restore thread.trap_nr,
  773. * arch_uprobe_xol_was_trapped() simply checks that ->trap_nr is not equal to
  774. * UPROBE_TRAP_NR == -1 set by arch_uprobe_pre_xol().
  775. */
  776. bool arch_uprobe_xol_was_trapped(struct task_struct *t)
  777. {
  778. if (t->thread.trap_nr != UPROBE_TRAP_NR)
  779. return true;
  780. return false;
  781. }
  782. /*
  783. * Called after single-stepping. To avoid the SMP problems that can
  784. * occur when we temporarily put back the original opcode to
  785. * single-step, we single-stepped a copy of the instruction.
  786. *
  787. * This function prepares to resume execution after the single-step.
  788. */
  789. int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  790. {
  791. struct uprobe_task *utask = current->utask;
  792. bool send_sigtrap = utask->autask.saved_tf;
  793. int err = 0;
  794. WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR);
  795. current->thread.trap_nr = utask->autask.saved_trap_nr;
  796. if (auprobe->ops->post_xol) {
  797. err = auprobe->ops->post_xol(auprobe, regs);
  798. if (err) {
  799. /*
  800. * Restore ->ip for restart or post mortem analysis.
  801. * ->post_xol() must not return -ERESTART unless this
  802. * is really possible.
  803. */
  804. regs->ip = utask->vaddr;
  805. if (err == -ERESTART)
  806. err = 0;
  807. send_sigtrap = false;
  808. }
  809. }
  810. /*
  811. * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP
  812. * so we can get an extra SIGTRAP if we do not clear TF. We need
  813. * to examine the opcode to make it right.
  814. */
  815. if (send_sigtrap)
  816. send_sig(SIGTRAP, current, 0);
  817. if (!utask->autask.saved_tf)
  818. regs->flags &= ~X86_EFLAGS_TF;
  819. return err;
  820. }
  821. /* callback routine for handling exceptions. */
  822. int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val, void *data)
  823. {
  824. struct die_args *args = data;
  825. struct pt_regs *regs = args->regs;
  826. int ret = NOTIFY_DONE;
  827. /* We are only interested in userspace traps */
  828. if (regs && !user_mode(regs))
  829. return NOTIFY_DONE;
  830. switch (val) {
  831. case DIE_INT3:
  832. if (uprobe_pre_sstep_notifier(regs))
  833. ret = NOTIFY_STOP;
  834. break;
  835. case DIE_DEBUG:
  836. if (uprobe_post_sstep_notifier(regs))
  837. ret = NOTIFY_STOP;
  838. default:
  839. break;
  840. }
  841. return ret;
  842. }
  843. /*
  844. * This function gets called when XOL instruction either gets trapped or
  845. * the thread has a fatal signal. Reset the instruction pointer to its
  846. * probed address for the potential restart or for post mortem analysis.
  847. */
  848. void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
  849. {
  850. struct uprobe_task *utask = current->utask;
  851. if (auprobe->ops->abort)
  852. auprobe->ops->abort(auprobe, regs);
  853. current->thread.trap_nr = utask->autask.saved_trap_nr;
  854. regs->ip = utask->vaddr;
  855. /* clear TF if it was set by us in arch_uprobe_pre_xol() */
  856. if (!utask->autask.saved_tf)
  857. regs->flags &= ~X86_EFLAGS_TF;
  858. }
  859. static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
  860. {
  861. if (auprobe->ops->emulate)
  862. return auprobe->ops->emulate(auprobe, regs);
  863. return false;
  864. }
  865. bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
  866. {
  867. bool ret = __skip_sstep(auprobe, regs);
  868. if (ret && (regs->flags & X86_EFLAGS_TF))
  869. send_sig(SIGTRAP, current, 0);
  870. return ret;
  871. }
  872. unsigned long
  873. arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs *regs)
  874. {
  875. int rasize = sizeof_long(), nleft;
  876. unsigned long orig_ret_vaddr = 0; /* clear high bits for 32-bit apps */
  877. if (copy_from_user(&orig_ret_vaddr, (void __user *)regs->sp, rasize))
  878. return -1;
  879. /* check whether address has been already hijacked */
  880. if (orig_ret_vaddr == trampoline_vaddr)
  881. return orig_ret_vaddr;
  882. nleft = copy_to_user((void __user *)regs->sp, &trampoline_vaddr, rasize);
  883. if (likely(!nleft))
  884. return orig_ret_vaddr;
  885. if (nleft != rasize) {
  886. pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
  887. "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
  888. force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
  889. }
  890. return -1;
  891. }