selftests: add tests for pidfd_send_signal()

As suggested by Andrew Morton in [1] add selftests for the new
sys_pidfd_send_signal() syscall:

/* test_pidfd_send_signal_syscall_support */
Test whether the pidfd_send_signal() syscall is supported and the tests can
be run or need to be skipped.

/* test_pidfd_send_signal_simple_success */
Test whether sending a signal via a pidfd works.

/* test_pidfd_send_signal_exited_fail */
Verify that sending a signal to an already exited process fails with ESRCH.

/* test_pidfd_send_signal_recycled_pid_fail */
Verify that a recycled pid cannot be signaled via a pidfd referring to an
already exited process that had the same pid (cf. [2], [3]).


Cc: Arnd Bergmann <>
Cc: "Eric W. Biederman" <>
Cc: Kees Cook <>
Cc: Jann Horn <>
Cc: Andy Lutomirsky <>
Cc: Andrew Morton <>
Cc: Oleg Nesterov <>
Cc: Aleksa Sarai <>
Cc: Al Viro <>
Cc: Florian Weimer <>
Signed-off-by: Christian Brauner <>
Reviewed-by: Tycho Andersen <>
Acked-by: Serge Hallyn <>
3 files changed