Commit da9315d8 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

cr-exec: initialize kdat.{task_size, has_compat_sigreturn} on criu exec

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@codeaurora.org>
Cc: Andrew Vagin <avagin@virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: 's avatarChristopher Covington <cov@codeaurora.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 3693c5e6
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "vma.h" #include "vma.h"
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
#include "kerndat.h"
struct syscall_exec_desc { struct syscall_exec_desc {
char *name; char *name;
...@@ -125,6 +126,11 @@ int cr_exec(int pid, char **opt) ...@@ -125,6 +126,11 @@ int cr_exec(int pid, char **opt)
goto out; goto out;
} }
if (kerndat_init_cr_exec()) {
pr_err("Failed to init kerndat\n");
goto out;
}
si = find_syscall(sys_name); si = find_syscall(sys_name);
if (!si) { if (!si) {
pr_err("Unknown syscall [%s]\n", sys_name); pr_err("Unknown syscall [%s]\n", sys_name);
......
...@@ -12,6 +12,7 @@ struct stat; ...@@ -12,6 +12,7 @@ struct stat;
extern int kerndat_init(void); extern int kerndat_init(void);
extern int kerndat_init_rst(void); extern int kerndat_init_rst(void);
extern int kerndat_init_cr_exec(void);
extern int kerndat_get_dirty_track(void); extern int kerndat_get_dirty_track(void);
extern int kerndat_fdinfo_has_lock(void); extern int kerndat_fdinfo_has_lock(void);
extern int kerndat_loginuid(bool only_dump); extern int kerndat_loginuid(bool only_dump);
......
...@@ -506,3 +506,12 @@ int kerndat_init_rst(void) ...@@ -506,3 +506,12 @@ int kerndat_init_rst(void)
return ret; return ret;
} }
int kerndat_init_cr_exec(void)
{
int ret;
ret = get_task_size();
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment