<html><head></head><body>Reviewed-by: Christopher Covington &lt;cov@codeaurora.org&gt;<br><br><div class="gmail_quote">On July 7, 2016 7:51:55 AM EDT, Dmitry Safonov &lt;dsafonov@virtuozzo.com&gt; wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">For `criu exec` we are searching for a place for syscall injection.<br />While searching for a VMA with PROT_EXEC and with needed size,<br />we check that VMA is lower than task_size.<br />The callpath for it is:<br />cr_exec =&gt; parasite_prep_ctl =&gt; get_vma_by_ip<br /><br />Firstly, I thought to omit kdat.task_size checking if it's not inited:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> if (vma_area-&gt;e-&gt;start &gt;= kdat.task_size &amp;&amp; kdat.task_size)<br /></blockquote>but I think it's a hack then a proper solution.<br />Besides, this code still can choose VMA over task_size on ARM<br />and try to inject syscall there (IIRC, ARM has kernel-mapped<br />VMA in that area).<br /><br />So, lets init kdat.task_size for `criu exec`.<br />Also lets init kdat.has_compat_sigreturn so we could exec into<br />compatible applications.<br /><br />Cc: Christopher Covington
&lt;cov@codeaurora.org&gt;<br />Cc: Andrew Vagin &lt;avagin@virtuozzo.com&gt;<br />Cc: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;<br />Signed-off-by: Dmitry Safonov &lt;dsafonov@virtuozzo.com&gt;<br />---<br /> criu/cr-exec.c         |  6 ++++++<br /> criu/include/kerndat.h |  1 +<br /> criu/kerndat.c         | 11 +++++++++++<br /> 3 files changed, 18 insertions(+)<br /><br />diff --git a/criu/cr-exec.c b/criu/cr-exec.c<br />index e8177388686b..42fb90f60123 100644<br />--- a/criu/cr-exec.c<br />+++ b/criu/cr-exec.c<br />@@ -7,6 +7,7 @@<br /> #include "vma.h"<br /> #include "log.h"<br /> #include "util.h"<br />+#include "kerndat.h"<br /> <br /> struct syscall_exec_desc {<br />  char *name;<br />@@ -125,6 +126,11 @@ int cr_exec(int pid, char **opt)<br />   goto out;<br />  }<br /> <br />+ if (kerndat_init_cr_exec()) {<br />+  pr_err("Failed to init kerndat\n");<br />+  goto out;<br />+ }<br />+<br />  if (seize_catch_task(pid))<br />   goto out;<br /> <br />diff --git
a/criu/include/kerndat.h b/criu/include/kerndat.h<br />index e1bf7ad043c6..0a5cd4bfac57 100644<br />--- a/criu/include/kerndat.h<br />+++ b/criu/include/kerndat.h<br />@@ -12,6 +12,7 @@ struct stat;<br /> <br /> extern int kerndat_init(void);<br /> extern int kerndat_init_rst(void);<br />+extern int kerndat_init_cr_exec(void);<br /> extern int kerndat_get_dirty_track(void);<br /> extern int kerndat_fdinfo_has_lock(void);<br /> extern int kerndat_loginuid(bool only_dump);<br />diff --git a/criu/kerndat.c b/criu/kerndat.c<br />index 07f848e7bae0..04a355ba4505 100644<br />--- a/criu/kerndat.c<br />+++ b/criu/kerndat.c<br />@@ -521,3 +521,14 @@ int kerndat_init_rst(void)<br /> <br />  return ret;<br /> }<br />+<br />+int kerndat_init_cr_exec(void)<br />+{<br />+ int ret;<br />+<br />+ ret = get_task_size();<br />+ if (!ret)<br />+  ret = kerndat_compat_restore();<br />+<br />+ return ret;<br />+}</pre></blockquote></div><br>
-- <br>
Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,<br>
a Linux Foundation Collaborative Project<br>
<br>
Sent from my Snapdragon powered Android device with K-9 Mail. Please excuse my brevity.</body></html>