Commit 27243759 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

infect: Make parasite_ctl private

This structure will be internal to compel. Users will only see
one as opaque pointer and read data from it using calls.

Exception for now -- infect_ictx. This is a configuration structure
that will be embeded into ctl and seen outside.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 7d3e7b05
......@@ -17,7 +17,7 @@
#include "util.h"
#include "cpu.h"
#include "restorer.h"
#include "infect-priv.h"
/*
* Injected syscall instruction
......
......@@ -18,7 +18,7 @@
#include "restorer.h"
#include "errno.h"
#include "kerndat.h"
#include "infect-priv.h"
/*
* Injected syscall instruction
......
......@@ -18,6 +18,7 @@
#include "util.h"
#include "cpu.h"
#include "errno.h"
#include "infect-priv.h"
#include "protobuf.h"
#include "images/core.pb-c.h"
......
......@@ -24,6 +24,7 @@
#include "errno.h"
#include "uapi/std/syscall-codes.h"
#include "kerndat.h"
#include "infect-priv.h"
#include "protobuf.h"
#include "images/core.pb-c.h"
......
......@@ -13,6 +13,7 @@
#include "util.h"
#include "kerndat.h"
#include "infect.h"
#include "infect-priv.h"
struct syscall_exec_desc {
char *name;
......
#ifndef __COMPEL_INFECT_PRIV_H__
#define __COMPEL_INFECT_PRIV_H__
#include <stdbool.h>
/* parasite control block */
struct parasite_ctl {
int rpid; /* Real pid of the victim */
void *remote_map;
void *local_map;
void *sigreturn_addr; /* A place for the breakpoint */
unsigned long map_length;
struct infect_ctx ictx;
/* thread leader data */
bool daemonized;
struct thread_ctx orig;
void *rstack; /* thread leader stack*/
struct rt_sigframe *sigframe;
struct rt_sigframe *rsigframe; /* address in a parasite */
void *r_thread_stack; /* stack for non-leader threads */
unsigned long parasite_ip; /* service routine start ip */
unsigned int *addr_cmd; /* addr for command */
void *addr_args; /* address for arguments */
unsigned long args_size;
int tsock; /* transport socket for transferring fds */
};
#endif
......@@ -46,34 +46,7 @@ struct infect_ctx {
#define INFECT_NO_MEMFD 0x1 /* don't use memfd() */
#define INFECT_FAIL_CONNECT 0x2 /* make parasite connect() fail */
/* parasite control block */
struct parasite_ctl {
int rpid; /* Real pid of the victim */
void *remote_map;
void *local_map;
void *sigreturn_addr; /* A place for the breakpoint */
unsigned long map_length;
struct infect_ctx ictx;
/* thread leader data */
bool daemonized;
struct thread_ctx orig;
void *rstack; /* thread leader stack*/
struct rt_sigframe *sigframe;
struct rt_sigframe *rsigframe; /* address in a parasite */
void *r_thread_stack; /* stack for non-leader threads */
unsigned long parasite_ip; /* service routine start ip */
unsigned int *addr_cmd; /* addr for command */
void *addr_args; /* address for arguments */
unsigned long args_size;
int tsock; /* transport socket for transferring fds */
};
struct parasite_ctl;
extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_imgset);
extern int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *);
......@@ -84,10 +57,13 @@ extern int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc
#define parasite_args(ctl, type) \
({ \
void *___ret; \
BUILD_BUG_ON(sizeof(type) > PARASITE_ARG_SIZE_MIN); \
ctl->addr_args; \
___ret = parasite_args_p(ctl); \
___ret; \
})
extern void *parasite_args_p(struct parasite_ctl *ctl);
extern void *parasite_args_s(struct parasite_ctl *ctl, int args_size);
extern int parasite_send_fd(struct parasite_ctl *ctl, int fd);
......
......@@ -6,8 +6,11 @@
#include <signal.h>
#include <linux/seccomp.h>
#include "parasite-syscall.h"
#include "log.h"
#include "infect.h"
#include "infect-priv.h"
#define PTRACE_EVENT_STOP 128
......
......@@ -42,6 +42,8 @@
#include "restorer.h"
#include "pie/pie-relocs.h"
#include "infect-priv.h"
#define MEMFD_FNAME "CRIUMFD"
#define MEMFD_FNAME_SZ sizeof(MEMFD_FNAME)
......@@ -243,10 +245,15 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl,
return err;
}
void *parasite_args_p(struct parasite_ctl *ctl)
{
return ctl->addr_args;
}
void *parasite_args_s(struct parasite_ctl *ctl, int args_size)
{
BUG_ON(args_size > ctl->args_size);
return ctl->addr_args;
return parasite_args_p(ctl);
}
static int parasite_run_in_thread(pid_t pid, unsigned int cmd,
......
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