diff options
author | Cyrill Gorcunov <gorcunov@openvz.org> | 2017-02-20 11:33:42 +0300 |
---|---|---|
committer | Pavel Emelyanov <xemul@virtuozzo.com> | 2017-04-02 18:09:34 +0300 |
commit | 6e4d05853d75d4e8a5cb41381eeb266ba62249e6 (patch) | |
tree | 7a187e0f1f6de01f31ed24d77cd954ef403a65e0 /compel/arch | |
parent | e5de8986675a1870498742591be0b3cbcc2829b1 (diff) |
compel: infect -- Don't forget to fetch sas early
When infecting victim we construct sigframe to
be able to self-rectore it in case if something
goes wrong. But in case is a targer been using
alternative stack for signal handling it will
be missed in sigframe since we don't fetch it.
Thus add fetching sas on infection stage and
put it into signal frame early.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Diffstat (limited to 'compel/arch')
-rw-r--r-- | compel/arch/aarch64/src/lib/infect.c | 11 | ||||
-rw-r--r-- | compel/arch/arm/src/lib/infect.c | 11 | ||||
-rw-r--r-- | compel/arch/ppc64/src/lib/infect.c | 11 | ||||
-rw-r--r-- | compel/arch/x86/src/lib/infect.c | 15 |
4 files changed, 48 insertions, 0 deletions
diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c index 41600e091..166ec2363 100644 --- a/compel/arch/aarch64/src/lib/infect.c +++ b/compel/arch/aarch64/src/lib/infect.c @@ -140,6 +140,17 @@ bool arch_can_dump_task(struct parasite_ctl *ctl) return true; } +int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s) +{ + long ret; + int err; + + err = compel_syscall(ctl, __NR_sigaltstack, + &ret, 0, (unsigned long)&s->uc.uc_stack, + 0, 0, 0, 0); + return err ? err : ret; +} + /* * Range for task size calculated from the following Linux kernel files: * arch/arm64/include/asm/memory.h diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c index a78108dff..27d258bc3 100644 --- a/compel/arch/arm/src/lib/infect.c +++ b/compel/arch/arm/src/lib/infect.c @@ -160,6 +160,17 @@ bool arch_can_dump_task(struct parasite_ctl *ctl) return true; } +int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s) +{ + long ret; + int err; + + err = compel_syscall(ctl, __NR_sigaltstack, + &ret, 0, (unsigned long)&s->sig.uc.uc_stack, + 0, 0, 0, 0); + return err ? err : ret; +} + /* * Range for task size calculated from the following Linux kernel files: * arch/arm/include/asm/memory.h diff --git a/compel/arch/ppc64/src/lib/infect.c b/compel/arch/ppc64/src/lib/infect.c index f3f1aacec..32175174b 100644 --- a/compel/arch/ppc64/src/lib/infect.c +++ b/compel/arch/ppc64/src/lib/infect.c @@ -442,6 +442,17 @@ bool arch_can_dump_task(struct parasite_ctl *ctl) return true; } +int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s) +{ + long ret; + int err; + + err = compel_syscall(ctl, __NR_sigaltstack, + &ret, 0, (unsigned long)&s->uc.uc_stack, + 0, 0, 0, 0); + return err ? err : ret; +} + /* * Copied for the Linux kernel arch/powerpc/include/asm/processor.h * diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c index 84ff21b15..23a96df86 100644 --- a/compel/arch/x86/src/lib/infect.c +++ b/compel/arch/x86/src/lib/infect.c @@ -419,6 +419,21 @@ bool arch_can_dump_task(struct parasite_ctl *ctl) return true; } +int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s) +{ + int native = compel_mode_native(ctl); + void *where = native ? + (void *)&s->native.uc.uc_stack : + (void *)&s->compat.uc.uc_stack; + long ret; + int err; + + err = compel_syscall(ctl, __NR(sigaltstack, !native), + &ret, 0, (unsigned long)where, + 0, 0, 0, 0); + return err ? err : ret; +} + /* Copied from the gdb header gdb/nat/x86-dregs.h */ /* Debug registers' indices. */ |