From b5dfd452cc9b5b33cb7b29f0cd608cf915522db4 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 27 Mar 2013 15:43:27 +0400 Subject: [PATCH] dump: Be more specific about inability to dump 32bit tasks on x86 Signed-off-by: Pavel Emelyanov --- arch/arm/crtools.c | 4 ++-- arch/x86/crtools.c | 12 +++++++++++- include/parasite-syscall.h | 2 +- parasite-syscall.c | 4 +--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/arm/crtools.c b/arch/arm/crtools.c index 61df24724..c41349cef 100644 --- a/arch/arm/crtools.c +++ b/arch/arm/crtools.c @@ -46,12 +46,12 @@ 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) +bool arch_can_dump_task(pid_t pid) { /* * TODO: Add proper check here */ - return 0; + return true; } int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c index bf1236ac2..9a4217e42 100644 --- a/arch/x86/crtools.c +++ b/arch/x86/crtools.c @@ -46,7 +46,7 @@ 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) +static int task_in_compat_mode(pid_t pid) { unsigned long cs, ds; @@ -68,6 +68,16 @@ int task_in_compat_mode(pid_t pid) return cs != 0x33 || ds == 0x2b; } +bool arch_can_dump_task(pid_t pid) +{ + if (task_in_compat_mode(pid)) { + pr_err("Can't dump task %d running in 32-bit mode\n", pid); + return false; + } + + return true; +} + int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, unsigned long arg1, unsigned long arg2, diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h index aba7559b4..696547058 100644 --- a/include/parasite-syscall.h +++ b/include/parasite-syscall.h @@ -74,6 +74,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); +extern bool arch_can_dump_task(pid_t pid); #endif /* __CR_PARASITE_SYSCALL_H__ */ diff --git a/parasite-syscall.c b/parasite-syscall.c index f88a8139b..c723bc8b5 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -767,10 +767,8 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_ 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"); + if (!arch_can_dump_task(pid)) goto err; - } /* * Control block early setup.