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

Submitted by Cyrill Gorcunov on March 20, 2018, 9:43 p.m.

Details

Message ID 20180320214313.25326-28-gorcunov@gmail.com
State Rejected
Series "seccomp, v2: Add support for per-thread tracking"
Headers show

Commit Message

Cyrill Gorcunov March 20, 2018, 9:43 p.m.
The thread_core is not present on dead tasks so to
prevent nil dereference on restore.

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

Patch hide | download patch | download mbox

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 {