2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 18:07:57 +00:00

criu/pie/restorer: add madvise(MADV_GUARD_INSTALL) restore logic

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
This commit is contained in:
Alexander Mikhalitsyn 2025-04-06 20:10:10 +02:00 committed by Radostin Stoyanov
parent 556d1c4406
commit f091422ad6

View File

@ -28,6 +28,7 @@
#include <compel/plugins/std/syscall.h> #include <compel/plugins/std/syscall.h>
#include <compel/plugins/std/log.h> #include <compel/plugins/std/log.h>
#include <compel/ksigset.h> #include <compel/ksigset.h>
#include "mman.h"
#include "signal.h" #include "signal.h"
#include "prctl.h" #include "prctl.h"
#include "criu-log.h" #include "criu-log.h"
@ -1665,6 +1666,30 @@ static int restore_membarrier_registrations(int mask)
return ret; return ret;
} }
static int restore_madv_guard_regions(struct task_restore_args *args)
{
int i, ret;
for (i = 0; i < args->vmas_n; i++) {
VmaEntry *vma_entry = args->vmas + i;
size_t len;
if (!vma_entry_is(vma_entry, VMA_AREA_GUARD))
continue;
len = vma_entry->end - vma_entry->start;
ret = sys_madvise(vma_entry->start, len, MADV_GUARD_INSTALL);
if (ret) {
pr_err("madvise(%" PRIx64 ", %zu, MADV_GUARD_INSTALL) "
"failed with %d\n",
vma_entry->start, len, ret);
return -1;
}
}
return 0;
}
/* /*
* The main routine to restore task via sigreturn. * The main routine to restore task via sigreturn.
* This one is very special, we never return there * This one is very special, we never return there
@ -1972,6 +1997,13 @@ __visible long __export_restore_task(struct task_restore_args *args)
} }
} }
/*
* Restore madvise(MADV_GUARD_INSTALL)
*/
ret = restore_madv_guard_regions(args);
if (ret)
goto core_restore_end;
/* /*
* Tune up the task fields. * Tune up the task fields.
*/ */