mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
cr-exec: add non-generated sys-exec-tbl for x86
Impact: search sys-exec-tbl-32.c for compatible tasks. Rename task_in_compat_mode to arch_task_compatible and use it in find_syscall for 64-bit to check compatible task's syscall nr. It still will not execute syscall in 32-tasks, as we still do not have 32-bit pie (arch_can_dump_task will return false for these tasks). NOTE: be sure to `make mrproper` on criu directory before applying this patch, as before `criu/arch/x86/sys-exec-tbl.c` was autogenerated, it will make conflict if you try to apply this patch on dirty directory. Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
bbc2f1331f
commit
bc5cca1a29
5 changed files with 59 additions and 22 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -24,6 +24,8 @@ images/google/protobuf/*.h
|
|||
.gitid
|
||||
criu/criu
|
||||
criu/arch/*/sys-exec-tbl*.c
|
||||
# x86 syscalls-table is not generated
|
||||
!criu/arch/x86/sys-exec-tbl.c
|
||||
criu/arch/*/syscalls*.S
|
||||
criu/include/config.h
|
||||
criu/include/syscall-codes*.h
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ CFLAGS := $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
|
|||
CFLAGS := $(filter-out -DCONFIG_X86_64,$(CFLAGS))
|
||||
|
||||
SYS-PROTO-GENERIC := $(obj)/../../include/syscall.h
|
||||
SYS-EXEC-TBL-GENERIC := sys-exec-tbl.c
|
||||
|
||||
SYS-CODES-GENERIC = $(obj)/../../include/syscall-codes.h
|
||||
SYS-CODES = $(obj)/../../include/syscall-codes-$(1).h
|
||||
|
|
@ -155,23 +154,6 @@ $(SYS-PROTO-GENERIC): $(strip $(call map,SYS-PROTO,$(SYS-BITS)))
|
|||
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
|
||||
mrproper-y += $(SYS-PROTO-GENERIC)
|
||||
|
||||
$(obj)/$(SYS-EXEC-TBL-GENERIC):
|
||||
$(Q) echo "/* Autogenerated, don't edit */" > $@
|
||||
$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {" >> $@
|
||||
ifeq ($(ARCH),x86)
|
||||
$(Q) echo '#include "sys-exec-tbl-64.c"' >> $@
|
||||
$(Q) echo " { }, /* terminator */" >> $@
|
||||
$(Q) echo "};" >> $@
|
||||
$(Q) echo "" >> $@
|
||||
# FIXME: uncomment to support 32-bit task
|
||||
# $(Q) echo "static struct syscall_exec_desc sc_exec_table_32[] = {" >> $@
|
||||
endif
|
||||
# $(Q) echo '#include "sys-exec-tbl-32.c"' >> $@
|
||||
# $(Q) echo " { }, /* terminator */" >> $@
|
||||
# $(Q) echo "};" >> $@
|
||||
mrproper-y += $(obj)/$(SYS-EXEC-TBL-GENERIC)
|
||||
all-y += $(obj)/$(SYS-EXEC-TBL-GENERIC)
|
||||
|
||||
$(eval $(call map,gen-rule-sys-codes,$(SYS-BITS)))
|
||||
$(eval $(call map,gen-rule-sys-proto,$(SYS-BITS)))
|
||||
$(eval $(call map,gen-rule-sys-asm,$(SYS-BITS)))
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *
|
|||
regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF | X86_EFLAGS_IF);
|
||||
}
|
||||
|
||||
static int task_in_compat_mode(pid_t pid)
|
||||
int arch_task_compatible(pid_t pid)
|
||||
{
|
||||
unsigned long cs, ds;
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
|
|||
{
|
||||
pid_t pid = ctl->rpid;
|
||||
|
||||
if (task_in_compat_mode(pid)) {
|
||||
if (arch_task_compatible(pid)) {
|
||||
pr_err("Can't dump task %d running in 32-bit mode\n", pid);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
50
criu/arch/x86/sys-exec-tbl.c
Normal file
50
criu/arch/x86/sys-exec-tbl.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
#ifdef CONFIG_X86_64
|
||||
static struct syscall_exec_desc sc_exec_table_64[] = {
|
||||
#include "sys-exec-tbl-64.c"
|
||||
{ }, /* terminator */
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct syscall_exec_desc sc_exec_table_32[] = {
|
||||
#include "sys-exec-tbl-32.c"
|
||||
{ }, /* terminator */
|
||||
};
|
||||
|
||||
struct syscall_exec_desc;
|
||||
|
||||
static inline struct syscall_exec_desc *
|
||||
find_syscall_table(char *name, struct syscall_exec_desc *tbl)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; tbl[i].name != NULL; i++)
|
||||
if (!strcmp(tbl[i].name, name))
|
||||
return &tbl[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) arch_task_compatible(pid_t pid) { return false; }
|
||||
#define ARCH_HAS_FIND_SYSCALL
|
||||
/* overwrite default to search in two tables above */
|
||||
#ifdef CONFIG_X86_64
|
||||
struct syscall_exec_desc * find_syscall(char *name, int pid)
|
||||
{
|
||||
int err = arch_task_compatible(pid);
|
||||
|
||||
switch(err) {
|
||||
case 0:
|
||||
return find_syscall_table(name, sc_exec_table_64);
|
||||
case 1:
|
||||
return find_syscall_table(name, sc_exec_table_32);
|
||||
default: /* Error */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
struct syscall_exec_desc *
|
||||
find_syscall(char *name, __attribute__((unused)) int pid)
|
||||
{
|
||||
return find_syscall_table(name, sc_exec_table_32);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -21,7 +21,9 @@ struct syscall_exec_desc {
|
|||
#include "sys-exec-tbl.c"
|
||||
#undef SYSCALL
|
||||
|
||||
static struct syscall_exec_desc *find_syscall(char *name)
|
||||
#ifndef ARCH_HAS_FIND_SYSCALL
|
||||
struct syscall_exec_desc *
|
||||
find_syscall(char *name, int __attribute__((unused)) pid)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -31,6 +33,7 @@ static struct syscall_exec_desc *find_syscall(char *name)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MAX_ARGS 6
|
||||
|
||||
|
|
@ -132,7 +135,7 @@ int cr_exec(int pid, char **opt)
|
|||
goto out;
|
||||
}
|
||||
|
||||
si = find_syscall(sys_name);
|
||||
si = find_syscall(sys_name, pid);
|
||||
if (!si) {
|
||||
pr_err("Unknown syscall [%s]\n", sys_name);
|
||||
goto out;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue