Bug 485924 - No support for pidfd_send_signal system call
Summary: No support for pidfd_send_signal system call
Status: CONFIRMED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (other bugs)
Version First Reported In: 3.22.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-21 20:42 UTC by k04jg02
Modified: 2026-01-18 15:57 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description k04jg02 2024-04-21 20:42:49 UTC
SUMMARY
If you call pidfd_send_signal and then run valgrind on your executable you get this message on x86-64:

==822833== For lists of detected and suppressed errors, rerun with: -s
==822833== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--822834-- WARNING: unhandled amd64-linux syscall: 424
--822834-- You may be able to write your own handler.
--822834-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--822834-- Nevertheless we consider this a bug.  Please report
--822834-- it at http://valgrind.org/support/bug_reports.html.
Comment 1 k04jg02 2024-04-21 20:44:06 UTC
Note that my libc was not new enough to have a wrapper for this syscall, if yours isn't as well you will want this to reproduce:

```
#include <sys/syscall.h>

#ifndef SYS_pidfd_send_signal
#define SYS_pidfd_send_signal 424
#endif

int pidfd_send_signal(int pidfd, int sig, siginfo_t* info, unsigned int flags)
{
    return syscall(SYS_pidfd_send_signal, pidfd, sig, info, flags);
}
```
Comment 2 Mark Wielaard 2024-04-23 16:33:48 UTC
There was a preliminary implementation posted to the mailinglist:
https://sourceforge.net/p/valgrind/mailman/message/52515225/
Comment 3 Mark Wielaard 2024-04-23 16:48:35 UTC
So the only tricky part is that we want to mimic this part of the (generic) PRE(sys_kill):

   /* If we're sending SIGKILL, check to see if the target is one of            
      our threads and handle it specially. */                                   
   if (ARG2 == VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1))                        
      SET_STATUS_Success(0);                                                    

In the pidfd_send_signal case ARG2 is the signo, just like the kill syscall.
But ARG1 is a pidfd and do_sigkill wants an pid (tid).
So we have to somehow translate the pidfd to a pid number.

It isn't immediately clear how to do that.
Comment 4 milasudril 2026-01-18 15:57:11 UTC
Any work on this