ptrace.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 Ross Biro
  7. * Copyright (C) Linus Torvalds
  8. * Copyright (C) 1994, 95, 96, 97, 98, 2000 Ralf Baechle
  9. * Copyright (C) 1996 David S. Miller
  10. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  11. * Copyright (C) 1999 MIPS Technologies, Inc.
  12. * Copyright (C) 2000 Ulf Carlsson
  13. *
  14. * At this time Linux/MIPS64 only supports syscall tracing, even for 32-bit
  15. * binaries.
  16. */
  17. #include <linux/compiler.h>
  18. #include <linux/context_tracking.h>
  19. #include <linux/elf.h>
  20. #include <linux/kernel.h>
  21. #include <linux/sched.h>
  22. #include <linux/mm.h>
  23. #include <linux/errno.h>
  24. #include <linux/ptrace.h>
  25. #include <linux/regset.h>
  26. #include <linux/smp.h>
  27. #include <linux/user.h>
  28. #include <linux/security.h>
  29. #include <linux/tracehook.h>
  30. #include <linux/audit.h>
  31. #include <linux/seccomp.h>
  32. #include <asm/byteorder.h>
  33. #include <asm/cpu.h>
  34. #include <asm/dsp.h>
  35. #include <asm/fpu.h>
  36. #include <asm/mipsregs.h>
  37. #include <asm/mipsmtregs.h>
  38. #include <asm/pgtable.h>
  39. #include <asm/page.h>
  40. #include <asm/uaccess.h>
  41. #include <asm/bootinfo.h>
  42. #include <asm/reg.h>
  43. /*
  44. * Called by kernel/ptrace.c when detaching..
  45. *
  46. * Make sure single step bits etc are not set.
  47. */
  48. void ptrace_disable(struct task_struct *child)
  49. {
  50. /* Don't load the watchpoint registers for the ex-child. */
  51. clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
  52. }
  53. /*
  54. * Read a general register set. We always use the 64-bit format, even
  55. * for 32-bit kernels and for 32-bit processes on a 64-bit kernel.
  56. * Registers are sign extended to fill the available space.
  57. */
  58. int ptrace_getregs(struct task_struct *child, __s64 __user *data)
  59. {
  60. struct pt_regs *regs;
  61. int i;
  62. if (!access_ok(VERIFY_WRITE, data, 38 * 8))
  63. return -EIO;
  64. regs = task_pt_regs(child);
  65. for (i = 0; i < 32; i++)
  66. __put_user((long)regs->regs[i], data + i);
  67. __put_user((long)regs->lo, data + EF_LO - EF_R0);
  68. __put_user((long)regs->hi, data + EF_HI - EF_R0);
  69. __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
  70. __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
  71. __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
  72. __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
  73. return 0;
  74. }
  75. /*
  76. * Write a general register set. As for PTRACE_GETREGS, we always use
  77. * the 64-bit format. On a 32-bit kernel only the lower order half
  78. * (according to endianness) will be used.
  79. */
  80. int ptrace_setregs(struct task_struct *child, __s64 __user *data)
  81. {
  82. struct pt_regs *regs;
  83. int i;
  84. if (!access_ok(VERIFY_READ, data, 38 * 8))
  85. return -EIO;
  86. regs = task_pt_regs(child);
  87. for (i = 0; i < 32; i++)
  88. __get_user(regs->regs[i], data + i);
  89. __get_user(regs->lo, data + EF_LO - EF_R0);
  90. __get_user(regs->hi, data + EF_HI - EF_R0);
  91. __get_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
  92. /* badvaddr, status, and cause may not be written. */
  93. return 0;
  94. }
  95. int ptrace_getfpregs(struct task_struct *child, __u32 __user *data)
  96. {
  97. int i;
  98. unsigned int tmp;
  99. if (!access_ok(VERIFY_WRITE, data, 33 * 8))
  100. return -EIO;
  101. if (tsk_used_math(child)) {
  102. fpureg_t *fregs = get_fpu_regs(child);
  103. for (i = 0; i < 32; i++)
  104. __put_user(fregs[i], i + (__u64 __user *) data);
  105. } else {
  106. for (i = 0; i < 32; i++)
  107. __put_user((__u64) -1, i + (__u64 __user *) data);
  108. }
  109. __put_user(child->thread.fpu.fcr31, data + 64);
  110. preempt_disable();
  111. if (cpu_has_fpu) {
  112. unsigned int flags;
  113. if (cpu_has_mipsmt) {
  114. unsigned int vpflags = dvpe();
  115. flags = read_c0_status();
  116. __enable_fpu();
  117. __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp));
  118. write_c0_status(flags);
  119. evpe(vpflags);
  120. } else {
  121. flags = read_c0_status();
  122. __enable_fpu();
  123. __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp));
  124. write_c0_status(flags);
  125. }
  126. } else {
  127. tmp = 0;
  128. }
  129. preempt_enable();
  130. __put_user(tmp, data + 65);
  131. return 0;
  132. }
  133. int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
  134. {
  135. fpureg_t *fregs;
  136. int i;
  137. if (!access_ok(VERIFY_READ, data, 33 * 8))
  138. return -EIO;
  139. fregs = get_fpu_regs(child);
  140. for (i = 0; i < 32; i++)
  141. __get_user(fregs[i], i + (__u64 __user *) data);
  142. __get_user(child->thread.fpu.fcr31, data + 64);
  143. /* FIR may not be written. */
  144. return 0;
  145. }
  146. int ptrace_get_watch_regs(struct task_struct *child,
  147. struct pt_watch_regs __user *addr)
  148. {
  149. enum pt_watch_style style;
  150. int i;
  151. if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
  152. return -EIO;
  153. if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs)))
  154. return -EIO;
  155. #ifdef CONFIG_32BIT
  156. style = pt_watch_style_mips32;
  157. #define WATCH_STYLE mips32
  158. #else
  159. style = pt_watch_style_mips64;
  160. #define WATCH_STYLE mips64
  161. #endif
  162. __put_user(style, &addr->style);
  163. __put_user(current_cpu_data.watch_reg_use_cnt,
  164. &addr->WATCH_STYLE.num_valid);
  165. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  166. __put_user(child->thread.watch.mips3264.watchlo[i],
  167. &addr->WATCH_STYLE.watchlo[i]);
  168. __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff,
  169. &addr->WATCH_STYLE.watchhi[i]);
  170. __put_user(current_cpu_data.watch_reg_masks[i],
  171. &addr->WATCH_STYLE.watch_masks[i]);
  172. }
  173. for (; i < 8; i++) {
  174. __put_user(0, &addr->WATCH_STYLE.watchlo[i]);
  175. __put_user(0, &addr->WATCH_STYLE.watchhi[i]);
  176. __put_user(0, &addr->WATCH_STYLE.watch_masks[i]);
  177. }
  178. return 0;
  179. }
  180. int ptrace_set_watch_regs(struct task_struct *child,
  181. struct pt_watch_regs __user *addr)
  182. {
  183. int i;
  184. int watch_active = 0;
  185. unsigned long lt[NUM_WATCH_REGS];
  186. u16 ht[NUM_WATCH_REGS];
  187. if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
  188. return -EIO;
  189. if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs)))
  190. return -EIO;
  191. /* Check the values. */
  192. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  193. __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]);
  194. #ifdef CONFIG_32BIT
  195. if (lt[i] & __UA_LIMIT)
  196. return -EINVAL;
  197. #else
  198. if (test_tsk_thread_flag(child, TIF_32BIT_ADDR)) {
  199. if (lt[i] & 0xffffffff80000000UL)
  200. return -EINVAL;
  201. } else {
  202. if (lt[i] & __UA_LIMIT)
  203. return -EINVAL;
  204. }
  205. #endif
  206. __get_user(ht[i], &addr->WATCH_STYLE.watchhi[i]);
  207. if (ht[i] & ~0xff8)
  208. return -EINVAL;
  209. }
  210. /* Install them. */
  211. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  212. if (lt[i] & 7)
  213. watch_active = 1;
  214. child->thread.watch.mips3264.watchlo[i] = lt[i];
  215. /* Set the G bit. */
  216. child->thread.watch.mips3264.watchhi[i] = ht[i];
  217. }
  218. if (watch_active)
  219. set_tsk_thread_flag(child, TIF_LOAD_WATCH);
  220. else
  221. clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
  222. return 0;
  223. }
  224. /* regset get/set implementations */
  225. static int gpr_get(struct task_struct *target,
  226. const struct user_regset *regset,
  227. unsigned int pos, unsigned int count,
  228. void *kbuf, void __user *ubuf)
  229. {
  230. struct pt_regs *regs = task_pt_regs(target);
  231. return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
  232. regs, 0, sizeof(*regs));
  233. }
  234. static int gpr_set(struct task_struct *target,
  235. const struct user_regset *regset,
  236. unsigned int pos, unsigned int count,
  237. const void *kbuf, const void __user *ubuf)
  238. {
  239. struct pt_regs newregs;
  240. int ret;
  241. ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  242. &newregs,
  243. 0, sizeof(newregs));
  244. if (ret)
  245. return ret;
  246. *task_pt_regs(target) = newregs;
  247. return 0;
  248. }
  249. static int fpr_get(struct task_struct *target,
  250. const struct user_regset *regset,
  251. unsigned int pos, unsigned int count,
  252. void *kbuf, void __user *ubuf)
  253. {
  254. return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
  255. &target->thread.fpu,
  256. 0, sizeof(elf_fpregset_t));
  257. /* XXX fcr31 */
  258. }
  259. static int fpr_set(struct task_struct *target,
  260. const struct user_regset *regset,
  261. unsigned int pos, unsigned int count,
  262. const void *kbuf, const void __user *ubuf)
  263. {
  264. return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  265. &target->thread.fpu,
  266. 0, sizeof(elf_fpregset_t));
  267. /* XXX fcr31 */
  268. }
  269. enum mips_regset {
  270. REGSET_GPR,
  271. REGSET_FPR,
  272. };
  273. static const struct user_regset mips_regsets[] = {
  274. [REGSET_GPR] = {
  275. .core_note_type = NT_PRSTATUS,
  276. .n = ELF_NGREG,
  277. .size = sizeof(unsigned int),
  278. .align = sizeof(unsigned int),
  279. .get = gpr_get,
  280. .set = gpr_set,
  281. },
  282. [REGSET_FPR] = {
  283. .core_note_type = NT_PRFPREG,
  284. .n = ELF_NFPREG,
  285. .size = sizeof(elf_fpreg_t),
  286. .align = sizeof(elf_fpreg_t),
  287. .get = fpr_get,
  288. .set = fpr_set,
  289. },
  290. };
  291. static const struct user_regset_view user_mips_view = {
  292. .name = "mips",
  293. .e_machine = ELF_ARCH,
  294. .ei_osabi = ELF_OSABI,
  295. .regsets = mips_regsets,
  296. .n = ARRAY_SIZE(mips_regsets),
  297. };
  298. static const struct user_regset mips64_regsets[] = {
  299. [REGSET_GPR] = {
  300. .core_note_type = NT_PRSTATUS,
  301. .n = ELF_NGREG,
  302. .size = sizeof(unsigned long),
  303. .align = sizeof(unsigned long),
  304. .get = gpr_get,
  305. .set = gpr_set,
  306. },
  307. [REGSET_FPR] = {
  308. .core_note_type = NT_PRFPREG,
  309. .n = ELF_NFPREG,
  310. .size = sizeof(elf_fpreg_t),
  311. .align = sizeof(elf_fpreg_t),
  312. .get = fpr_get,
  313. .set = fpr_set,
  314. },
  315. };
  316. static const struct user_regset_view user_mips64_view = {
  317. .name = "mips",
  318. .e_machine = ELF_ARCH,
  319. .ei_osabi = ELF_OSABI,
  320. .regsets = mips64_regsets,
  321. .n = ARRAY_SIZE(mips_regsets),
  322. };
  323. const struct user_regset_view *task_user_regset_view(struct task_struct *task)
  324. {
  325. #ifdef CONFIG_32BIT
  326. return &user_mips_view;
  327. #endif
  328. #ifdef CONFIG_MIPS32_O32
  329. if (test_thread_flag(TIF_32BIT_REGS))
  330. return &user_mips_view;
  331. #endif
  332. return &user_mips64_view;
  333. }
  334. long arch_ptrace(struct task_struct *child, long request,
  335. unsigned long addr, unsigned long data)
  336. {
  337. int ret;
  338. void __user *addrp = (void __user *) addr;
  339. void __user *datavp = (void __user *) data;
  340. unsigned long __user *datalp = (void __user *) data;
  341. switch (request) {
  342. /* when I and D space are separate, these will need to be fixed. */
  343. case PTRACE_PEEKTEXT: /* read word at location addr. */
  344. case PTRACE_PEEKDATA:
  345. ret = generic_ptrace_peekdata(child, addr, data);
  346. break;
  347. /* Read the word at location addr in the USER area. */
  348. case PTRACE_PEEKUSR: {
  349. struct pt_regs *regs;
  350. unsigned long tmp = 0;
  351. regs = task_pt_regs(child);
  352. ret = 0; /* Default return value. */
  353. switch (addr) {
  354. case 0 ... 31:
  355. tmp = regs->regs[addr];
  356. break;
  357. case FPR_BASE ... FPR_BASE + 31:
  358. if (tsk_used_math(child)) {
  359. fpureg_t *fregs = get_fpu_regs(child);
  360. #ifdef CONFIG_32BIT
  361. /*
  362. * The odd registers are actually the high
  363. * order bits of the values stored in the even
  364. * registers - unless we're using r2k_switch.S.
  365. */
  366. if (addr & 1)
  367. tmp = (unsigned long) (fregs[((addr & ~1) - 32)] >> 32);
  368. else
  369. tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
  370. #endif
  371. #ifdef CONFIG_64BIT
  372. tmp = fregs[addr - FPR_BASE];
  373. #endif
  374. } else {
  375. tmp = -1; /* FP not yet used */
  376. }
  377. break;
  378. case PC:
  379. tmp = regs->cp0_epc;
  380. break;
  381. case CAUSE:
  382. tmp = regs->cp0_cause;
  383. break;
  384. case BADVADDR:
  385. tmp = regs->cp0_badvaddr;
  386. break;
  387. case MMHI:
  388. tmp = regs->hi;
  389. break;
  390. case MMLO:
  391. tmp = regs->lo;
  392. break;
  393. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  394. case ACX:
  395. tmp = regs->acx;
  396. break;
  397. #endif
  398. case FPC_CSR:
  399. tmp = child->thread.fpu.fcr31;
  400. break;
  401. case FPC_EIR: { /* implementation / version register */
  402. unsigned int flags;
  403. #ifdef CONFIG_MIPS_MT_SMTC
  404. unsigned long irqflags;
  405. unsigned int mtflags;
  406. #endif /* CONFIG_MIPS_MT_SMTC */
  407. preempt_disable();
  408. if (!cpu_has_fpu) {
  409. preempt_enable();
  410. break;
  411. }
  412. #ifdef CONFIG_MIPS_MT_SMTC
  413. /* Read-modify-write of Status must be atomic */
  414. local_irq_save(irqflags);
  415. mtflags = dmt();
  416. #endif /* CONFIG_MIPS_MT_SMTC */
  417. if (cpu_has_mipsmt) {
  418. unsigned int vpflags = dvpe();
  419. flags = read_c0_status();
  420. __enable_fpu();
  421. __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
  422. write_c0_status(flags);
  423. evpe(vpflags);
  424. } else {
  425. flags = read_c0_status();
  426. __enable_fpu();
  427. __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
  428. write_c0_status(flags);
  429. }
  430. #ifdef CONFIG_MIPS_MT_SMTC
  431. emt(mtflags);
  432. local_irq_restore(irqflags);
  433. #endif /* CONFIG_MIPS_MT_SMTC */
  434. preempt_enable();
  435. break;
  436. }
  437. case DSP_BASE ... DSP_BASE + 5: {
  438. dspreg_t *dregs;
  439. if (!cpu_has_dsp) {
  440. tmp = 0;
  441. ret = -EIO;
  442. goto out;
  443. }
  444. dregs = __get_dsp_regs(child);
  445. tmp = (unsigned long) (dregs[addr - DSP_BASE]);
  446. break;
  447. }
  448. case DSP_CONTROL:
  449. if (!cpu_has_dsp) {
  450. tmp = 0;
  451. ret = -EIO;
  452. goto out;
  453. }
  454. tmp = child->thread.dsp.dspcontrol;
  455. break;
  456. default:
  457. tmp = 0;
  458. ret = -EIO;
  459. goto out;
  460. }
  461. ret = put_user(tmp, datalp);
  462. break;
  463. }
  464. /* when I and D space are separate, this will have to be fixed. */
  465. case PTRACE_POKETEXT: /* write the word at location addr. */
  466. case PTRACE_POKEDATA:
  467. ret = generic_ptrace_pokedata(child, addr, data);
  468. break;
  469. case PTRACE_POKEUSR: {
  470. struct pt_regs *regs;
  471. ret = 0;
  472. regs = task_pt_regs(child);
  473. switch (addr) {
  474. case 0 ... 31:
  475. regs->regs[addr] = data;
  476. break;
  477. case FPR_BASE ... FPR_BASE + 31: {
  478. fpureg_t *fregs = get_fpu_regs(child);
  479. if (!tsk_used_math(child)) {
  480. /* FP not yet used */
  481. memset(&child->thread.fpu, ~0,
  482. sizeof(child->thread.fpu));
  483. child->thread.fpu.fcr31 = 0;
  484. }
  485. #ifdef CONFIG_32BIT
  486. /*
  487. * The odd registers are actually the high order bits
  488. * of the values stored in the even registers - unless
  489. * we're using r2k_switch.S.
  490. */
  491. if (addr & 1) {
  492. fregs[(addr & ~1) - FPR_BASE] &= 0xffffffff;
  493. fregs[(addr & ~1) - FPR_BASE] |= ((unsigned long long) data) << 32;
  494. } else {
  495. fregs[addr - FPR_BASE] &= ~0xffffffffLL;
  496. fregs[addr - FPR_BASE] |= data;
  497. }
  498. #endif
  499. #ifdef CONFIG_64BIT
  500. fregs[addr - FPR_BASE] = data;
  501. #endif
  502. break;
  503. }
  504. case PC:
  505. regs->cp0_epc = data;
  506. break;
  507. case MMHI:
  508. regs->hi = data;
  509. break;
  510. case MMLO:
  511. regs->lo = data;
  512. break;
  513. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  514. case ACX:
  515. regs->acx = data;
  516. break;
  517. #endif
  518. case FPC_CSR:
  519. child->thread.fpu.fcr31 = data;
  520. break;
  521. case DSP_BASE ... DSP_BASE + 5: {
  522. dspreg_t *dregs;
  523. if (!cpu_has_dsp) {
  524. ret = -EIO;
  525. break;
  526. }
  527. dregs = __get_dsp_regs(child);
  528. dregs[addr - DSP_BASE] = data;
  529. break;
  530. }
  531. case DSP_CONTROL:
  532. if (!cpu_has_dsp) {
  533. ret = -EIO;
  534. break;
  535. }
  536. child->thread.dsp.dspcontrol = data;
  537. break;
  538. default:
  539. /* The rest are not allowed. */
  540. ret = -EIO;
  541. break;
  542. }
  543. break;
  544. }
  545. case PTRACE_GETREGS:
  546. ret = ptrace_getregs(child, datavp);
  547. break;
  548. case PTRACE_SETREGS:
  549. ret = ptrace_setregs(child, datavp);
  550. break;
  551. case PTRACE_GETFPREGS:
  552. ret = ptrace_getfpregs(child, datavp);
  553. break;
  554. case PTRACE_SETFPREGS:
  555. ret = ptrace_setfpregs(child, datavp);
  556. break;
  557. case PTRACE_GET_THREAD_AREA:
  558. ret = put_user(task_thread_info(child)->tp_value, datalp);
  559. break;
  560. case PTRACE_GET_WATCH_REGS:
  561. ret = ptrace_get_watch_regs(child, addrp);
  562. break;
  563. case PTRACE_SET_WATCH_REGS:
  564. ret = ptrace_set_watch_regs(child, addrp);
  565. break;
  566. default:
  567. ret = ptrace_request(child, request, addr, data);
  568. break;
  569. }
  570. out:
  571. return ret;
  572. }
  573. static inline int audit_arch(void)
  574. {
  575. int arch = EM_MIPS;
  576. #ifdef CONFIG_64BIT
  577. arch |= __AUDIT_ARCH_64BIT;
  578. #endif
  579. #if defined(__LITTLE_ENDIAN)
  580. arch |= __AUDIT_ARCH_LE;
  581. #endif
  582. return arch;
  583. }
  584. /*
  585. * Notification of system call entry/exit
  586. * - triggered by current->work.syscall_trace
  587. */
  588. asmlinkage void syscall_trace_enter(struct pt_regs *regs)
  589. {
  590. user_exit();
  591. /* do the secure computing check first */
  592. secure_computing_strict(regs->regs[2]);
  593. if (test_thread_flag(TIF_SYSCALL_TRACE))
  594. ptrace_report_syscall(regs);
  595. audit_syscall_entry(audit_arch(), regs->regs[2],
  596. regs->regs[4], regs->regs[5],
  597. regs->regs[6], regs->regs[7]);
  598. }
  599. /*
  600. * Notification of system call entry/exit
  601. * - triggered by current->work.syscall_trace
  602. */
  603. asmlinkage void syscall_trace_leave(struct pt_regs *regs)
  604. {
  605. /*
  606. * We may come here right after calling schedule_user()
  607. * or do_notify_resume(), in which case we can be in RCU
  608. * user mode.
  609. */
  610. user_exit();
  611. audit_syscall_exit(regs);
  612. if (test_thread_flag(TIF_SYSCALL_TRACE))
  613. tracehook_report_syscall_exit(regs, 0);
  614. user_enter();
  615. }