[CRIU] [PATCH] restore: check a return code of RUN_CLONE_RESTORE_FN

Andrei Vagin avagin at virtuozzo.com
Tue May 15 23:31:12 MSK 2018


Otherwise we can skip an error and then criu will hang on switching to
the next stage.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/pie/restorer.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 6b5e9a008..ea79211ba 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1604,6 +1604,8 @@ long __export_restore_task(struct task_restore_args *args)
 
 		for (i = 0; i < args->nr_threads; i++) {
 			char last_pid_buf[16], *s;
+			pid_t pid = 0;
+
 			/* skip self */
 			if (thread_args[i].pid[0] == args->t->pid[0]) {
 				self_thread = i;
@@ -1612,7 +1614,8 @@ long __export_restore_task(struct task_restore_args *args)
 
 			if (fd >= 0) {
 				/* One level pid ns hierarhy */
-				last_pid_len = std_vprint_num(last_pid_buf, sizeof(last_pid_buf), thread_args[i].pid[0] - 1, &s);
+				pid = thread_args[i].pid[0];
+				last_pid_len = std_vprint_num(last_pid_buf, sizeof(last_pid_buf), pid - 1, &s);
 				sys_lseek(fd, 0, SEEK_SET);
 				ret = sys_write(fd, s, last_pid_len);
 				if (ret < 0) {
@@ -1625,7 +1628,8 @@ long __export_restore_task(struct task_restore_args *args)
 				for (k = 0; k < MAX_NS_NESTING; k++) {
 					if (thread_args[i].pid[k] == 0)
 						break;
-					if (request_set_next_pid(args->pid_ns_id[k], thread_args[i].pid[k], args->transport_fd) < 0) {
+					pid = thread_args[i].pid[k];
+					if (request_set_next_pid(args->pid_ns_id[k], pid, args->transport_fd) < 0) {
 						pr_err("Can't request to set pid\n");
 						mutex_unlock(&task_entries_local->last_pid_mutex);
 						goto core_restore_end;
@@ -1642,6 +1646,10 @@ long __export_restore_task(struct task_restore_args *args)
 			 */
 
 			RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, thread_args, args->clone_restore_fn);
+			if (ret != pid) {
+				pr_err("Unable to create a thread: %ld", ret);
+				goto core_restore_end;
+			}
 		}
 
 		mutex_unlock(&task_entries_local->last_pid_mutex);
-- 
2.14.3



More information about the CRIU mailing list