[CRIU] [PATCH 11/28] seccomp: Move filter position into seccomp_entry

Cyrill Gorcunov gorcunov at gmail.com
Wed Mar 21 00:42:56 MSK 2018


From: Cyrill Gorcunov <gorcunov at virtuozzo.com>

Since it will serve per-thread offsets.

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/cr-dump.c         |  2 +-
 criu/include/seccomp.h |  1 +
 criu/seccomp.c         | 12 +++++++-----
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 3bc07e6c5cf3..7aabd4736905 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -775,7 +775,7 @@ static int dump_task_core_all(struct parasite_ctl *ctl,
 
 		if (entry->mode == SECCOMP_MODE_FILTER) {
 			thread_core->has_seccomp_filter = true;
-			thread_core->seccomp_filter = dmpi(item)->last_filter;
+			thread_core->seccomp_filter = entry->last_filter;
 		}
 	}
 
diff --git a/criu/include/seccomp.h b/criu/include/seccomp.h
index f21f493e17a0..7e38ee2ea7fd 100644
--- a/criu/include/seccomp.h
+++ b/criu/include/seccomp.h
@@ -31,6 +31,7 @@ struct pstree_item;
 
 struct seccomp_entry {
 	pid_t			tid_real;
+	size_t			last_filter;
 	unsigned int		mode;
 };
 
diff --git a/criu/seccomp.c b/criu/seccomp.c
index 1f525633d3c2..4256f8d2ca12 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -93,8 +93,8 @@ static int collect_filter_for_pstree(struct pstree_item *item)
 {
 	struct seccomp_metadata meta_buf, *meta = &meta_buf;
 	struct seccomp_info *infos = NULL, *cursor;
-	struct seccomp_entry *entry;
-	int info_count, i, last_filter, ret = -1;
+	struct seccomp_entry *entry, *entry_parent;
+	int info_count, i, ret = -1;
 	struct sock_filter buf[BPF_MAXINSNS];
 	void *m;
 
@@ -139,8 +139,10 @@ static int collect_filter_for_pstree(struct pstree_item *item)
 			}
 		}
 
-		last_filter = dmpi(item->parent)->last_filter;
-		inherited = find_inherited(last_filter, buf, len, meta);
+		entry_parent = seccomp_find_entry(item->parent, item->parent->pid->real);
+		if (!entry_parent)
+			goto out;
+		inherited = find_inherited(entry_parent->last_filter, buf, len, meta);
 		if (inherited) {
 			bool found = false;
 
@@ -200,7 +202,7 @@ static int collect_filter_for_pstree(struct pstree_item *item)
 
 	next_filter_id += info_count;
 
-	dmpi(item)->last_filter = infos->id;
+	entry->last_filter = infos->id;
 
 	/* Don't free the part of the tree we just successfully acquired */
 	infos = NULL;
-- 
2.14.3



More information about the CRIU mailing list