Commit 8c2faeb5 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

parasite-syscall: choose between native/compat blobs

Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 024bae0a
...@@ -1346,13 +1346,27 @@ static int parasite_start_daemon(struct parasite_ctl *ctl, struct pstree_item *i ...@@ -1346,13 +1346,27 @@ static int parasite_start_daemon(struct parasite_ctl *ctl, struct pstree_item *i
return 0; return 0;
} }
/* FIXME: parasite native/compat */ #define init_parasite_ctl(ctl, blob_type) \
do { \
memcpy(ctl->local_map, parasite_##blob_type##_blob, \
sizeof(parasite_##blob_type##_blob)); \
ELF_RELOCS_APPLY(parasite_##blob_type, \
ctl->local_map, ctl->remote_map); \
/* Setup the rest of a control block */ \
ctl->parasite_ip = (unsigned long)parasite_sym(ctl->remote_map, \
blob_type, __export_parasite_head_start); \
ctl->addr_cmd = parasite_sym(ctl->local_map, blob_type, \
__export_parasite_cmd); \
ctl->addr_args = parasite_sym(ctl->local_map, blob_type, \
__export_parasite_args); \
} while (0)
struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
struct vm_area_list *vma_area_list) struct vm_area_list *vma_area_list)
{ {
int ret; int ret;
struct parasite_ctl *ctl; struct parasite_ctl *ctl;
unsigned long p, map_exchange_size; unsigned long p, map_exchange_size, parasite_size;
BUG_ON(item->threads[0].real != pid); BUG_ON(item->threads[0].real != pid);
...@@ -1378,9 +1392,18 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, ...@@ -1378,9 +1392,18 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
* without using ptrace at all. * without using ptrace at all.
*/ */
if (user_regs_native(&ctl->orig.regs))
parasite_size = pie_size(parasite_native);
#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
else
parasite_size = pie_size(parasite_compat);
#endif
ctl->args_size = round_up(parasite_args_size, PAGE_SIZE); ctl->args_size = round_up(parasite_args_size, PAGE_SIZE);
parasite_args_size = PARASITE_ARG_SIZE_MIN; /* reset for next task */ parasite_args_size = PARASITE_ARG_SIZE_MIN; /* reset for next task */
map_exchange_size = pie_size(parasite_native) + ctl->args_size; parasite_size += ctl->args_size;
map_exchange_size = parasite_size;
map_exchange_size += RESTORE_STACK_SIGFRAME + PARASITE_STACK_SIZE; map_exchange_size += RESTORE_STACK_SIGFRAME + PARASITE_STACK_SIZE;
if (item->nr_threads > 1) if (item->nr_threads > 1)
map_exchange_size += PARASITE_STACK_SIZE; map_exchange_size += PARASITE_STACK_SIZE;
...@@ -1392,16 +1415,15 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, ...@@ -1392,16 +1415,15 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
goto err_restore; goto err_restore;
pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map); pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
memcpy(ctl->local_map, parasite_native_blob, sizeof(parasite_native_blob));
ELF_RELOCS_APPLY(parasite_native, ctl->local_map, ctl->remote_map);
/* Setup the rest of a control block */ if (user_regs_native(&ctl->orig.regs))
ctl->parasite_ip = (unsigned long)parasite_sym(ctl->remote_map, native, __export_parasite_head_start); init_parasite_ctl(ctl, native);
ctl->addr_cmd = parasite_sym(ctl->local_map, native, __export_parasite_cmd); #ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
ctl->addr_args = parasite_sym(ctl->local_map, native, __export_parasite_args); else
init_parasite_ctl(ctl, compat);
#endif
p = pie_size(parasite_native) + ctl->args_size; p = parasite_size;
ctl->rsigframe = ctl->remote_map + p; ctl->rsigframe = ctl->remote_map + p;
ctl->sigframe = ctl->local_map + p; ctl->sigframe = ctl->local_map + p;
......
#include "parasite-native-blob.h" #include "parasite-native-blob.h"
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
/* FIXME: parasite_compat_blob defined but not used */ # include "parasite-compat-blob.h"
/* # include "parasite-compat-blob.h"*/
#endif #endif
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size, extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size,
elf_reloc_t *elf_relocs, size_t nr_relocs); elf_reloc_t *elf_relocs, size_t nr_relocs);
/* FIXME: native/compat pie's pie_size(), ELF_RELOCS_APPLY() */
#define pie_size(__pie_name) (round_up(sizeof(__pie_name##_blob) + \ #define pie_size(__pie_name) (round_up(sizeof(__pie_name##_blob) + \
__pie_name ## _nr_gotpcrel * sizeof(long), page_size())) __pie_name ## _nr_gotpcrel * sizeof(long), page_size()))
#define ELF_RELOCS_APPLY(__pie_name, __mem, __vbase) \ #define ELF_RELOCS_APPLY(__pie_name, __mem, __vbase) \
......
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