Yann Droneaud
a21b0b354d
perf: Introduce a flag to enable close-on-exec in perf_event_open()
Unlike recent modern userspace API such as:
epoll_create1 (EPOLL_CLOEXEC), eventfd (EFD_CLOEXEC),
fanotify_init (FAN_CLOEXEC), inotify_init1 (IN_CLOEXEC),
signalfd (SFD_CLOEXEC), timerfd_create (TFD_CLOEXEC),
or the venerable general purpose open (O_CLOEXEC),
perf_event_open() syscall lack a flag to atomically set FD_CLOEXEC
(eg. close-on-exec) flag on file descriptor it returns to userspace.
The present patch adds a PERF_FLAG_FD_CLOEXEC flag to allow
perf_event_open() syscall to atomically set close-on-exec.
Having this flag will enable userspace to remove the file descriptor
from the list of file descriptors being inherited across exec,
without the need to call fcntl(fd, F_SETFD, FD_CLOEXEC) and the
associated race condition between the current thread and another
thread calling fork(2) then execve(2).
Links:
- Secure File Descriptor Handling (Ulrich Drepper, 2008)
http://udrepper.livejournal.com/20407.html
- Excuse me son, but your code is leaking !!! (Dan Walsh, March 2012)
http://danwalsh.livejournal.com/53603.html
- Notes in DMA buffer sharing: leak and security hole
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/dma-buf-sharing.txt?id=v3.13-rc3#n428
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/8c03f54e1598b1727c19706f3af03f98685d9fe6.1388952061.git.ydroneaud@opteya.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-01-12 10:16:59 +01:00
..
2013-09-25 14:07:49 +02:00
2013-10-03 18:47:54 +02:00
2014-01-12 10:16:59 +01:00
2013-11-13 12:09:34 +09:00
2013-12-02 10:15:39 -08:00
2013-11-13 13:50:17 +01:00
2013-11-19 01:07:08 +01:00
2013-11-13 12:09:14 +09:00
2013-11-19 14:59:50 +01:00
2013-11-27 11:04:53 +01:00
2013-11-29 12:23:03 +01:00
2013-12-06 08:34:16 -08:00
2013-12-10 18:21:34 +00:00
2013-11-21 19:18:14 -08:00
2013-11-05 11:15:03 -05:00
2013-11-05 11:09:16 -05:00
2013-11-06 11:47:24 -05:00
2013-11-19 14:20:12 -08:00
2013-09-09 11:19:09 -07:00
2013-11-27 18:16:21 -05:00
2013-10-09 12:36:13 +02:00
2013-11-14 16:55:11 +09:00
2013-11-27 13:52:47 -05:00
2013-11-13 12:09:12 +09:00
2013-11-09 00:16:23 -05:00
2013-11-28 09:49:41 -08:00
2013-11-15 09:32:15 +09:00
2013-12-12 09:53:51 -08:00
2013-08-30 23:44:11 -07:00
2013-11-15 13:51:36 +09:00
2013-10-19 19:45:35 -04:00
2013-11-15 09:32:22 +09:00
2013-12-07 14:20:28 -07:00
2013-09-30 14:31:02 -07:00
2013-11-13 12:09:26 +09:00
2013-09-12 15:38:03 -07:00
2013-11-13 12:08:59 +09:00
2013-11-21 19:46:00 -08:00
2013-10-25 17:15:18 -04:00
2013-09-25 17:17:01 +01:00
2013-11-15 13:27:50 +09:00
2013-09-07 14:35:32 -07:00
2013-10-30 12:02:58 +08:00
2013-11-13 12:09:35 +09:00
2013-09-28 12:35:52 -07:00
2013-10-24 23:43:29 -04:00
2013-09-30 14:31:03 -07:00
2013-11-13 12:09:33 +09:00
2013-09-24 17:00:26 -07:00
2013-09-12 15:38:02 -07:00
2013-11-09 00:16:29 -05:00
2013-11-15 09:32:22 +09:00
2013-11-15 09:32:22 +09:00
2013-11-11 12:43:38 +01:00
2013-11-13 12:09:13 +09:00
2013-11-13 12:09:33 +09:00
2013-11-14 16:30:30 +09:00
2013-12-10 18:25:28 +00:00
2013-12-10 18:25:28 +00:00
2013-09-11 15:58:27 -07:00
2013-11-19 16:39:05 -05:00
2013-11-19 14:59:50 +01:00
2013-08-30 23:44:11 -07:00
2013-11-15 09:32:22 +09:00
2013-09-24 10:35:19 +01:00
2013-09-24 10:35:19 +01:00
2013-08-30 23:44:11 -07:00
2013-09-24 17:00:25 -07:00
2013-12-15 11:45:27 -08:00