Commit b752e05e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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=2505Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 90fbbabb
...@@ -47,6 +47,13 @@ void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs) ...@@ -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; 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, int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
unsigned long arg1, unsigned long arg1,
......
...@@ -45,6 +45,28 @@ void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs) ...@@ -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); 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, int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
unsigned long arg1, unsigned long arg1,
unsigned long arg2, unsigned long arg2,
......
...@@ -71,5 +71,6 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, ...@@ -71,5 +71,6 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
unsigned long arg6); unsigned long arg6);
extern int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs); 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__ */ #endif /* __CR_PARASITE_SYSCALL_H__ */
...@@ -713,6 +713,11 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct list_head *vma_area_lis ...@@ -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 parasite_ctl *ctl = NULL;
struct vma_area *vma_area; 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. * Control block early setup.
*/ */
......
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