ptrace.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * arch/s390/kernel/ptrace.c
  3. *
  4. * S390 version
  5. * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
  7. * Martin Schwidefsky (schwidefsky@de.ibm.com)
  8. *
  9. * Based on PowerPC version
  10. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  11. *
  12. * Derived from "arch/m68k/kernel/ptrace.c"
  13. * Copyright (C) 1994 by Hamish Macdonald
  14. * Taken from linux/kernel/ptrace.c and modified for M680x0.
  15. * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
  16. *
  17. * Modified by Cort Dougan (cort@cs.nmt.edu)
  18. *
  19. *
  20. * This file is subject to the terms and conditions of the GNU General
  21. * Public License. See the file README.legal in the main directory of
  22. * this archive for more details.
  23. */
  24. #include <linux/kernel.h>
  25. #include <linux/sched.h>
  26. #include <linux/mm.h>
  27. #include <linux/smp.h>
  28. #include <linux/smp_lock.h>
  29. #include <linux/errno.h>
  30. #include <linux/ptrace.h>
  31. #include <linux/user.h>
  32. #include <linux/security.h>
  33. #include <linux/audit.h>
  34. #include <linux/signal.h>
  35. #include <asm/segment.h>
  36. #include <asm/page.h>
  37. #include <asm/pgtable.h>
  38. #include <asm/pgalloc.h>
  39. #include <asm/system.h>
  40. #include <asm/uaccess.h>
  41. #include <asm/unistd.h>
  42. #include "entry.h"
  43. #ifdef CONFIG_COMPAT
  44. #include "compat_ptrace.h"
  45. #endif
  46. static void
  47. FixPerRegisters(struct task_struct *task)
  48. {
  49. struct pt_regs *regs;
  50. per_struct *per_info;
  51. regs = task_pt_regs(task);
  52. per_info = (per_struct *) &task->thread.per_info;
  53. per_info->control_regs.bits.em_instruction_fetch =
  54. per_info->single_step | per_info->instruction_fetch;
  55. if (per_info->single_step) {
  56. per_info->control_regs.bits.starting_addr = 0;
  57. #ifdef CONFIG_COMPAT
  58. if (test_thread_flag(TIF_31BIT))
  59. per_info->control_regs.bits.ending_addr = 0x7fffffffUL;
  60. else
  61. #endif
  62. per_info->control_regs.bits.ending_addr = PSW_ADDR_INSN;
  63. } else {
  64. per_info->control_regs.bits.starting_addr =
  65. per_info->starting_addr;
  66. per_info->control_regs.bits.ending_addr =
  67. per_info->ending_addr;
  68. }
  69. /*
  70. * if any of the control reg tracing bits are on
  71. * we switch on per in the psw
  72. */
  73. if (per_info->control_regs.words.cr[0] & PER_EM_MASK)
  74. regs->psw.mask |= PSW_MASK_PER;
  75. else
  76. regs->psw.mask &= ~PSW_MASK_PER;
  77. if (per_info->control_regs.bits.em_storage_alteration)
  78. per_info->control_regs.bits.storage_alt_space_ctl = 1;
  79. else
  80. per_info->control_regs.bits.storage_alt_space_ctl = 0;
  81. }
  82. void user_enable_single_step(struct task_struct *task)
  83. {
  84. task->thread.per_info.single_step = 1;
  85. FixPerRegisters(task);
  86. }
  87. void user_disable_single_step(struct task_struct *task)
  88. {
  89. task->thread.per_info.single_step = 0;
  90. FixPerRegisters(task);
  91. }
  92. /*
  93. * Called by kernel/ptrace.c when detaching..
  94. *
  95. * Make sure single step bits etc are not set.
  96. */
  97. void
  98. ptrace_disable(struct task_struct *child)
  99. {
  100. /* make sure the single step bit is not set. */
  101. user_disable_single_step(child);
  102. }
  103. #ifndef CONFIG_64BIT
  104. # define __ADDR_MASK 3
  105. #else
  106. # define __ADDR_MASK 7
  107. #endif
  108. /*
  109. * Read the word at offset addr from the user area of a process. The
  110. * trouble here is that the information is littered over different
  111. * locations. The process registers are found on the kernel stack,
  112. * the floating point stuff and the trace settings are stored in
  113. * the task structure. In addition the different structures in
  114. * struct user contain pad bytes that should be read as zeroes.
  115. * Lovely...
  116. */
  117. static int
  118. peek_user(struct task_struct *child, addr_t addr, addr_t data)
  119. {
  120. struct user *dummy = NULL;
  121. addr_t offset, tmp, mask;
  122. /*
  123. * Stupid gdb peeks/pokes the access registers in 64 bit with
  124. * an alignment of 4. Programmers from hell...
  125. */
  126. mask = __ADDR_MASK;
  127. #ifdef CONFIG_64BIT
  128. if (addr >= (addr_t) &dummy->regs.acrs &&
  129. addr < (addr_t) &dummy->regs.orig_gpr2)
  130. mask = 3;
  131. #endif
  132. if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK)
  133. return -EIO;
  134. if (addr < (addr_t) &dummy->regs.acrs) {
  135. /*
  136. * psw and gprs are stored on the stack
  137. */
  138. tmp = *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr);
  139. if (addr == (addr_t) &dummy->regs.psw.mask)
  140. /* Remove per bit from user psw. */
  141. tmp &= ~PSW_MASK_PER;
  142. } else if (addr < (addr_t) &dummy->regs.orig_gpr2) {
  143. /*
  144. * access registers are stored in the thread structure
  145. */
  146. offset = addr - (addr_t) &dummy->regs.acrs;
  147. #ifdef CONFIG_64BIT
  148. /*
  149. * Very special case: old & broken 64 bit gdb reading
  150. * from acrs[15]. Result is a 64 bit value. Read the
  151. * 32 bit acrs[15] value and shift it by 32. Sick...
  152. */
  153. if (addr == (addr_t) &dummy->regs.acrs[15])
  154. tmp = ((unsigned long) child->thread.acrs[15]) << 32;
  155. else
  156. #endif
  157. tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset);
  158. } else if (addr == (addr_t) &dummy->regs.orig_gpr2) {
  159. /*
  160. * orig_gpr2 is stored on the kernel stack
  161. */
  162. tmp = (addr_t) task_pt_regs(child)->orig_gpr2;
  163. } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
  164. /*
  165. * floating point regs. are stored in the thread structure
  166. */
  167. offset = addr - (addr_t) &dummy->regs.fp_regs;
  168. tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset);
  169. if (addr == (addr_t) &dummy->regs.fp_regs.fpc)
  170. tmp &= (unsigned long) FPC_VALID_MASK
  171. << (BITS_PER_LONG - 32);
  172. } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) {
  173. /*
  174. * per_info is found in the thread structure
  175. */
  176. offset = addr - (addr_t) &dummy->regs.per_info;
  177. tmp = *(addr_t *)((addr_t) &child->thread.per_info + offset);
  178. } else
  179. tmp = 0;
  180. return put_user(tmp, (addr_t __user *) data);
  181. }
  182. /*
  183. * Write a word to the user area of a process at location addr. This
  184. * operation does have an additional problem compared to peek_user.
  185. * Stores to the program status word and on the floating point
  186. * control register needs to get checked for validity.
  187. */
  188. static int
  189. poke_user(struct task_struct *child, addr_t addr, addr_t data)
  190. {
  191. struct user *dummy = NULL;
  192. addr_t offset, mask;
  193. /*
  194. * Stupid gdb peeks/pokes the access registers in 64 bit with
  195. * an alignment of 4. Programmers from hell indeed...
  196. */
  197. mask = __ADDR_MASK;
  198. #ifdef CONFIG_64BIT
  199. if (addr >= (addr_t) &dummy->regs.acrs &&
  200. addr < (addr_t) &dummy->regs.orig_gpr2)
  201. mask = 3;
  202. #endif
  203. if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK)
  204. return -EIO;
  205. if (addr < (addr_t) &dummy->regs.acrs) {
  206. /*
  207. * psw and gprs are stored on the stack
  208. */
  209. if (addr == (addr_t) &dummy->regs.psw.mask &&
  210. #ifdef CONFIG_COMPAT
  211. data != PSW_MASK_MERGE(psw_user32_bits, data) &&
  212. #endif
  213. data != PSW_MASK_MERGE(psw_user_bits, data))
  214. /* Invalid psw mask. */
  215. return -EINVAL;
  216. #ifndef CONFIG_64BIT
  217. if (addr == (addr_t) &dummy->regs.psw.addr)
  218. /* I'd like to reject addresses without the
  219. high order bit but older gdb's rely on it */
  220. data |= PSW_ADDR_AMODE;
  221. #endif
  222. *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
  223. } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) {
  224. /*
  225. * access registers are stored in the thread structure
  226. */
  227. offset = addr - (addr_t) &dummy->regs.acrs;
  228. #ifdef CONFIG_64BIT
  229. /*
  230. * Very special case: old & broken 64 bit gdb writing
  231. * to acrs[15] with a 64 bit value. Ignore the lower
  232. * half of the value and write the upper 32 bit to
  233. * acrs[15]. Sick...
  234. */
  235. if (addr == (addr_t) &dummy->regs.acrs[15])
  236. child->thread.acrs[15] = (unsigned int) (data >> 32);
  237. else
  238. #endif
  239. *(addr_t *)((addr_t) &child->thread.acrs + offset) = data;
  240. } else if (addr == (addr_t) &dummy->regs.orig_gpr2) {
  241. /*
  242. * orig_gpr2 is stored on the kernel stack
  243. */
  244. task_pt_regs(child)->orig_gpr2 = data;
  245. } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
  246. /*
  247. * floating point regs. are stored in the thread structure
  248. */
  249. if (addr == (addr_t) &dummy->regs.fp_regs.fpc &&
  250. (data & ~((unsigned long) FPC_VALID_MASK
  251. << (BITS_PER_LONG - 32))) != 0)
  252. return -EINVAL;
  253. offset = addr - (addr_t) &dummy->regs.fp_regs;
  254. *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data;
  255. } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) {
  256. /*
  257. * per_info is found in the thread structure
  258. */
  259. offset = addr - (addr_t) &dummy->regs.per_info;
  260. *(addr_t *)((addr_t) &child->thread.per_info + offset) = data;
  261. }
  262. FixPerRegisters(child);
  263. return 0;
  264. }
  265. long arch_ptrace(struct task_struct *child, long request, long addr, long data)
  266. {
  267. ptrace_area parea;
  268. int copied, ret;
  269. switch (request) {
  270. case PTRACE_PEEKTEXT:
  271. case PTRACE_PEEKDATA:
  272. /* Remove high order bit from address (only for 31 bit). */
  273. addr &= PSW_ADDR_INSN;
  274. /* read word at location addr. */
  275. return generic_ptrace_peekdata(child, addr, data);
  276. case PTRACE_PEEKUSR:
  277. /* read the word at location addr in the USER area. */
  278. return peek_user(child, addr, data);
  279. case PTRACE_POKETEXT:
  280. case PTRACE_POKEDATA:
  281. /* Remove high order bit from address (only for 31 bit). */
  282. addr &= PSW_ADDR_INSN;
  283. /* write the word at location addr. */
  284. return generic_ptrace_pokedata(child, addr, data);
  285. case PTRACE_POKEUSR:
  286. /* write the word at location addr in the USER area */
  287. return poke_user(child, addr, data);
  288. case PTRACE_PEEKUSR_AREA:
  289. case PTRACE_POKEUSR_AREA:
  290. if (copy_from_user(&parea, (void __force __user *) addr,
  291. sizeof(parea)))
  292. return -EFAULT;
  293. addr = parea.kernel_addr;
  294. data = parea.process_addr;
  295. copied = 0;
  296. while (copied < parea.len) {
  297. if (request == PTRACE_PEEKUSR_AREA)
  298. ret = peek_user(child, addr, data);
  299. else {
  300. addr_t utmp;
  301. if (get_user(utmp,
  302. (addr_t __force __user *) data))
  303. return -EFAULT;
  304. ret = poke_user(child, addr, utmp);
  305. }
  306. if (ret)
  307. return ret;
  308. addr += sizeof(unsigned long);
  309. data += sizeof(unsigned long);
  310. copied += sizeof(unsigned long);
  311. }
  312. return 0;
  313. }
  314. return ptrace_request(child, request, addr, data);
  315. }
  316. #ifdef CONFIG_COMPAT
  317. /*
  318. * Now the fun part starts... a 31 bit program running in the
  319. * 31 bit emulation tracing another program. PTRACE_PEEKTEXT,
  320. * PTRACE_PEEKDATA, PTRACE_POKETEXT and PTRACE_POKEDATA are easy
  321. * to handle, the difference to the 64 bit versions of the requests
  322. * is that the access is done in multiples of 4 byte instead of
  323. * 8 bytes (sizeof(unsigned long) on 31/64 bit).
  324. * The ugly part are PTRACE_PEEKUSR, PTRACE_PEEKUSR_AREA,
  325. * PTRACE_POKEUSR and PTRACE_POKEUSR_AREA. If the traced program
  326. * is a 31 bit program too, the content of struct user can be
  327. * emulated. A 31 bit program peeking into the struct user of
  328. * a 64 bit program is a no-no.
  329. */
  330. /*
  331. * Same as peek_user but for a 31 bit program.
  332. */
  333. static int
  334. peek_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
  335. {
  336. struct user32 *dummy32 = NULL;
  337. per_struct32 *dummy_per32 = NULL;
  338. addr_t offset;
  339. __u32 tmp;
  340. if (!test_thread_flag(TIF_31BIT) ||
  341. (addr & 3) || addr > sizeof(struct user) - 3)
  342. return -EIO;
  343. if (addr < (addr_t) &dummy32->regs.acrs) {
  344. /*
  345. * psw and gprs are stored on the stack
  346. */
  347. if (addr == (addr_t) &dummy32->regs.psw.mask) {
  348. /* Fake a 31 bit psw mask. */
  349. tmp = (__u32)(task_pt_regs(child)->psw.mask >> 32);
  350. tmp = PSW32_MASK_MERGE(psw32_user_bits, tmp);
  351. } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
  352. /* Fake a 31 bit psw address. */
  353. tmp = (__u32) task_pt_regs(child)->psw.addr |
  354. PSW32_ADDR_AMODE31;
  355. } else {
  356. /* gpr 0-15 */
  357. tmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw +
  358. addr*2 + 4);
  359. }
  360. } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
  361. /*
  362. * access registers are stored in the thread structure
  363. */
  364. offset = addr - (addr_t) &dummy32->regs.acrs;
  365. tmp = *(__u32*)((addr_t) &child->thread.acrs + offset);
  366. } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {
  367. /*
  368. * orig_gpr2 is stored on the kernel stack
  369. */
  370. tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4);
  371. } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
  372. /*
  373. * floating point regs. are stored in the thread structure
  374. */
  375. offset = addr - (addr_t) &dummy32->regs.fp_regs;
  376. tmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset);
  377. } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {
  378. /*
  379. * per_info is found in the thread structure
  380. */
  381. offset = addr - (addr_t) &dummy32->regs.per_info;
  382. /* This is magic. See per_struct and per_struct32. */
  383. if ((offset >= (addr_t) &dummy_per32->control_regs &&
  384. offset < (addr_t) (&dummy_per32->control_regs + 1)) ||
  385. (offset >= (addr_t) &dummy_per32->starting_addr &&
  386. offset <= (addr_t) &dummy_per32->ending_addr) ||
  387. offset == (addr_t) &dummy_per32->lowcore.words.address)
  388. offset = offset*2 + 4;
  389. else
  390. offset = offset*2;
  391. tmp = *(__u32 *)((addr_t) &child->thread.per_info + offset);
  392. } else
  393. tmp = 0;
  394. return put_user(tmp, (__u32 __user *) data);
  395. }
  396. /*
  397. * Same as poke_user but for a 31 bit program.
  398. */
  399. static int
  400. poke_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
  401. {
  402. struct user32 *dummy32 = NULL;
  403. per_struct32 *dummy_per32 = NULL;
  404. addr_t offset;
  405. __u32 tmp;
  406. if (!test_thread_flag(TIF_31BIT) ||
  407. (addr & 3) || addr > sizeof(struct user32) - 3)
  408. return -EIO;
  409. tmp = (__u32) data;
  410. if (addr < (addr_t) &dummy32->regs.acrs) {
  411. /*
  412. * psw, gprs, acrs and orig_gpr2 are stored on the stack
  413. */
  414. if (addr == (addr_t) &dummy32->regs.psw.mask) {
  415. /* Build a 64 bit psw mask from 31 bit mask. */
  416. if (tmp != PSW32_MASK_MERGE(psw32_user_bits, tmp))
  417. /* Invalid psw mask. */
  418. return -EINVAL;
  419. task_pt_regs(child)->psw.mask =
  420. PSW_MASK_MERGE(psw_user32_bits, (__u64) tmp << 32);
  421. } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
  422. /* Build a 64 bit psw address from 31 bit address. */
  423. task_pt_regs(child)->psw.addr =
  424. (__u64) tmp & PSW32_ADDR_INSN;
  425. } else {
  426. /* gpr 0-15 */
  427. *(__u32*)((addr_t) &task_pt_regs(child)->psw
  428. + addr*2 + 4) = tmp;
  429. }
  430. } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
  431. /*
  432. * access registers are stored in the thread structure
  433. */
  434. offset = addr - (addr_t) &dummy32->regs.acrs;
  435. *(__u32*)((addr_t) &child->thread.acrs + offset) = tmp;
  436. } else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {
  437. /*
  438. * orig_gpr2 is stored on the kernel stack
  439. */
  440. *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4) = tmp;
  441. } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
  442. /*
  443. * floating point regs. are stored in the thread structure
  444. */
  445. if (addr == (addr_t) &dummy32->regs.fp_regs.fpc &&
  446. (tmp & ~FPC_VALID_MASK) != 0)
  447. /* Invalid floating point control. */
  448. return -EINVAL;
  449. offset = addr - (addr_t) &dummy32->regs.fp_regs;
  450. *(__u32 *)((addr_t) &child->thread.fp_regs + offset) = tmp;
  451. } else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {
  452. /*
  453. * per_info is found in the thread structure.
  454. */
  455. offset = addr - (addr_t) &dummy32->regs.per_info;
  456. /*
  457. * This is magic. See per_struct and per_struct32.
  458. * By incident the offsets in per_struct are exactly
  459. * twice the offsets in per_struct32 for all fields.
  460. * The 8 byte fields need special handling though,
  461. * because the second half (bytes 4-7) is needed and
  462. * not the first half.
  463. */
  464. if ((offset >= (addr_t) &dummy_per32->control_regs &&
  465. offset < (addr_t) (&dummy_per32->control_regs + 1)) ||
  466. (offset >= (addr_t) &dummy_per32->starting_addr &&
  467. offset <= (addr_t) &dummy_per32->ending_addr) ||
  468. offset == (addr_t) &dummy_per32->lowcore.words.address)
  469. offset = offset*2 + 4;
  470. else
  471. offset = offset*2;
  472. *(__u32 *)((addr_t) &child->thread.per_info + offset) = tmp;
  473. }
  474. FixPerRegisters(child);
  475. return 0;
  476. }
  477. long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
  478. compat_ulong_t caddr, compat_ulong_t cdata)
  479. {
  480. unsigned long addr = caddr;
  481. unsigned long data = cdata;
  482. ptrace_area_emu31 parea;
  483. int copied, ret;
  484. switch (request) {
  485. case PTRACE_PEEKUSR:
  486. /* read the word at location addr in the USER area. */
  487. return peek_user_emu31(child, addr, data);
  488. case PTRACE_POKEUSR:
  489. /* write the word at location addr in the USER area */
  490. return poke_user_emu31(child, addr, data);
  491. case PTRACE_PEEKUSR_AREA:
  492. case PTRACE_POKEUSR_AREA:
  493. if (copy_from_user(&parea, (void __force __user *) addr,
  494. sizeof(parea)))
  495. return -EFAULT;
  496. addr = parea.kernel_addr;
  497. data = parea.process_addr;
  498. copied = 0;
  499. while (copied < parea.len) {
  500. if (request == PTRACE_PEEKUSR_AREA)
  501. ret = peek_user_emu31(child, addr, data);
  502. else {
  503. __u32 utmp;
  504. if (get_user(utmp,
  505. (__u32 __force __user *) data))
  506. return -EFAULT;
  507. ret = poke_user_emu31(child, addr, utmp);
  508. }
  509. if (ret)
  510. return ret;
  511. addr += sizeof(unsigned int);
  512. data += sizeof(unsigned int);
  513. copied += sizeof(unsigned int);
  514. }
  515. return 0;
  516. }
  517. return compat_ptrace_request(child, request, addr, data);
  518. }
  519. #endif
  520. asmlinkage void
  521. syscall_trace(struct pt_regs *regs, int entryexit)
  522. {
  523. if (unlikely(current->audit_context) && entryexit)
  524. audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]), regs->gprs[2]);
  525. if (!test_thread_flag(TIF_SYSCALL_TRACE))
  526. goto out;
  527. if (!(current->ptrace & PT_PTRACED))
  528. goto out;
  529. ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
  530. ? 0x80 : 0));
  531. /*
  532. * If the debuffer has set an invalid system call number,
  533. * we prepare to skip the system call restart handling.
  534. */
  535. if (!entryexit && regs->gprs[2] >= NR_syscalls)
  536. regs->trap = -1;
  537. /*
  538. * this isn't the same as continuing with a signal, but it will do
  539. * for normal use. strace only continues with a signal if the
  540. * stopping signal is not SIGTRAP. -brl
  541. */
  542. if (current->exit_code) {
  543. send_sig(current->exit_code, current, 1);
  544. current->exit_code = 0;
  545. }
  546. out:
  547. if (unlikely(current->audit_context) && !entryexit)
  548. audit_syscall_entry(test_thread_flag(TIF_31BIT)?AUDIT_ARCH_S390:AUDIT_ARCH_S390X,
  549. regs->gprs[2], regs->orig_gpr2, regs->gprs[3],
  550. regs->gprs[4], regs->gprs[5]);
  551. }