mirror of https://github.com/torvalds/linux.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 <aleksandr.mikhalitsyn@canonical.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
32ae9fa406
commit
8b64f54c81
|
|
@ -271,22 +271,26 @@ TEST_F(coredump, socket_detect_userspace_client)
|
|||
_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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue