criu
criu copied to clipboard
CRIU can't dump `pidfd_open` returned fd containing process
dumpee src:
#define _GNU_SOURCE
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
static int pidfd_open(pid_t pid, unsigned int flags)
{
return syscall(SYS_pidfd_open, pid, flags);
}
int main(void)
{
int pid, pidfd, ready;
struct pollfd pollfd;
printf("pid: %d\n", getpid());
pid = fork();
if (pid > 0) {
pidfd = pidfd_open(pid, 0);
if (pidfd == -1) {
perror("pidfd_open");
exit(EXIT_FAILURE);
}
pollfd.fd = pidfd;
pollfd.events = POLLIN;
ready = poll(&pollfd, 1, -1);
if (ready == -1) {
perror("poll");
exit(EXIT_FAILURE);
}
printf("Events (%#x): POLLIN is %sset\n", pollfd.revents,
(pollfd.revents & POLLIN) ? "" : "not ");
pause();
close(pidfd);
}
exit(EXIT_SUCCESS);
}
dumpee
./pidfd_app
pid: 58909
Events (0x1): POLLIN is set
criu dump:
sudo ./criu/criu dump -D dumpdir/ -v4 --shell-job -t 58909
failed dump log:
........................
pie: 58909: Daemon waits for command
(00.014997) Fetched ack: 73 73 0
(00.015134) 58909 fdinfo 1: pos: 0 flags: 2002/0
(00.015184) 58909 fdinfo 2: pos: 0 flags: 2002/0
(00.015225) 58909 fdinfo 3: pos: 0 flags: 2/0x1
(00.015248) Error (criu/files-ext.c:94): Can't dump file 3 of that type [600] (anon anon_inode:[pidfd])
(00.015260) ----------------------------------------
(00.015297) Error (criu/cr-dump.c:1674): Dump files (pid: 58909) failed with -1
(00.015312) Waiting for 58909 to trap
(00.015350) Daemon 58909 exited trapping
(00.015366) Sent msg to daemon 3 0 0
pie: 58909: __fetched msg: 3 0 0
pie: 58909: 58909: new_sp=0x7f330aac5948 ip 0x7f330a9a936e
(00.053642) 58909 was trapped
(00.053707) 58909 was trapped
(00.053720) 58909 (native) is going to execute the syscall 15, required is 15
(00.053768) 58909 was stopped
(00.054081) net: Unlock network
(00.054093) Unfreezing tasks into 1
(00.054099) Unseizing 58909 into 1
(00.054119) Error (criu/cr-dump.c:2098): Dumping FAILED.
#2256 also related to this.
I'd like to work on this issue parallel to memfd_secret MR. If it's possible, can you please assign this for me. Thanks!
cc @mihalicyn @brauner
@warusadura Thanks for creating this issue, I was working on this issue and had mike to get some feedback on the work I did.If you want we can collaborate on this. I opened up a draft PR for it #2259
If you want we can collaborate on this.
Yes, let's do it. @h0lyalg0rithm
A friendly reminder that this issue had no activity for 30 days.