mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
dump: Make sure we're dumping task not running in compat mode
It's been reported that we do not test if the tracee is 32bit task running kn 64bit kernel. This patch adds such test. https://bugzilla.openvz.org/show_bug.cgi?id=2505 Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
90fbbabb34
commit
b752e05e41
@@ -47,6 +47,13 @@ void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs)
|
||||
regs->ARM_cpsr &= PSR_f | PSR_s | PSR_x | PSR_T_BIT | MODE32_BIT;
|
||||
}
|
||||
|
||||
int task_in_compat_mode(pid_t pid)
|
||||
{
|
||||
/*
|
||||
* TODO: Add proper check here
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
|
||||
unsigned long arg1,
|
||||
|
@@ -45,6 +45,28 @@ void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs)
|
||||
regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF | X86_EFLAGS_IF);
|
||||
}
|
||||
|
||||
int task_in_compat_mode(pid_t pid)
|
||||
{
|
||||
unsigned long cs, ds;
|
||||
|
||||
errno = 0;
|
||||
cs = ptrace(PTRACE_PEEKUSER, pid, offsetof(user_regs_struct_t, cs), 0);
|
||||
if (errno != 0) {
|
||||
perror("Can't get CS register");
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
ds = ptrace(PTRACE_PEEKUSER, pid, offsetof(user_regs_struct_t, ds), 0);
|
||||
if (errno != 0) {
|
||||
perror("Can't get DS register");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* It's x86-32 or x32 */
|
||||
return cs != 0x33 || ds == 0x2b;
|
||||
}
|
||||
|
||||
int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
|
||||
unsigned long arg1,
|
||||
unsigned long arg2,
|
||||
|
@@ -71,5 +71,6 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
|
||||
unsigned long arg6);
|
||||
|
||||
extern int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs);
|
||||
extern int task_in_compat_mode(pid_t pid);
|
||||
|
||||
#endif /* __CR_PARASITE_SYSCALL_H__ */
|
||||
|
@@ -713,6 +713,11 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct list_head *vma_area_lis
|
||||
struct parasite_ctl *ctl = NULL;
|
||||
struct vma_area *vma_area;
|
||||
|
||||
if (task_in_compat_mode(pid)) {
|
||||
pr_err("Can't checkpoint task running in compat mode\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Control block early setup.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user