Commit fb9b0f50 authored by Pavel Emelyanov's avatar Pavel Emelyanov

parasite: Use struct pid on parasite_ctl

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 69db54d8
......@@ -74,7 +74,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.ARM_r5 = arg6;
parasite_setup_regs(ctl->syscall_ip, &regs);
err = __parasite_execute(ctl, ctl->pid, &regs);
err = __parasite_execute(ctl, ctl->pid.real, &regs);
if (err)
return err;
......
......@@ -98,7 +98,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.r9 = arg6;
parasite_setup_regs(ctl->syscall_ip, &regs);
err = __parasite_execute(ctl, ctl->pid, &regs);
err = __parasite_execute(ctl, ctl->pid.real, &regs);
if (err)
return err;
......
......@@ -393,10 +393,10 @@ static int dump_task_creds(struct parasite_ctl *ctl, const struct cr_fdset *fds)
CredsEntry ce = CREDS_ENTRY__INIT;
pr_info("\n");
pr_info("Dumping creds for %d)\n", ctl->pid);
pr_info("Dumping creds for %d)\n", ctl->pid.real);
pr_info("----------------------------------------\n");
ret = parse_pid_status(ctl->pid, &cr);
ret = parse_pid_status(ctl->pid.real, &cr);
if (ret < 0)
return ret;
......
......@@ -117,7 +117,7 @@ int dump_task_file_locks(struct parasite_ctl *ctl,
FileLockEntry fle;
struct file_lock *fl;
pid_t pid = ctl->pid;
pid_t pid = ctl->pid.real;
int ret = 0;
list_for_each_entry(fl, &file_lock_list, list) {
......
......@@ -154,13 +154,13 @@ static int fill_fd_params(struct parasite_ctl *ctl, int fd, int lfd,
return -1;
}
p->flags = ret;
p->pid = ctl->pid;
p->pid = ctl->pid.real;
p->fd_flags = opts->flags;
fown_entry__init(&p->fown);
pr_info("%d fdinfo %d: pos: 0x%16lx flags: %16o/%#x\n",
ctl->pid, fd, p->pos, p->flags, (int)p->fd_flags);
ctl->pid.real, fd, p->pos, p->flags, (int)p->fd_flags);
ret = fcntl(lfd, F_GETSIG, 0);
if (ret < 0) {
......@@ -265,7 +265,7 @@ int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item,
int i, ret = -1;
pr_info("\n");
pr_info("Dumping opened files (pid: %d)\n", ctl->pid);
pr_info("Dumping opened files (pid: %d)\n", ctl->pid.real);
pr_info("----------------------------------------\n");
lfds = xmalloc(dfds->nr_fds * sizeof(int));
......
......@@ -3,9 +3,11 @@
#define BUILTIN_SYSCALL_SIZE 8
#include "pstree.h"
/* parasite control block */
struct parasite_ctl {
pid_t pid; /* process pid where we live in */
struct pid pid;
void *remote_map;
void *local_map;
unsigned long map_length;
......
......@@ -111,7 +111,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl, int vpid,
struct page_xfer xfer;
pr_info("\n");
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid);
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid.real);
pr_info("----------------------------------------\n");
pr_debug(" Private vmas %lu/%lu pages\n",
......@@ -123,7 +123,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl, int vpid,
if (!map)
goto out;
ret = pagemap = open_proc(ctl->pid, "pagemap");
ret = pagemap = open_proc(ctl->pid.real, "pagemap");
if (ret < 0)
goto out_free;
......
......@@ -200,7 +200,7 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
int ret;
user_regs_struct_t regs_orig, regs;
if (ctl->pid == pid)
if (ctl->pid.real == pid)
regs = ctl->regs_orig;
else {
if (ptrace(PTRACE_GETREGS, pid, NULL, &regs_orig)) {
......@@ -221,7 +221,7 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
if (ret)
pr_err("Parasite exited with %d\n", ret);
if (ctl->pid != pid)
if (ctl->pid.real != pid)
if (ptrace(PTRACE_SETREGS, pid, NULL, &regs_orig)) {
pr_perror("Can't restore registers (pid: %d)", pid);
return -1;
......@@ -232,7 +232,7 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
int parasite_execute(unsigned int cmd, struct parasite_ctl *ctl)
{
return parasite_execute_by_pid(cmd, ctl, ctl->pid);
return parasite_execute_by_pid(cmd, ctl, ctl->pid.real);
}
static int munmap_seized(struct parasite_ctl *ctl, void *addr, size_t length)
......@@ -601,26 +601,26 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item)
if (ctl->remote_map) {
if (munmap_seized(ctl, (void *)ctl->remote_map, ctl->map_length)) {
pr_err("munmap_seized failed (pid: %d)\n", ctl->pid);
pr_err("munmap_seized failed (pid: %d)\n", ctl->pid.real);
ret = -1;
}
}
if (ctl->local_map) {
if (munmap(ctl->local_map, ctl->map_length)) {
pr_err("munmap failed (pid: %d)\n", ctl->pid);
pr_err("munmap failed (pid: %d)\n", ctl->pid.real);
ret = -1;
}
}
if (ptrace_poke_area(ctl->pid, (void *)ctl->code_orig,
if (ptrace_poke_area(ctl->pid.real, (void *)ctl->code_orig,
(void *)ctl->syscall_ip, sizeof(ctl->code_orig))) {
pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid);
pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid.real);
ret = -1;
}
if (ptrace(PTRACE_SETREGS, ctl->pid, NULL, &ctl->regs_orig)) {
pr_err("Can't restore registers (pid: %d)\n", ctl->pid);
if (ptrace(PTRACE_SETREGS, ctl->pid.real, NULL, &ctl->regs_orig)) {
pr_err("Can't restore registers (pid: %d)\n", ctl->pid.real);
ret = -1;
}
......@@ -659,7 +659,8 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
goto err;
}
ctl->pid = pid;
ctl->pid.real = pid;
ctl->pid.virt = 0;
ctl->syscall_ip = vma_area->vma.start;
/*
......@@ -667,7 +668,7 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
* we will need it to restore original program content.
*/
memcpy(ctl->code_orig, code_syscall, sizeof(ctl->code_orig));
if (ptrace_swap_area(ctl->pid, (void *)ctl->syscall_ip,
if (ptrace_swap_area(pid, (void *)ctl->syscall_ip,
(void *)ctl->code_orig, sizeof(ctl->code_orig))) {
pr_err("Can't inject syscall blob (pid: %d)\n", pid);
goto err;
......@@ -688,13 +689,13 @@ int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size)
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_SHARED, -1, 0);
if (!ctl->remote_map) {
pr_err("Can't allocate memory for parasite blob (pid: %d)\n", ctl->pid);
pr_err("Can't allocate memory for parasite blob (pid: %d)\n", ctl->pid.real);
return -1;
}
ctl->map_length = round_up(size, PAGE_SIZE);
fd = open_proc_rw(ctl->pid, "map_files/%p-%p",
fd = open_proc_rw(ctl->pid.real, "map_files/%p-%p",
ctl->remote_map, ctl->remote_map + ctl->map_length);
if (fd < 0)
return -1;
......
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