ptrace.c 16 KB

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