[CRIU] [PATCH 1/3] restorer: Remember to check ret codes for syscalls

Dmitry Safonov dima at arista.com
Wed Oct 31 01:35:29 MSK 2018


Looks like, we're missing the check which potentially can add us
some troubles.

Signed-off-by: Dmitry Safonov <dima at arista.com>
---
 criu/pie/restorer.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 186cbae404ef..d3b459c6c8b1 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1263,11 +1263,19 @@ long __export_restore_task(struct task_restore_args *args)
 	act.rt_sa_handler = sigchld_handler;
 	act.rt_sa_flags = SA_SIGINFO | SA_RESTORER | SA_RESTART;
 	act.rt_sa_restorer = cr_restore_rt;
-	sys_sigaction(SIGCHLD, &act, NULL, sizeof(k_rtsigset_t));
+	ret = sys_sigaction(SIGCHLD, &act, NULL, sizeof(k_rtsigset_t));
+	if (ret) {
+		pr_err("Failed to set SIGCHLD %ld\n", ret);
+		goto core_restore_end;
+	}
 
 	ksigemptyset(&to_block);
 	ksigaddset(&to_block, SIGCHLD);
 	ret = sys_sigprocmask(SIG_UNBLOCK, &to_block, NULL, sizeof(k_rtsigset_t));
+	if (ret) {
+		pr_err("Failed to unblock SIGCHLD %ld\n", ret);
+		goto core_restore_end;
+	}
 
 	std_log_set_fd(args->logfd);
 	std_log_set_loglevel(args->loglevel);
@@ -1663,7 +1671,7 @@ long __export_restore_task(struct task_restore_args *args)
 	}
 
 	if (!args->compatible_mode) {
-		sys_sigaction(SIGCHLD, &args->sigchld_act,
+		ret = sys_sigaction(SIGCHLD, &args->sigchld_act,
 				NULL, sizeof(k_rtsigset_t));
 	} else {
 		void *stack = alloc_compat_syscall_stack();
@@ -1672,10 +1680,14 @@ long __export_restore_task(struct task_restore_args *args)
 			pr_err("Failed to allocate 32-bit stack for sigaction\n");
 			goto core_restore_end;
 		}
-		arch_compat_rt_sigaction(stack, SIGCHLD,
+		ret = arch_compat_rt_sigaction(stack, SIGCHLD,
 				(void*)&args->sigchld_act);
 		free_compat_syscall_stack(stack);
 	}
+	if (ret) {
+		pr_err("Failed to restore SIGCHLD: %ld\n", ret);
+		goto core_restore_end;
+	}
 
 	ret = restore_signals(args->siginfo, args->siginfo_n, true);
 	if (ret)
-- 
2.19.1



More information about the CRIU mailing list