criu icon indicating copy to clipboard operation
criu copied to clipboard

Criu Restore failed without sudo : Error (criu/tty.c:1466): tty: No task found with sid 10316

Open indusai99 opened this issue 2 years ago • 8 comments

Description

I am trying to take criu dump and restore using system() call function using criu CLI interface. But restore is failing with below error when run the dump and restore with out sudo.

 (00.001462) 274198: Error (criu/tty.c:1466): tty: No task found with sid 10316
(00.001524) Error (criu/cr-restore.c:2483): Restoring FAILED.
(00.001774) Error (criu/cr-restore.c:1562): 274198 killed by signal 9: Killed

Steps to reproduce the issue: (Please rename below dump and restore txt files to .c and please manually create /tmp/Plato folder)

  1. Created new C file for dumping dump.txt
  • Build -> gcc -o dump dump.c
  • Run -> ./dump
  1. Created new C file for restore restore.txt
  • Build -> gcc -o restore restore.c
  • Run -> ./restore

Describe the results you received: Restore is failing saying above error(No task found with sid 10316) even though I used sudo in criu CLI command inside restore file. But it is succesful when ran both dump and restore with sudo

  • sudo ./dump & sudo ./restore

Additional information you deem important (e.g. issue happens only occasionally): Issue happening only when run dump and restore with out sudo

criu version - 3.15

Additional environment details: Using Fedora based linux of kernel 5.12 version

Can anyone help me on this issue?

indusai99 avatar Sep 21 '23 10:09 indusai99

@Snorch @adrianreber @rst0git . Can I get your support on this issue?

indusai99 avatar Sep 25 '23 06:09 indusai99

@indusai99 You probably do something wrong, in first source (dump.txt/c) you fork criu providing it with -t getpid() option. It will make criu dump itself as it is in dumped subtree, see https://criu.org/Self_dump, you should use criu in service/swrk mode to succeed self-dump.

Snorch avatar Sep 25 '23 07:09 Snorch

@indusai99 It might be easier to implement this using libcriu. Here is an example: test/others/libcriu/test_self.c

rst0git avatar Sep 25 '23 13:09 rst0git

@indusai99 You probably do something wrong, in first source (dump.txt/c) you fork criu providing it with -t getpid() option. It will make criu dump itself as it is in dumped subtree, see https://criu.org/Self_dump, you should use criu in service/swrk mode to succeed self-dump.

Thank you @Snorch for quick response. Here I am using double fork() to create grand child and making this as daemon process by exiting from child . In this daemon process, I am trying to take criu dump of main process which is grand parent. In this case, dump process PID and daemon process doesn't relates to each other.
If something like this, restore should fail when running with sudo also. But its failing only in case of running test without sudo. Please let me know if I am missing something here .

indusai99 avatar Sep 25 '23 15:09 indusai99

@indusai99 It might be easier to implement this using libcriu. Here is an example: test/others/libcriu/test_self.c

Thanks @rst0git for response. I can't use libcriu because I require criu 32-bit libraries to do my 32-bit build. But criu doesn't have 32-bit library support. That's why I chosen criu CLI mode. Do you have any idea why restore is failing only when I ran test without sudo. Is it something like I used system command to run criu dump command which created child process internally but my host system doesn't have access to inherit tty in this child?

indusai99 avatar Sep 25 '23 15:09 indusai99

Here I am using double fork()

Sorry, missed second fork =) This way in general you approach is right.

Note: You need to handle all errors from all your system/libc-calls. for instance you need to check fork return for -1, else we don't actually know if you fork succeeded or not =) That may be one reason of your problems.

Note2: You might want to close stdin/stdout/stderr in your app (in the beggining of main()) so that your app is not connected to external terminals owned by unknown session, and also do setsid() to have self-owned session for the similar reason.

Snorch avatar Sep 26 '23 02:09 Snorch

@Snorch , I have checked all returns of my system/lib calls. Everything is fine. Coming to Note2, when i tried to close stdin/stderr/stdout in my main(), its causing to terminate function and I already used setsid() before calling criu CLI dump command.

indusai99 avatar Sep 26 '23 16:09 indusai99

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

github-actions[bot] avatar Oct 27 '23 00:10 github-actions[bot]