[CRIU] [PATCH 27/28] seccomp: Fetch mode for alive tasks only

Cyrill Gorcunov gorcunov at gmail.com
Wed Mar 21 00:43:12 MSK 2018


The thread_core is not present on dead tasks so to
prevent nil dereference on restore.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/cr-restore.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 3025ec4032c2..673afb29c8fc 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1519,13 +1519,16 @@ static inline int fork_with_pid(struct pstree_item *item)
 		item->pid->state = ca.core->tc->task_state;
 		rsti(item)->cg_set = ca.core->tc->cg_set;
 
-		rsti(item)->has_seccomp = ca.core->thread_core->seccomp_mode != SECCOMP_MODE_DISABLED;
-
 		if (item->pid->state != TASK_DEAD && !task_alive(item)) {
 			pr_err("Unknown task state %d\n", item->pid->state);
 			return -1;
 		}
 
+		if (item->pid->state != TASK_DEAD)
+			rsti(item)->has_seccomp = ca.core->thread_core->seccomp_mode != SECCOMP_MODE_DISABLED;
+		else
+			rsti(item)->has_seccomp = false;
+
 		if (unlikely(item == root_item))
 			maybe_clone_parent(item, &ca);
 	} else {
-- 
2.14.3



More information about the CRIU mailing list