From: Christian Brauner Date: Tue, 28 Oct 2025 08:46:00 +0000 (+0100) Subject: selftests/coredump: fix userspace coredump client detection X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b64f54c81d5baaef7fe117caa2f565be50ba440;p=thirdparty%2Flinux.git selftests/coredump: fix userspace coredump client detection PIDFD_INFO_COREDUMP is only retrievable until the task has exited. After it has exited task->mm is NULL. So if the task didn't actually coredump we can't retrieve it's dumpability settings anymore. Only if the task did coredump will we have stashed the coredump information in the respective struct pid. Link: https://patch.msgid.link/20251028-work-coredump-signal-v1-15-ca449b7b7aa0@kernel.org Reviewed-by: Alexander Mikhalitsyn Signed-off-by: Christian Brauner --- diff --git a/tools/testing/selftests/coredump/coredump_socket_test.c b/tools/testing/selftests/coredump/coredump_socket_test.c index 658f3966064f9..5103d9f130031 100644 --- a/tools/testing/selftests/coredump/coredump_socket_test.c +++ b/tools/testing/selftests/coredump/coredump_socket_test.c @@ -271,22 +271,26 @@ out: _exit(EXIT_FAILURE); close(fd_socket); + pause(); _exit(EXIT_SUCCESS); } pidfd = sys_pidfd_open(pid, 0); ASSERT_GE(pidfd, 0); - waitpid(pid, &status, 0); - ASSERT_TRUE(WIFEXITED(status)); - ASSERT_EQ(WEXITSTATUS(status), 0); - ASSERT_TRUE(get_pidfd_info(pidfd, &info)); ASSERT_GT((info.mask & PIDFD_INFO_COREDUMP), 0); ASSERT_EQ((info.coredump_mask & PIDFD_COREDUMPED), 0); wait_and_check_coredump_server(pid_coredump_server, _metadata, self); + ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0), 0); + ASSERT_EQ(close(pidfd), 0); + + waitpid(pid, &status, 0); + ASSERT_TRUE(WIFSIGNALED(status)); + ASSERT_EQ(WTERMSIG(status), SIGKILL); + ASSERT_NE(stat("/tmp/coredump.file", &st), 0); ASSERT_EQ(errno, ENOENT); }