[CRIU] [PATCH] parasite: Don't keep code_orig on parasite_ctl
Pavel Emelyanov
xemul at parallels.com
Tue Oct 14 06:54:43 PDT 2014
We need this only once -- while calling the mmap from remote
context -- so it's enough to have on-stack variable.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
include/parasite-syscall.h | 1 -
parasite-syscall.c | 9 +++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 67840fc..c4fb118 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -46,7 +46,6 @@ struct parasite_ctl {
unsigned long parasite_ip; /* service routine start ip */
unsigned long syscall_ip; /* entry point of infection */
- u8 code_orig[BUILTIN_SYSCALL_SIZE];
unsigned int *addr_cmd; /* addr for command */
void *addr_args; /* address for arguments */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 7cc1a84..41ae3c8 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -208,14 +208,15 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *reg
{
pid_t pid = ctl->pid.real;
int err;
+ u8 code_orig[BUILTIN_SYSCALL_SIZE];
/*
* Inject syscall instruction and remember original code,
* we will need it to restore original program content.
*/
- memcpy(ctl->code_orig, code_syscall, sizeof(ctl->code_orig));
+ memcpy(code_orig, code_syscall, sizeof(code_orig));
if (ptrace_swap_area(pid, (void *)ctl->syscall_ip,
- (void *)ctl->code_orig, sizeof(ctl->code_orig))) {
+ (void *)code_orig, sizeof(code_orig))) {
pr_err("Can't inject syscall blob (pid: %d)\n", pid);
return -1;
}
@@ -224,8 +225,8 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *reg
if (!err)
err = parasite_trap(ctl, pid, regs, &ctl->orig);
- if (ptrace_poke_area(pid, (void *)ctl->code_orig,
- (void *)ctl->syscall_ip, sizeof(ctl->code_orig))) {
+ if (ptrace_poke_area(pid, (void *)code_orig,
+ (void *)ctl->syscall_ip, sizeof(code_orig))) {
pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid.real);
err = -1;
}
--
1.8.4.2
More information about the CRIU
mailing list