Fix leakage of placeholder descriptors to tracees

As a side effect of commit v4.11-211-g0736d4e, strace used to leak
placeholders for standard descriptors to tracees thus affecting their
behaviour.  Fix this by setting close-on-exec flag on placeholder
descriptors.

* strace.c (open_dummy_desc): Set close-on-exec flag on the descriptor
that is going to be returned to the caller.
(fd_is_placeholder): New array.
(ensure_standard_fds_opened, redirect_standard_fds): New functions.
(startup_child): Use redirect_standard_fds.
(init): Use ensure_standard_fds_opened.
1 file changed
tree: 00865d604a47fd85c61f93c5457e9dd1207da98a
  1. debian/
  2. linux/
  3. m4/
  4. maint/
  5. qemu_multiarch_testing/
  6. test/
  7. tests/
  8. xlat/
  9. .gitignore
  10. .mailmap
  11. .travis.yml
  12. access.c
  13. affinity.c
  14. aio.c
  15. alpha.c
  16. AUTHORS
  17. bjm.c
  18. block.c
  19. bootstrap
  20. bpf.c
  21. btrfs.c
  22. build_static_example.sh
  23. cacheflush.c
  24. capability.c
  25. caps0.h
  26. caps1.h
  27. ChangeLog-CVS
  28. chdir.c
  29. chmod.c
  30. clone.c
  31. configure.ac
  32. copy_file_range.c
  33. COPYING
  34. count.c
  35. CREDITS.in
  36. defs.h
  37. desc.c
  38. dirent.c
  39. dirent64.c
  40. empty.h
  41. epoll.c
  42. errnoent.sh
  43. evdev.c
  44. eventfd.c
  45. execve.c
  46. exit.c
  47. fadvise.c
  48. fallocate.c
  49. fanotify.c
  50. fchownat.c
  51. fcntl.c
  52. fetch_seccomp_fprog.c
  53. fetch_struct_flock.c
  54. fetch_struct_mmsghdr.c
  55. fetch_struct_msghdr.c
  56. fetch_struct_statfs.c
  57. file.c
  58. file_handle.c
  59. file_ioctl.c
  60. flock.c
  61. flock.h
  62. fs_x_ioctl.c
  63. fstatfs.c
  64. fstatfs64.c
  65. futex.c
  66. gcc_compat.h
  67. generate_mpers_am.sh
  68. generate_sen.sh
  69. get_robust_list.c
  70. getcpu.c
  71. getcwd.c
  72. getrandom.c
  73. git-set-file-times
  74. git-version-gen
  75. gitlog-to-changelog
  76. HACKING-scripts
  77. hdio.c
  78. hostname.c
  79. inotify.c
  80. INSTALL
  81. io.c
  82. ioctl.c
  83. ioctlsort.c
  84. ioperm.c
  85. iopl.c
  86. ioprio.c
  87. ipc.c
  88. ipc_defs.h
  89. ipc_msg.c
  90. ipc_msgctl.c
  91. ipc_sem.c
  92. ipc_shm.c
  93. ipc_shmctl.c
  94. kcmp.c
  95. kernel_types.h
  96. kexec.c
  97. keyctl.c
  98. ldt.c
  99. link.c
  100. lookup_dcookie.c
  101. loop.c
  102. lseek.c
  103. make-dist
  104. make-dsc
  105. Makefile.am
  106. mem.c
  107. membarrier.c
  108. memfd_create.c
  109. mknod.c
  110. mmsghdr.c
  111. mount.c
  112. mpers.awk
  113. mpers.sh
  114. mpers_test.sh
  115. mpers_type.h
  116. mq.c
  117. msghdr.c
  118. msghdr.h
  119. mtd.c
  120. native_defs.h
  121. net.c
  122. netlink.c
  123. NEWS
  124. numa.c
  125. open.c
  126. or1k_atomic.c
  127. pathtrace.c
  128. perf.c
  129. personality.c
  130. poll.c
  131. prctl.c
  132. print_mq_attr.c
  133. print_msgbuf.c
  134. print_sigevent.c
  135. print_statfs.c
  136. print_time.c
  137. print_timex.c
  138. printmode.c
  139. printrusage.c
  140. printsiginfo.c
  141. printsiginfo.h
  142. printstat.h
  143. process.c
  144. process_vm.c
  145. ptp.c
  146. ptrace.h
  147. quota.c
  148. readahead.c
  149. readlink.c
  150. README
  151. README-hacking
  152. README-linux-ptrace
  153. README-mpers
  154. README.md
  155. reboot.c
  156. regs.h
  157. renameat.c
  158. resource.c
  159. rtc.c
  160. sched.c
  161. scsi.c
  162. seccomp.c
  163. seccomp_fprog.h
  164. sendfile.c
  165. sigaltstack.c
  166. sigevent.h
  167. signal.c
  168. signalent.sh
  169. signalfd.c
  170. sigreturn.c
  171. sock.c
  172. sockaddr.c
  173. socketcall.c
  174. socketutils.c
  175. sram_alloc.c
  176. statfs.c
  177. statfs.h
  178. statfs64.c
  179. strace-graph
  180. strace-log-merge
  181. strace.1
  182. strace.c
  183. strace.spec.in
  184. swapon.c
  185. sync_file_range.c
  186. sync_file_range2.c
  187. syscall.c
  188. syscallent.sh
  189. sysctl.c
  190. sysinfo.c
  191. syslog.c
  192. sysmips.c
  193. term.c
  194. time.c
  195. times.c
  196. travis-build.sh
  197. travis-install.sh
  198. travis-success.sh
  199. truncate.c
  200. ubi.c
  201. uid.c
  202. uid16.c
  203. umask.c
  204. umount.c
  205. uname.c
  206. unwind.c
  207. upeek.c
  208. userfaultfd.c
  209. util.c
  210. utime.c
  211. utimes.c
  212. v4l2.c
  213. vsprintf.c
  214. wait.c
  215. xattr.c
  216. xlat.h
  217. xlate.el
  218. xmalloc.c
README.md

This is strace -- a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.

strace is released under a Berkeley-style license at the request of Paul Kranenburg; see the file COPYING for details.

See the file NEWS for information on what has changed in recent versions.

Please send bug reports and enhancements to the strace mailing list.

Build Status Code Coverage