Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRIU can't dump pidfd_open returned fd containing process #2258

Open
warusadura opened this issue Sep 5, 2023 · 6 comments
Open

CRIU can't dump pidfd_open returned fd containing process #2258

warusadura opened this issue Sep 5, 2023 · 6 comments
Labels
new feature no-auto-close Don't auto-close as a stale issue

Comments

@warusadura
Copy link
Member

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.
@warusadura
Copy link
Member Author

#2256 also related to this.

@warusadura
Copy link
Member Author

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!

@warusadura
Copy link
Member Author

cc @mihalicyn @brauner

@h0lyalg0rithm
Copy link
Contributor

@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

@warusadura
Copy link
Member Author

warusadura commented Sep 6, 2023

If you want we can collaborate on this.

Yes, let's do it. @h0lyalg0rithm

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

A friendly reminder that this issue had no activity for 30 days.

@rst0git rst0git added new feature no-auto-close Don't auto-close as a stale issue and removed stale-issue labels Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature no-auto-close Don't auto-close as a stale issue
Projects
None yet
Development

No branches or pull requests

3 participants