criu icon indicating copy to clipboard operation
criu copied to clipboard

criu: Add support for pidfds

Open bsach64 opened this issue 1 year ago • 5 comments

A PR for support of process file descriptors.

Here's a article that talks about features of pidfds, which we might have to support (and test): http://www.corsix.org/content/what-is-a-pidfd

To Do:

  • [x] Check if the pid of pidfd is part of the process tree we are dumping. So, that we can ensure it exists on restore.
  • [x] Add support for pidfds that point to dead processes. (waiting for feedback) If the process for which a pidfd is open dies, the Pid and NSPid entries change to -1. So, we don't have the Pid necessary to recreate the process. We cannot just create a random process, open a pidfd to it, and kill it since pidfds opened for a specific process have the same inode number used to compare them.
  • [x] Change the magic in criu/include/magic.h
  • [x] test for pidfd_getfd
  • [x] Make CI green
  • [x] Check functionality before and after 6.9
  • [x] Better commit messages (add related issues that are fixed as a result of this PR)

Support for PIDFD_THREAD (allows creation of a pidfd that points to a specific thread) not a part of this PR.

Known Limitations: CRIU doesn't support nested PID namespaces. As such we cannot C/R pidfd's that point to PIDs in nested namespaces. If we introduce support for nested PID namespaces we will have to rework some of this code.

This is work being done as part of Google Summer of Code 2024 (https://summerofcode.withgoogle.com/programs/2024/projects/vgpqxIxx) A huge thank you to Alex @mihalicyn for guiding me and making this a wonderful experience :)

bsach64 avatar Jul 21 '24 17:07 bsach64

Better commit messages (add related issues that are fixed as a result of this PR)

@bsach64 The following blog post provides information on how to write good commit messages: https://cbea.ms/git-commit/

Similar to the Linux kernel, we use the commit history to make it easier for reviewers (and maintainers) to understand the problem that motivated particular patch and how this problem is being addressed.

rst0git avatar Aug 09 '24 16:08 rst0git

Better commit messages (add related issues that are fixed as a result of this PR)

@bsach64 The following blog post provides information on how to write good commit messages: https://cbea.ms/git-commit/

Similar to the Linux kernel, we use the commit history to make it easier for reviewers (and maintainers) to understand the problem that motivated particular patch and how this problem is being addressed.

Hello @rst0git! I have updated the commit messages and have tried to follow the rules stated here: https://cbea.ms/git-commit/

bsach64 avatar Aug 11 '24 19:08 bsach64

I am having a hard time understanding why the Vagrant Fedora Rawhide and Vagrant Fedora Rawhide (No VDSO) fail on the pidfd_child test. Can I get some help regarding this?

bsach64 avatar Aug 12 '24 10:08 bsach64

I am having a hard time understanding why the Vagrant Fedora Rawhide and Vagrant Fedora Rawhide (No VDSO) fail on the pidfd_child test. Can I get some help regarding this?

Fixed now! Vagrant Fedora Rawhide Test failure seems unrelated.

bsach64 avatar Aug 15 '24 10:08 bsach64

All tests pass for me locally on 6.10.4-200.fc40.x86_64!

bsach64 avatar Aug 16 '24 20:08 bsach64

@avagin Any update? :)

bsach64 avatar Sep 13 '24 12:09 bsach64

@mihalicyn could you help with reviewing this pr?

avagin avatar Sep 14 '24 00:09 avagin

Hey @bsach64, if you have a time and interest, we can discuss support for threaded pidfds. Next week I'll be on LPC 2024, but just after that I'll be happy chat with you.

mihalicyn avatar Sep 15 '24 08:09 mihalicyn

@mihalicyn could you help with reviewing this pr?

yeah, sorry, I just forgot to press an "approve" button earlier. As I was following a whole development process of this thing there is no doubt that it's approved/reviewed from my side :-)

mihalicyn avatar Sep 15 '24 08:09 mihalicyn

Hey @bsach64, if you have a time and interest, we can discuss support for threaded pidfds.

Next week I'll be on LPC 2024, but just after that I'll be happy chat with you.

Sure Alex :) Please send me an email, whenever you are free!

bsach64 avatar Sep 15 '24 08:09 bsach64

LGTM. Good job.

avagin avatar Oct 03 '24 15:10 avagin