PCuABI requires that the siginfo_t data delivered to the signal by syscalls such as rt_sigqueueinfo/pidfd_send_signal should pass the capability pointer tags in case of signal delivered to the same process. Hence rt_sigtimedwait() syscall should be able to get siginfo_t with all tag details.
Appropriate test is added to verify the above behavior.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- .../testing/selftests/arm64/morello/signal.c | 21 +++++++++++++++++++ .../selftests/arm64/morello/signal_common.c | 6 ++++++ .../selftests/arm64/morello/signal_common.h | 2 ++ 3 files changed, 29 insertions(+)
diff --git a/tools/testing/selftests/arm64/morello/signal.c b/tools/testing/selftests/arm64/morello/signal.c index 5c5bddf251ad..50b1d623bacb 100644 --- a/tools/testing/selftests/arm64/morello/signal.c +++ b/tools/testing/selftests/arm64/morello/signal.c @@ -371,6 +371,26 @@ TEST(test_pidfd_send_signal) close(pidfd); }
+TEST(test_rt_sigtimedwait) +{ + siginfo_t si, wait_si = (siginfo_t){0}; + struct sigaction sa; + int ret; + + setup_sigusr1_handler(&sa, SIG_SETMASK); + + TH_LOG("test_rt_sigtimedwait: Signal to the same process"); + setup_siginfo_same_process(&si); + ret = rt_sigqueueinfo(si.si_pid, SIGUSR1, &si); + ASSERT_EQ(ret, 0) { + __TH_LOG_ERROR("rt_sigqueueinfo syscall failed"); + } + ret = rt_sigtimedwait(&sa.sa_mask, &wait_si, NULL, sizeof(sa.sa_mask)); + ASSERT_EQ(ret, SIGUSR1); + ASSERT_TRUE(cheri_is_equal_exact(wait_si.si_value.sival_ptr, + siginfo_params.ptr)); +} + int main(void) { test_signal_basic(); @@ -379,5 +399,6 @@ int main(void) test_rt_sigqueueinfo(); test_rt_tgsigqueueinfo(); test_pidfd_send_signal(); + test_rt_sigtimedwait(); return 0; } diff --git a/tools/testing/selftests/arm64/morello/signal_common.c b/tools/testing/selftests/arm64/morello/signal_common.c index 260f3ebe2b5e..8178e1eb6a8a 100644 --- a/tools/testing/selftests/arm64/morello/signal_common.c +++ b/tools/testing/selftests/arm64/morello/signal_common.c @@ -107,3 +107,9 @@ int pidfd_send_signal(int pidfd, int sig, siginfo_t *uinfo, unsigned int flags) { return syscall(__NR_pidfd_send_signal, pidfd, sig, uinfo, flags); } + +int rt_sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout, size_t sigsetsize) +{ + return syscall(__NR_rt_sigtimedwait, set, info, timeout, sigsetsize); +} diff --git a/tools/testing/selftests/arm64/morello/signal_common.h b/tools/testing/selftests/arm64/morello/signal_common.h index 2275ae1cab18..6ddc9acf95eb 100644 --- a/tools/testing/selftests/arm64/morello/signal_common.h +++ b/tools/testing/selftests/arm64/morello/signal_common.h @@ -35,5 +35,7 @@ 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); +int rt_sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout, size_t sigsetsize);
#endif /* ! SIGNAL_COMMON_H */