PCuABI requires that the siginfo_t data delivered to the signal by syscall pidfd_send_signal should pass the capability pointer tags in case of signal delivered to the same process. In case of different process, no tag details are copied.
Appropriate tests are added to verify the above behavior.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- .../testing/selftests/arm64/morello/signal.c | 42 +++++++++++++++++++ .../selftests/arm64/morello/signal_common.c | 10 +++++ .../selftests/arm64/morello/signal_common.h | 2 + 3 files changed, 54 insertions(+)
diff --git a/tools/testing/selftests/arm64/morello/signal.c b/tools/testing/selftests/arm64/morello/signal.c index 67e277cecc52..5c5bddf251ad 100644 --- a/tools/testing/selftests/arm64/morello/signal.c +++ b/tools/testing/selftests/arm64/morello/signal.c @@ -330,6 +330,47 @@ TEST(test_rt_tgsigqueueinfo) } }
+TEST(test_pidfd_send_signal) +{ + siginfo_t si, wait_si; + pid_t cpid; + int pidfd, ret; + struct sigaction sa; + + setup_sigusr1_handler(&sa, SIG_UNBLOCK); + + TH_LOG("test_pidfd_send_signal: Signal to the same process"); + setup_siginfo_same_process(&si); + pidfd = pidfd_open(si.si_pid, 0); + ASSERT_GE(pidfd, 0) { + __TH_LOG_ERROR("Failed to open process file descriptor"); + } + ret = pidfd_send_signal(pidfd, SIGUSR1, &si, 0); + ASSERT_EQ(ret, 0) { + __TH_LOG_ERROR("pidfd_send_signal syscall failed"); + } + wait(DELAY * 1000); + ASSERT_TRUE(signal_status); + close(pidfd); + + TH_LOG("test_pidfd_send_signal: Signal to a different process"); + cpid = setup_siginfo_diff_process(&si); + + pidfd = pidfd_open(cpid, 0); + ASSERT_GE(pidfd, 0) { + __TH_LOG_ERROR("Failed to open process file descriptor"); + } + ret = pidfd_send_signal(pidfd, SIGUSR1, &si, 0); + ASSERT_EQ(ret, 0) { + __TH_LOG_ERROR("pidfd_send_signal syscall failed"); + } + ret = waitid(P_PID, cpid, &wait_si, WEXITED, NULL); + ASSERT_EQ(ret, 0) { + __TH_LOG_ERROR("test_pidfd_send_signal: Failed on wait"); + } + close(pidfd); +} + int main(void) { test_signal_basic(); @@ -337,5 +378,6 @@ int main(void) test_timer_create(); test_rt_sigqueueinfo(); test_rt_tgsigqueueinfo(); + test_pidfd_send_signal(); return 0; } diff --git a/tools/testing/selftests/arm64/morello/signal_common.c b/tools/testing/selftests/arm64/morello/signal_common.c index 59bb7cca1b40..260f3ebe2b5e 100644 --- a/tools/testing/selftests/arm64/morello/signal_common.c +++ b/tools/testing/selftests/arm64/morello/signal_common.c @@ -97,3 +97,13 @@ int rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *uinfo) { return syscall(__NR_rt_tgsigqueueinfo, tgid, tid, sig, uinfo); } + +int pidfd_open(pid_t pid, int flags) +{ + return syscall(__NR_pidfd_open, pid, flags); +} + +int pidfd_send_signal(int pidfd, int sig, siginfo_t *uinfo, unsigned int flags) +{ + return syscall(__NR_pidfd_send_signal, pidfd, sig, uinfo, flags); +} diff --git a/tools/testing/selftests/arm64/morello/signal_common.h b/tools/testing/selftests/arm64/morello/signal_common.h index cf08a3995792..2275ae1cab18 100644 --- a/tools/testing/selftests/arm64/morello/signal_common.h +++ b/tools/testing/selftests/arm64/morello/signal_common.h @@ -33,5 +33,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *new_value struct itimerspec *old_value); int rt_sigqueueinfo(pid_t tgid, int sig, siginfo_t *uinfo); int rt_tgsigqueueinfo(pid_t tgid, pid_t tid, int sig, siginfo_t *uinfo); +int pidfd_open(pid_t pid, int flags); +int pidfd_send_signal(int pidfd, int sig, siginfo_t *uinfo, unsigned int flags);
#endif /* ! SIGNAL_COMMON_H */