mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 17:49:13 +00:00
dump: Obtain task brk via misc dump command
Right now we do syscall_seized for this, but we have the misc dumping command and the core is (after patch #3) dump after parasite, so we can get brk from the misc dump, thus avoiding one more switch to parasite. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
parent
583a7fe8c3
commit
c56574b411
6 changed files with 11 additions and 35 deletions
13
cr-dump.c
13
cr-dump.c
|
|
@ -665,7 +665,7 @@ static int dump_task_core(struct core_entry *core, struct cr_fdset *fdset)
|
|||
}
|
||||
|
||||
static int dump_task_core_all(pid_t pid, int pid_dir, struct proc_pid_stat *stat,
|
||||
struct cr_fdset *cr_fdset)
|
||||
struct parasite_dump_misc *misc, struct cr_fdset *cr_fdset)
|
||||
{
|
||||
struct core_entry *core = xzalloc(sizeof(*core));
|
||||
int ret = -1;
|
||||
|
|
@ -704,6 +704,8 @@ static int dump_task_core_all(pid_t pid, int pid_dir, struct proc_pid_stat *stat
|
|||
core->tc.mm_env_start = stat->env_start;
|
||||
core->tc.mm_env_end = stat->env_end;
|
||||
|
||||
core->tc.mm_brk = misc->brk;
|
||||
|
||||
pr_info("Obtainting sigmask ... ");
|
||||
ret = get_task_sigmask(pid, pid_dir, &core->tc.blk_sigset);
|
||||
if (ret)
|
||||
|
|
@ -716,13 +718,6 @@ static int dump_task_core_all(pid_t pid, int pid_dir, struct proc_pid_stat *stat
|
|||
goto err_free;
|
||||
pr_info("OK\n");
|
||||
|
||||
pr_info("Obtainting task brk ... ");
|
||||
brk = brk_seized(pid, 0);
|
||||
if ((long)brk < 0)
|
||||
goto err_free;
|
||||
core->tc.mm_brk = brk;
|
||||
pr_info("OK\n");
|
||||
|
||||
core->tc.task_state = TASK_ALIVE;
|
||||
core->tc.exit_code = 0;
|
||||
|
||||
|
|
@ -1254,7 +1249,7 @@ static int dump_one_task(struct pstree_item *item, struct cr_fdset *cr_fdset)
|
|||
goto err;
|
||||
}
|
||||
|
||||
ret = dump_task_core_all(pid, pid_dir, &pps_buf, cr_fdset);
|
||||
ret = dump_task_core_all(pid, pid_dir, &pps_buf, &misc, cr_fdset);
|
||||
if (ret) {
|
||||
pr_err("Dump core (pid: %d) failed with %d\n", pid, ret);
|
||||
goto err;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ extern void *mmap_seized(pid_t pid, user_regs_struct_t *regs,
|
|||
|
||||
extern int munmap_seized(pid_t pid, user_regs_struct_t *regs,
|
||||
void *addr, size_t length);
|
||||
extern unsigned long brk_seized(pid_t pid, unsigned long addr);
|
||||
|
||||
extern int syscall_seized(pid_t pid,
|
||||
user_regs_struct_t *where,
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ struct parasite_dump_pages_args {
|
|||
struct parasite_dump_misc {
|
||||
parasite_status_t status;
|
||||
unsigned int secbits;
|
||||
unsigned long brk;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -258,6 +258,11 @@ static always_inline long sys_prctl(int code, unsigned long arg2, unsigned long
|
|||
return syscall5(__NR_prctl, code, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
static always_inline long sys_brk(unsigned long arg)
|
||||
{
|
||||
return syscall1(__NR_brk, arg);
|
||||
}
|
||||
|
||||
static always_inline long sys_clone(unsigned long flags, void *child_stack,
|
||||
void *parent_tid, void *child_tid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,31 +92,6 @@ int munmap_seized(pid_t pid, user_regs_struct_t *regs,
|
|||
return ret;
|
||||
}
|
||||
|
||||
unsigned long brk_seized(pid_t pid, unsigned long addr)
|
||||
{
|
||||
user_regs_struct_t params, regs_orig;
|
||||
unsigned long ret = -1UL;
|
||||
|
||||
jerr(ptrace(PTRACE_GETREGS, pid, NULL, ®s_orig), err);
|
||||
params = regs_orig;
|
||||
|
||||
params.ax = (unsigned long)__NR_brk; /* brk */
|
||||
params.di = (unsigned long)addr; /* @addr */
|
||||
|
||||
ret = syscall_seized(pid, ®s_orig, ¶ms, ¶ms);
|
||||
if (!ret)
|
||||
ret = (unsigned long)params.ax;
|
||||
else
|
||||
ret = -1UL;
|
||||
|
||||
if (ptrace(PTRACE_SETREGS, pid, NULL, ®s_orig)) {
|
||||
pr_panic("Can't restore registers (pid: %d)\n", pid);
|
||||
ret = -1UL;
|
||||
}
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int syscall_seized(pid_t pid,
|
||||
user_regs_struct_t *where,
|
||||
user_regs_struct_t *params,
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ static int dump_misc(struct parasite_dump_misc *args)
|
|||
parasite_status_t *st = &args->status;
|
||||
|
||||
args->secbits = sys_prctl(PR_GET_SECUREBITS, 0, 0, 0, 0);
|
||||
args->brk = sys_brk(0);
|
||||
|
||||
SET_PARASITE_STATUS(st, 0, 0);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue