Commit 8a647a58 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

dump/restore: signals -- Use struct sa_entry for managing the signals

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9be40340
......@@ -1056,6 +1056,7 @@ static int prepare_sigactions(int pid)
int fd_sigact, ret;
int sig, i;
struct sigaction act, oact;
struct sa_entry e;
fd_sigact = open_fmt_ro(FMT_FNAME_SIGACTS, pid);
if (fd_sigact < 0) {
......@@ -1073,15 +1074,25 @@ static int prepare_sigactions(int pid)
if (sig == SIGKILL || sig == SIGSTOP)
continue;
ret = read(fd_sigact, &act, sizeof(act));
if (ret != sizeof(act)) {
ret = read(fd_sigact, &e, sizeof(e));
if (ret != sizeof(e)) {
pr_err("%d: Bad sigaction entry: %d (%m)\n", pid, ret);
ret = -1;
goto err;
}
/* A pure syscall is used, because a glibc
* sigaction overwrite se_restorer */
BUILD_BUG_ON(sizeof(e.mask) != sizeof(act.sa_mask));
act.sa_sigaction = (void *)(long)e.sigaction;
act.sa_flags = (int)e.flags;
act.sa_restorer = (void *)(long)e.restorer;
memcpy(&act.sa_mask, &e.mask, sizeof(act.sa_mask));
/*
* A pure syscall is used, because glibc
* sigaction overwrites se_restorer.
*/
ret = sys_sigaction(sig, &act, &oact);
if (ret == -1) {
pr_err("%d: Can't restore sigaction: %m\n", pid);
......
......@@ -227,6 +227,7 @@ static int dump_sigact(parasite_args_cmd_dumpsigacts_t *args)
{
parasite_status_t *st = &args->status;
struct sigaction act;
struct sa_entry e;
int fd, sig;
int ret = PARASITE_ERR_FAIL;
......@@ -253,8 +254,16 @@ static int dump_sigact(parasite_args_cmd_dumpsigacts_t *args)
goto err_close;
}
ret = sys_write(fd, &act, sizeof(act));
if (ret != sizeof(act)) {
BUILD_BUG_ON(sizeof(e.mask) != sizeof(act.sa_mask));
e.sigaction = (u64)act.sa_sigaction;
e.flags = (u32)act.sa_flags;
e.restorer = (u64)act.sa_restorer;
inline_memcpy(&e.mask, &act.sa_mask, sizeof(e.mask));
ret = sys_write(fd, &e, sizeof(e));
if (ret != sizeof(e)) {
sys_write_msg("sys_write failed\n");
SET_PARASITE_STATUS(st, PARASITE_ERR_WRITE, ret);
ret = st->ret;
......
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