lib/infect: Check if compel succeed in executing munmap

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Dmitry Safonov 2019-11-09 22:20:38 +00:00 committed by Andrei Vagin
parent ee449e27c6
commit 7173856578
2 changed files with 10 additions and 4 deletions

View file

@ -453,8 +453,10 @@ void *remote_mmap(struct parasite_ctl *ctl,
if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
pr_err("Can't restore mmap args (pid: %d)\n", pid);
if (map != 0) {
compel_syscall(ctl, __NR_munmap, NULL, map,
err = compel_syscall(ctl, __NR_munmap, NULL, map,
length, 0, 0, 0, 0);
if (err)
pr_err("Can't munmap %d\n", err);
map = 0;
}
}

View file

@ -1303,6 +1303,7 @@ int compel_stop_daemon(struct parasite_ctl *ctl)
int compel_cure_remote(struct parasite_ctl *ctl)
{
long ret;
int err;
if (compel_stop_daemon(ctl))
return -1;
@ -1310,9 +1311,12 @@ int compel_cure_remote(struct parasite_ctl *ctl)
if (!ctl->remote_map)
return 0;
compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
(unsigned long)ctl->remote_map, ctl->map_length,
0, 0, 0, 0);
err = compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
(unsigned long)ctl->remote_map, ctl->map_length,
0, 0, 0, 0);
if (err)
return err;
if (ret) {
pr_err("munmap for remote map %p, %lu returned %lu\n",
ctl->remote_map, ctl->map_length, ret);