ptrace.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. /*
  2. * linux/kernel/ptrace.c
  3. *
  4. * (C) Copyright 1999 Linus Torvalds
  5. *
  6. * Common interfaces for "ptrace()" which we do not want
  7. * to continually duplicate across every architecture.
  8. */
  9. #include <linux/capability.h>
  10. #include <linux/module.h>
  11. #include <linux/sched.h>
  12. #include <linux/errno.h>
  13. #include <linux/mm.h>
  14. #include <linux/highmem.h>
  15. #include <linux/pagemap.h>
  16. #include <linux/smp_lock.h>
  17. #include <linux/ptrace.h>
  18. #include <linux/security.h>
  19. #include <linux/signal.h>
  20. #include <linux/audit.h>
  21. #include <linux/pid_namespace.h>
  22. #include <linux/syscalls.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/uaccess.h>
  25. /*
  26. * ptrace a task: make the debugger its new parent and
  27. * move it to the ptrace list.
  28. *
  29. * Must be called with the tasklist lock write-held.
  30. */
  31. void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)
  32. {
  33. BUG_ON(!list_empty(&child->ptrace_entry));
  34. list_add(&child->ptrace_entry, &new_parent->ptraced);
  35. child->parent = new_parent;
  36. }
  37. /*
  38. * Turn a tracing stop into a normal stop now, since with no tracer there
  39. * would be no way to wake it up with SIGCONT or SIGKILL. If there was a
  40. * signal sent that would resume the child, but didn't because it was in
  41. * TASK_TRACED, resume it now.
  42. * Requires that irqs be disabled.
  43. */
  44. static void ptrace_untrace(struct task_struct *child)
  45. {
  46. spin_lock(&child->sighand->siglock);
  47. if (task_is_traced(child)) {
  48. if (child->signal->flags & SIGNAL_STOP_STOPPED) {
  49. __set_task_state(child, TASK_STOPPED);
  50. } else {
  51. signal_wake_up(child, 1);
  52. }
  53. }
  54. spin_unlock(&child->sighand->siglock);
  55. }
  56. /*
  57. * unptrace a task: move it back to its original parent and
  58. * remove it from the ptrace list.
  59. *
  60. * Must be called with the tasklist lock write-held.
  61. */
  62. void __ptrace_unlink(struct task_struct *child)
  63. {
  64. BUG_ON(!child->ptrace);
  65. child->ptrace = 0;
  66. child->parent = child->real_parent;
  67. list_del_init(&child->ptrace_entry);
  68. if (task_is_traced(child))
  69. ptrace_untrace(child);
  70. }
  71. /*
  72. * Check that we have indeed attached to the thing..
  73. */
  74. int ptrace_check_attach(struct task_struct *child, int kill)
  75. {
  76. int ret = -ESRCH;
  77. /*
  78. * We take the read lock around doing both checks to close a
  79. * possible race where someone else was tracing our child and
  80. * detached between these two checks. After this locked check,
  81. * we are sure that this is our traced child and that can only
  82. * be changed by us so it's not changing right after this.
  83. */
  84. read_lock(&tasklist_lock);
  85. if ((child->ptrace & PT_PTRACED) && child->parent == current) {
  86. ret = 0;
  87. /*
  88. * child->sighand can't be NULL, release_task()
  89. * does ptrace_unlink() before __exit_signal().
  90. */
  91. spin_lock_irq(&child->sighand->siglock);
  92. if (task_is_stopped(child))
  93. child->state = TASK_TRACED;
  94. else if (!task_is_traced(child) && !kill)
  95. ret = -ESRCH;
  96. spin_unlock_irq(&child->sighand->siglock);
  97. }
  98. read_unlock(&tasklist_lock);
  99. if (!ret && !kill)
  100. ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;
  101. /* All systems go.. */
  102. return ret;
  103. }
  104. int __ptrace_may_access(struct task_struct *task, unsigned int mode)
  105. {
  106. /* May we inspect the given task?
  107. * This check is used both for attaching with ptrace
  108. * and for allowing access to sensitive information in /proc.
  109. *
  110. * ptrace_attach denies several cases that /proc allows
  111. * because setting up the necessary parent/child relationship
  112. * or halting the specified task is impossible.
  113. */
  114. uid_t uid;
  115. gid_t gid;
  116. int dumpable = 0;
  117. /* Don't let security modules deny introspection */
  118. if (task == current)
  119. return 0;
  120. current_uid_gid(&uid, &gid);
  121. if ((uid != task->euid ||
  122. uid != task->suid ||
  123. uid != task->uid ||
  124. gid != task->egid ||
  125. gid != task->sgid ||
  126. gid != task->gid) && !capable(CAP_SYS_PTRACE))
  127. return -EPERM;
  128. smp_rmb();
  129. if (task->mm)
  130. dumpable = get_dumpable(task->mm);
  131. if (!dumpable && !capable(CAP_SYS_PTRACE))
  132. return -EPERM;
  133. return security_ptrace_may_access(task, mode);
  134. }
  135. bool ptrace_may_access(struct task_struct *task, unsigned int mode)
  136. {
  137. int err;
  138. task_lock(task);
  139. err = __ptrace_may_access(task, mode);
  140. task_unlock(task);
  141. return (!err ? true : false);
  142. }
  143. int ptrace_attach(struct task_struct *task)
  144. {
  145. int retval;
  146. unsigned long flags;
  147. audit_ptrace(task);
  148. retval = -EPERM;
  149. if (same_thread_group(task, current))
  150. goto out;
  151. repeat:
  152. /*
  153. * Nasty, nasty.
  154. *
  155. * We want to hold both the task-lock and the
  156. * tasklist_lock for writing at the same time.
  157. * But that's against the rules (tasklist_lock
  158. * is taken for reading by interrupts on other
  159. * cpu's that may have task_lock).
  160. */
  161. task_lock(task);
  162. if (!write_trylock_irqsave(&tasklist_lock, flags)) {
  163. task_unlock(task);
  164. do {
  165. cpu_relax();
  166. } while (!write_can_lock(&tasklist_lock));
  167. goto repeat;
  168. }
  169. if (!task->mm)
  170. goto bad;
  171. /* the same process cannot be attached many times */
  172. if (task->ptrace & PT_PTRACED)
  173. goto bad;
  174. retval = __ptrace_may_access(task, PTRACE_MODE_ATTACH);
  175. if (retval)
  176. goto bad;
  177. /* Go */
  178. task->ptrace |= PT_PTRACED;
  179. if (capable(CAP_SYS_PTRACE))
  180. task->ptrace |= PT_PTRACE_CAP;
  181. __ptrace_link(task, current);
  182. send_sig_info(SIGSTOP, SEND_SIG_FORCED, task);
  183. bad:
  184. write_unlock_irqrestore(&tasklist_lock, flags);
  185. task_unlock(task);
  186. out:
  187. return retval;
  188. }
  189. static inline void __ptrace_detach(struct task_struct *child, unsigned int data)
  190. {
  191. child->exit_code = data;
  192. /* .. re-parent .. */
  193. __ptrace_unlink(child);
  194. /* .. and wake it up. */
  195. if (child->exit_state != EXIT_ZOMBIE)
  196. wake_up_process(child);
  197. }
  198. int ptrace_detach(struct task_struct *child, unsigned int data)
  199. {
  200. if (!valid_signal(data))
  201. return -EIO;
  202. /* Architecture-specific hardware disable .. */
  203. ptrace_disable(child);
  204. clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  205. write_lock_irq(&tasklist_lock);
  206. /* protect against de_thread()->release_task() */
  207. if (child->ptrace)
  208. __ptrace_detach(child, data);
  209. write_unlock_irq(&tasklist_lock);
  210. return 0;
  211. }
  212. int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len)
  213. {
  214. int copied = 0;
  215. while (len > 0) {
  216. char buf[128];
  217. int this_len, retval;
  218. this_len = (len > sizeof(buf)) ? sizeof(buf) : len;
  219. retval = access_process_vm(tsk, src, buf, this_len, 0);
  220. if (!retval) {
  221. if (copied)
  222. break;
  223. return -EIO;
  224. }
  225. if (copy_to_user(dst, buf, retval))
  226. return -EFAULT;
  227. copied += retval;
  228. src += retval;
  229. dst += retval;
  230. len -= retval;
  231. }
  232. return copied;
  233. }
  234. int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len)
  235. {
  236. int copied = 0;
  237. while (len > 0) {
  238. char buf[128];
  239. int this_len, retval;
  240. this_len = (len > sizeof(buf)) ? sizeof(buf) : len;
  241. if (copy_from_user(buf, src, this_len))
  242. return -EFAULT;
  243. retval = access_process_vm(tsk, dst, buf, this_len, 1);
  244. if (!retval) {
  245. if (copied)
  246. break;
  247. return -EIO;
  248. }
  249. copied += retval;
  250. src += retval;
  251. dst += retval;
  252. len -= retval;
  253. }
  254. return copied;
  255. }
  256. static int ptrace_setoptions(struct task_struct *child, long data)
  257. {
  258. child->ptrace &= ~PT_TRACE_MASK;
  259. if (data & PTRACE_O_TRACESYSGOOD)
  260. child->ptrace |= PT_TRACESYSGOOD;
  261. if (data & PTRACE_O_TRACEFORK)
  262. child->ptrace |= PT_TRACE_FORK;
  263. if (data & PTRACE_O_TRACEVFORK)
  264. child->ptrace |= PT_TRACE_VFORK;
  265. if (data & PTRACE_O_TRACECLONE)
  266. child->ptrace |= PT_TRACE_CLONE;
  267. if (data & PTRACE_O_TRACEEXEC)
  268. child->ptrace |= PT_TRACE_EXEC;
  269. if (data & PTRACE_O_TRACEVFORKDONE)
  270. child->ptrace |= PT_TRACE_VFORK_DONE;
  271. if (data & PTRACE_O_TRACEEXIT)
  272. child->ptrace |= PT_TRACE_EXIT;
  273. return (data & ~PTRACE_O_MASK) ? -EINVAL : 0;
  274. }
  275. static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
  276. {
  277. int error = -ESRCH;
  278. read_lock(&tasklist_lock);
  279. if (likely(child->sighand != NULL)) {
  280. error = -EINVAL;
  281. spin_lock_irq(&child->sighand->siglock);
  282. if (likely(child->last_siginfo != NULL)) {
  283. *info = *child->last_siginfo;
  284. error = 0;
  285. }
  286. spin_unlock_irq(&child->sighand->siglock);
  287. }
  288. read_unlock(&tasklist_lock);
  289. return error;
  290. }
  291. static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)
  292. {
  293. int error = -ESRCH;
  294. read_lock(&tasklist_lock);
  295. if (likely(child->sighand != NULL)) {
  296. error = -EINVAL;
  297. spin_lock_irq(&child->sighand->siglock);
  298. if (likely(child->last_siginfo != NULL)) {
  299. *child->last_siginfo = *info;
  300. error = 0;
  301. }
  302. spin_unlock_irq(&child->sighand->siglock);
  303. }
  304. read_unlock(&tasklist_lock);
  305. return error;
  306. }
  307. #ifdef PTRACE_SINGLESTEP
  308. #define is_singlestep(request) ((request) == PTRACE_SINGLESTEP)
  309. #else
  310. #define is_singlestep(request) 0
  311. #endif
  312. #ifdef PTRACE_SINGLEBLOCK
  313. #define is_singleblock(request) ((request) == PTRACE_SINGLEBLOCK)
  314. #else
  315. #define is_singleblock(request) 0
  316. #endif
  317. #ifdef PTRACE_SYSEMU
  318. #define is_sysemu_singlestep(request) ((request) == PTRACE_SYSEMU_SINGLESTEP)
  319. #else
  320. #define is_sysemu_singlestep(request) 0
  321. #endif
  322. static int ptrace_resume(struct task_struct *child, long request, long data)
  323. {
  324. if (!valid_signal(data))
  325. return -EIO;
  326. if (request == PTRACE_SYSCALL)
  327. set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  328. else
  329. clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  330. #ifdef TIF_SYSCALL_EMU
  331. if (request == PTRACE_SYSEMU || request == PTRACE_SYSEMU_SINGLESTEP)
  332. set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
  333. else
  334. clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
  335. #endif
  336. if (is_singleblock(request)) {
  337. if (unlikely(!arch_has_block_step()))
  338. return -EIO;
  339. user_enable_block_step(child);
  340. } else if (is_singlestep(request) || is_sysemu_singlestep(request)) {
  341. if (unlikely(!arch_has_single_step()))
  342. return -EIO;
  343. user_enable_single_step(child);
  344. }
  345. else
  346. user_disable_single_step(child);
  347. child->exit_code = data;
  348. wake_up_process(child);
  349. return 0;
  350. }
  351. int ptrace_request(struct task_struct *child, long request,
  352. long addr, long data)
  353. {
  354. int ret = -EIO;
  355. siginfo_t siginfo;
  356. switch (request) {
  357. case PTRACE_PEEKTEXT:
  358. case PTRACE_PEEKDATA:
  359. return generic_ptrace_peekdata(child, addr, data);
  360. case PTRACE_POKETEXT:
  361. case PTRACE_POKEDATA:
  362. return generic_ptrace_pokedata(child, addr, data);
  363. #ifdef PTRACE_OLDSETOPTIONS
  364. case PTRACE_OLDSETOPTIONS:
  365. #endif
  366. case PTRACE_SETOPTIONS:
  367. ret = ptrace_setoptions(child, data);
  368. break;
  369. case PTRACE_GETEVENTMSG:
  370. ret = put_user(child->ptrace_message, (unsigned long __user *) data);
  371. break;
  372. case PTRACE_GETSIGINFO:
  373. ret = ptrace_getsiginfo(child, &siginfo);
  374. if (!ret)
  375. ret = copy_siginfo_to_user((siginfo_t __user *) data,
  376. &siginfo);
  377. break;
  378. case PTRACE_SETSIGINFO:
  379. if (copy_from_user(&siginfo, (siginfo_t __user *) data,
  380. sizeof siginfo))
  381. ret = -EFAULT;
  382. else
  383. ret = ptrace_setsiginfo(child, &siginfo);
  384. break;
  385. case PTRACE_DETACH: /* detach a process that was attached. */
  386. ret = ptrace_detach(child, data);
  387. break;
  388. #ifdef PTRACE_SINGLESTEP
  389. case PTRACE_SINGLESTEP:
  390. #endif
  391. #ifdef PTRACE_SINGLEBLOCK
  392. case PTRACE_SINGLEBLOCK:
  393. #endif
  394. #ifdef PTRACE_SYSEMU
  395. case PTRACE_SYSEMU:
  396. case PTRACE_SYSEMU_SINGLESTEP:
  397. #endif
  398. case PTRACE_SYSCALL:
  399. case PTRACE_CONT:
  400. return ptrace_resume(child, request, data);
  401. case PTRACE_KILL:
  402. if (child->exit_state) /* already dead */
  403. return 0;
  404. return ptrace_resume(child, request, SIGKILL);
  405. default:
  406. break;
  407. }
  408. return ret;
  409. }
  410. /**
  411. * ptrace_traceme -- helper for PTRACE_TRACEME
  412. *
  413. * Performs checks and sets PT_PTRACED.
  414. * Should be used by all ptrace implementations for PTRACE_TRACEME.
  415. */
  416. int ptrace_traceme(void)
  417. {
  418. int ret = -EPERM;
  419. /*
  420. * Are we already being traced?
  421. */
  422. repeat:
  423. task_lock(current);
  424. if (!(current->ptrace & PT_PTRACED)) {
  425. /*
  426. * See ptrace_attach() comments about the locking here.
  427. */
  428. unsigned long flags;
  429. if (!write_trylock_irqsave(&tasklist_lock, flags)) {
  430. task_unlock(current);
  431. do {
  432. cpu_relax();
  433. } while (!write_can_lock(&tasklist_lock));
  434. goto repeat;
  435. }
  436. ret = security_ptrace_traceme(current->parent);
  437. /*
  438. * Set the ptrace bit in the process ptrace flags.
  439. * Then link us on our parent's ptraced list.
  440. */
  441. if (!ret) {
  442. current->ptrace |= PT_PTRACED;
  443. __ptrace_link(current, current->real_parent);
  444. }
  445. write_unlock_irqrestore(&tasklist_lock, flags);
  446. }
  447. task_unlock(current);
  448. return ret;
  449. }
  450. /**
  451. * ptrace_get_task_struct -- grab a task struct reference for ptrace
  452. * @pid: process id to grab a task_struct reference of
  453. *
  454. * This function is a helper for ptrace implementations. It checks
  455. * permissions and then grabs a task struct for use of the actual
  456. * ptrace implementation.
  457. *
  458. * Returns the task_struct for @pid or an ERR_PTR() on failure.
  459. */
  460. struct task_struct *ptrace_get_task_struct(pid_t pid)
  461. {
  462. struct task_struct *child;
  463. read_lock(&tasklist_lock);
  464. child = find_task_by_vpid(pid);
  465. if (child)
  466. get_task_struct(child);
  467. read_unlock(&tasklist_lock);
  468. if (!child)
  469. return ERR_PTR(-ESRCH);
  470. return child;
  471. }
  472. #ifndef arch_ptrace_attach
  473. #define arch_ptrace_attach(child) do { } while (0)
  474. #endif
  475. asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
  476. {
  477. struct task_struct *child;
  478. long ret;
  479. /*
  480. * This lock_kernel fixes a subtle race with suid exec
  481. */
  482. lock_kernel();
  483. if (request == PTRACE_TRACEME) {
  484. ret = ptrace_traceme();
  485. if (!ret)
  486. arch_ptrace_attach(current);
  487. goto out;
  488. }
  489. child = ptrace_get_task_struct(pid);
  490. if (IS_ERR(child)) {
  491. ret = PTR_ERR(child);
  492. goto out;
  493. }
  494. if (request == PTRACE_ATTACH) {
  495. ret = ptrace_attach(child);
  496. /*
  497. * Some architectures need to do book-keeping after
  498. * a ptrace attach.
  499. */
  500. if (!ret)
  501. arch_ptrace_attach(child);
  502. goto out_put_task_struct;
  503. }
  504. ret = ptrace_check_attach(child, request == PTRACE_KILL);
  505. if (ret < 0)
  506. goto out_put_task_struct;
  507. ret = arch_ptrace(child, request, addr, data);
  508. if (ret < 0)
  509. goto out_put_task_struct;
  510. out_put_task_struct:
  511. put_task_struct(child);
  512. out:
  513. unlock_kernel();
  514. return ret;
  515. }
  516. int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data)
  517. {
  518. unsigned long tmp;
  519. int copied;
  520. copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
  521. if (copied != sizeof(tmp))
  522. return -EIO;
  523. return put_user(tmp, (unsigned long __user *)data);
  524. }
  525. int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data)
  526. {
  527. int copied;
  528. copied = access_process_vm(tsk, addr, &data, sizeof(data), 1);
  529. return (copied == sizeof(data)) ? 0 : -EIO;
  530. }
  531. #if defined CONFIG_COMPAT && defined __ARCH_WANT_COMPAT_SYS_PTRACE
  532. #include <linux/compat.h>
  533. int compat_ptrace_request(struct task_struct *child, compat_long_t request,
  534. compat_ulong_t addr, compat_ulong_t data)
  535. {
  536. compat_ulong_t __user *datap = compat_ptr(data);
  537. compat_ulong_t word;
  538. siginfo_t siginfo;
  539. int ret;
  540. switch (request) {
  541. case PTRACE_PEEKTEXT:
  542. case PTRACE_PEEKDATA:
  543. ret = access_process_vm(child, addr, &word, sizeof(word), 0);
  544. if (ret != sizeof(word))
  545. ret = -EIO;
  546. else
  547. ret = put_user(word, datap);
  548. break;
  549. case PTRACE_POKETEXT:
  550. case PTRACE_POKEDATA:
  551. ret = access_process_vm(child, addr, &data, sizeof(data), 1);
  552. ret = (ret != sizeof(data) ? -EIO : 0);
  553. break;
  554. case PTRACE_GETEVENTMSG:
  555. ret = put_user((compat_ulong_t) child->ptrace_message, datap);
  556. break;
  557. case PTRACE_GETSIGINFO:
  558. ret = ptrace_getsiginfo(child, &siginfo);
  559. if (!ret)
  560. ret = copy_siginfo_to_user32(
  561. (struct compat_siginfo __user *) datap,
  562. &siginfo);
  563. break;
  564. case PTRACE_SETSIGINFO:
  565. memset(&siginfo, 0, sizeof siginfo);
  566. if (copy_siginfo_from_user32(
  567. &siginfo, (struct compat_siginfo __user *) datap))
  568. ret = -EFAULT;
  569. else
  570. ret = ptrace_setsiginfo(child, &siginfo);
  571. break;
  572. default:
  573. ret = ptrace_request(child, request, addr, data);
  574. }
  575. return ret;
  576. }
  577. asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
  578. compat_long_t addr, compat_long_t data)
  579. {
  580. struct task_struct *child;
  581. long ret;
  582. /*
  583. * This lock_kernel fixes a subtle race with suid exec
  584. */
  585. lock_kernel();
  586. if (request == PTRACE_TRACEME) {
  587. ret = ptrace_traceme();
  588. goto out;
  589. }
  590. child = ptrace_get_task_struct(pid);
  591. if (IS_ERR(child)) {
  592. ret = PTR_ERR(child);
  593. goto out;
  594. }
  595. if (request == PTRACE_ATTACH) {
  596. ret = ptrace_attach(child);
  597. /*
  598. * Some architectures need to do book-keeping after
  599. * a ptrace attach.
  600. */
  601. if (!ret)
  602. arch_ptrace_attach(child);
  603. goto out_put_task_struct;
  604. }
  605. ret = ptrace_check_attach(child, request == PTRACE_KILL);
  606. if (!ret)
  607. ret = compat_arch_ptrace(child, request, addr, data);
  608. out_put_task_struct:
  609. put_task_struct(child);
  610. out:
  611. unlock_kernel();
  612. return ret;
  613. }
  614. #endif /* CONFIG_COMPAT && __ARCH_WANT_COMPAT_SYS_PTRACE */