[CRIU] [PATCHv3 3/4] cr-exec: initialize kdat.{task_size, has_compat_sigreturn} on criu exec

Christopher Covington cov at codeaurora.org
Sat Jul 9 17:51:02 PDT 2016


Reviewed-by: Christopher Covington <cov at codeaurora.org>

On July 7, 2016 7:51:55 AM EDT, Dmitry Safonov <dsafonov at virtuozzo.com> wrote:
>For `criu exec` we are searching for a place for syscall injection.
>While searching for a VMA with PROT_EXEC and with needed size,
>we check that VMA is lower than task_size.
>The callpath for it is:
>cr_exec => parasite_prep_ctl => get_vma_by_ip
>
>Firstly, I thought to omit kdat.task_size checking if it's not inited:
>> if (vma_area->e->start >= kdat.task_size && kdat.task_size)
>but I think it's a hack then a proper solution.
>Besides, this code still can choose VMA over task_size on ARM
>and try to inject syscall there (IIRC, ARM has kernel-mapped
>VMA in that area).
>
>So, lets init kdat.task_size for `criu exec`.
>Also lets init kdat.has_compat_sigreturn so we could exec into
>compatible applications.
>
>Cc: Christopher Covington <cov at codeaurora.org>
>Cc: Andrew Vagin <avagin at virtuozzo.com>
>Cc: Cyrill Gorcunov <gorcunov at openvz.org>
>Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
>---
> criu/cr-exec.c         |  6 ++++++
> criu/include/kerndat.h |  1 +
> criu/kerndat.c         | 11 +++++++++++
> 3 files changed, 18 insertions(+)
>
>diff --git a/criu/cr-exec.c b/criu/cr-exec.c
>index e8177388686b..42fb90f60123 100644
>--- a/criu/cr-exec.c
>+++ b/criu/cr-exec.c
>@@ -7,6 +7,7 @@
> #include "vma.h"
> #include "log.h"
> #include "util.h"
>+#include "kerndat.h"
> 
> struct syscall_exec_desc {
> 	char *name;
>@@ -125,6 +126,11 @@ int cr_exec(int pid, char **opt)
> 		goto out;
> 	}
> 
>+	if (kerndat_init_cr_exec()) {
>+		pr_err("Failed to init kerndat\n");
>+		goto out;
>+	}
>+
> 	if (seize_catch_task(pid))
> 		goto out;
> 
>diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
>index e1bf7ad043c6..0a5cd4bfac57 100644
>--- a/criu/include/kerndat.h
>+++ b/criu/include/kerndat.h
>@@ -12,6 +12,7 @@ struct stat;
> 
> extern int kerndat_init(void);
> extern int kerndat_init_rst(void);
>+extern int kerndat_init_cr_exec(void);
> extern int kerndat_get_dirty_track(void);
> extern int kerndat_fdinfo_has_lock(void);
> extern int kerndat_loginuid(bool only_dump);
>diff --git a/criu/kerndat.c b/criu/kerndat.c
>index 07f848e7bae0..04a355ba4505 100644
>--- a/criu/kerndat.c
>+++ b/criu/kerndat.c
>@@ -521,3 +521,14 @@ int kerndat_init_rst(void)
> 
> 	return ret;
> }
>+
>+int kerndat_init_cr_exec(void)
>+{
>+	int ret;
>+
>+	ret = get_task_size();
>+	if (!ret)
>+		ret = kerndat_compat_restore();
>+
>+	return ret;
>+}
>-- 
>2.9.0

-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

Sent from my Snapdragon powered Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20160709/e152f686/attachment.html>


More information about the CRIU mailing list