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

pidfd: block SIGCHLD during tmp process creation #2491

Open
wants to merge 1 commit into
base: criu-dev
Choose a base branch
from

Conversation

rst0git
Copy link
Member

@rst0git rst0git commented Oct 9, 2024

This pull request updates pidfd to block SIGCHLD during temporary process creation to prevent a race condition between kill() and waitpid() where sigchld_handler() causes criu restore to fail with an error.

Fixes: #2490

Copy link
Member

@bsach64 bsach64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @rst0git!
I was about to raise one myself!

criu/pidfd.c Outdated Show resolved Hide resolved
criu/pidfd.c Outdated Show resolved Hide resolved
This patch blocks SIGCHLD during temporary process creation to prevent a
race condition between kill() and waitpid() where sigchld_handler()
causes `criu restore` to fail with an error.

Fixes: checkpoint-restore#2490

Signed-off-by: Bhavik Sachdev <b.sachdev1904@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@mihalicyn
Copy link
Member

Hi Radostin!

Thanks a lot for looking into it! We had a call with Bhavik today and he wants to see if we can use pstree helpers to solve this problem. So, let's wait a bit with merging this.

@rst0git
Copy link
Member Author

rst0git commented Oct 9, 2024

Thank you for the PR @rst0git! I was about to raise one myself!

No worries, I just wanted to confirm that the pidfd_dead test will pass with these changes in CI.

We had a call with Bhavik today and he wants to see if we can use pstree helpers to solve this problem.

I'm not sure how easy it would be to do that but the messages in the following commits might help: c09ba04 5f72963

*/
sigemptyset(&blockmask);
sigaddset(&blockmask, SIGCHLD);
if (sigprocmask(SIG_BLOCK, &blockmask, &dead->oldmask) == -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigprocmask should be called right before killing this process. If I remember it right, a process can be created in one process, but killed in another process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zdtm/static/pidfd_dead fails in Fedora Rawhide:
4 participants