[CRIU] Re: [PATCH 3/4] restorer: Do restore futex robust lists

Cyrill Gorcunov gorcunov at openvz.org
Thu Aug 9 13:36:54 EDT 2012


Updated version attached
-------------- next part --------------
>From 99b3282bd941ea4a2130076dd2e6e0f507a6377e Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Sun, 5 Aug 2012 13:07:29 +0400
Subject: [PATCH 3/4] restorer: Do restore futex robust lists v2

v2:
 - Check optional elements before restore

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c       |   14 ++++++++++++++
 include/restorer.h |    8 ++++++++
 restorer.c         |   18 ++++++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index ba49f6b..ef38505 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1318,6 +1318,13 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 	task_args->gpregs		= *core->thread_info->gpregs;
 	task_args->blk_sigset		= core->tc->blk_sigset;
 
+	if (core->thread_info->has_futex_rla &&
+	    core->thread_info->has_futex_rla_len) {
+		task_args->has_futex		= true;
+		task_args->futex_rla		= core->thread_info->futex_rla;
+		task_args->futex_rla_len	= core->thread_info->futex_rla_len;
+	}
+
 	/* No longer need it */
 	core_entry__free_unpacked(core, NULL);
 
@@ -1379,6 +1386,13 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 		thread_args[i].gpregs		= *core->thread_info->gpregs;
 		thread_args[i].clear_tid_addr	= core->thread_info->clear_tid_addr;
 
+		if (core->thread_info->has_futex_rla &&
+		    core->thread_info->has_futex_rla_len) {
+			thread_args[i].has_futex	= true;
+			thread_args[i].futex_rla	= core->thread_info->futex_rla;
+			thread_args[i].futex_rla_len	= core->thread_info->futex_rla_len;
+		}
+
 		core_entry__free_unpacked(core, NULL);
 
 		pr_info("Thread %4d stack %8p heap %8p rt_sigframe %8p\n",
diff --git a/include/restorer.h b/include/restorer.h
index 1cf2970..d50a9c8 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -64,6 +64,10 @@ struct thread_restore_args {
 	mutex_t				*rst_lock;
 	UserX86RegsEntry		gpregs;
 	u64				clear_tid_addr;
+
+	bool				has_futex;
+	u64				futex_rla;
+	u32				futex_rla_len;
 } __aligned(sizeof(long));
 
 struct task_restore_core_args {
@@ -101,6 +105,10 @@ struct task_restore_core_args {
 	char				comm[TASK_COMM_LEN];
 	TaskKobjIdsEntry		ids;
 	UserX86RegsEntry		gpregs;
+
+	bool				has_futex;
+	u64				futex_rla;
+	u32				futex_rla_len;
 } __aligned(sizeof(long));
 
 struct pt_regs {
diff --git a/restorer.c b/restorer.c
index 95a7922..a39374b 100644
--- a/restorer.c
+++ b/restorer.c
@@ -144,6 +144,15 @@ long __export_restore_thread(struct thread_restore_args *args)
 
 	sys_set_tid_address((int *)args->clear_tid_addr);
 
+	if (args->has_futex) {
+		if (sys_set_robust_list((void *)args->futex_rla, args->futex_rla_len)) {
+			write_num_n(__LINE__);
+			write_num_n(my_pid);
+			write_num_n(args->pid);
+			goto core_restore_end;
+		}
+	}
+
 	rt_sigframe = (void *)args->mem_zone.rt_sigframe + 8;
 
 #define CPREGT1(d)	rt_sigframe->uc.uc_mcontext.d = args->gpregs.d
@@ -432,6 +441,15 @@ long __export_restore_task(struct task_restore_core_args *args)
 	if (ret)
 		goto core_restore_end;
 
+	if (args->has_futex) {
+		if (sys_set_robust_list((void *)args->futex_rla, args->futex_rla_len)) {
+			write_num_n(__LINE__);
+			write_num_n(my_pid);
+			write_num_n(args->pid);
+			goto core_restore_end;
+		}
+	}
+
 	/*
 	 * We need to prepare a valid sigframe here, so
 	 * after sigreturn the kernel will pick up the
-- 
1.7.7.6



More information about the CRIU mailing list