signal: PIDFD_SIGNAL_THREAD threads via pidfds

This commit extends pidfd_send_signal() to signal a specific thread.
As promised in the commit for pidfd_send_signal() [1] the extension is
based on a flag argument, i.e. the scope of the signal delivery is based on
the flag argument, not on the type of file descriptor.
To this end the flag PIDFD_SIGNAL_THREAD is added. With this change we now
cover most of the functionality of all the other signal sending functions

- pidfd_send_signal(<pidfd>, <sig>, NULL, 0);
  which is equivalent to
  kill(<positive-pid>, <signal>)

- pidfd_send_signal(<pidfd>, <sig>, <info>, 0);
  which is equivalent to
  rt_sigqueueinfo(<tgid>, <sig>, <uinfo>)

- pidfd_send_signal(<pidfd>, <sig>, NULL, PIDFD_SIGNAL_THREAD);
  which is equivalent to
  tgkill(<tgid>, <tid>, <signal)

- pidfd_send_signal(<pidfd>, <sig>, <info>, PIDFD_SIGNAL_THREAD);
  which is equivalent to
  rt_tgsigqueueinfo(<tgid>, <tid>, <sig>, <uinfo>)

/* References */
[1]: commit 3eb39f47934 ("signal: add pidfd_send_signal() syscall")

Signed-off-by: Christian Brauner <>
Cc: Arnd Bergmann <>
Cc: "Eric W. Biederman" <>
Cc: Kees Cook <>
Cc: Alexey Dobriyan <>
Cc: Thomas Gleixner <>
Cc: Jann Horn <
Cc: "Michael Kerrisk (man-pages)" <>
Cc: Konstantin Khlebnikov <>
Cc: Jonathan Kowalski <>
Cc: "Dmitry V. Levin" <>
Cc: Andy Lutomirsky <>
Cc: Andrew Morton <>
Cc: Oleg Nesterov <>
Cc: Nagarathnam Muthusamy <>
Cc: Aleksa Sarai <>
Cc: Al Viro <>
Cc: Florian Weimer <>
/* Changelog */
- Jann Horn < [1]:
  - initialize PIDFD_SIGNAL_TID flag with 1U to match @flags unsigned int
  - update comment about @flags
  - align pidfd_send_signal_specific()'s argument ordering with
- Christian Brauner <>:
  - insert comment about what the flag arguments are going to be named if
    we extend pidfd_send_signal() to process groups and sessions

/* Changelog References */
2 files changed