aboutsummaryrefslogtreecommitdiff
path: root/include/linux/iio/timer/stm32-timer-trigger.h
diff options
context:
space:
mode:
authorChristian Brauner <[email protected]>2019-04-07 21:18:11 +0200
committerChristian Brauner <[email protected]>2019-05-07 14:31:04 +0200
commit43c6afee48d4d866d5eb984d3a5dbbc7d9b4e7bf (patch)
tree19fa00ede54949757cea719765db5ec86fb89f2a /include/linux/iio/timer/stm32-timer-trigger.h
parent2151ad1b067275730de1b38c7257478cae47d29e (diff)
samples: show race-free pidfd metadata access
This is a sample program showing userspace how to get race-free access to process metadata from a pidfd. It is rather easy to do and userspace can actually simply reuse code that currently parses a process's status file in procfs. The program can easily be extended into a generic helper suitable for inclusion in a libc to make it even easier for userspace to gain metadata access. Since this came up in a discussion because this API is going to be used in various service managers: A lot of programs will have a whitelist seccomp filter that returns <some-errno> for all new syscalls. This means that programs might get confused if CLONE_PIDFD works but the later pidfd_send_signal() syscall doesn't. Hence, here's a ahead of time check that pidfd_send_signal() is supported: bool pidfd_send_signal_supported() { int procfd = open("/proc/self", O_DIRECTORY | O_RDONLY | O_CLOEXEC); if (procfd < 0) return false; /* * A process is always allowed to signal itself so * pidfd_send_signal() should never fail this test. If it does * it must mean it is not available, blocked by an LSM, seccomp, * or other. */ return pidfd_send_signal(procfd, 0, NULL, 0) == 0; } Signed-off-by: Christian Brauner <[email protected]> Co-developed-by: Jann Horn <[email protected]> Signed-off-by: Jann Horn <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Kees Cook <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: David Howells <[email protected]> Cc: "Michael Kerrisk (man-pages)" <[email protected]> Cc: Andy Lutomirsky <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Aleksa Sarai <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Al Viro <[email protected]>
Diffstat (limited to 'include/linux/iio/timer/stm32-timer-trigger.h')
0 files changed, 0 insertions, 0 deletions