Commit 68baf8e7 authored by Pavel Emelyanov's avatar Pavel Emelyanov

criu: Fault injection core

This patch(set) is inspired by similar from Andrey Vagin sent
sime time earlier.

The major idea is to artificially fail criu dump or restore at
specific places and let zdtm tests check whether failed dump
or restore resulted in anything bad.

This particular patch introduces the ability to tell criu "fail
at X point". Each point is specified with a integer constant
and with the next patches there will appear places over the
code checking for specific fail code being set and failing.

Two points are introduced -- early on dump, right after loading
the parasite and right after creation of the root task.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c405304f
......@@ -75,6 +75,7 @@ obj-y += plugin.o
obj-y += cr-errno.o
obj-y += pie/pie-relocs.o
obj-y += seize.o
obj-y += fault-injection.o
obj-y += pie/util-fd.o
obj-y += pie/util.o
......
......@@ -81,6 +81,7 @@
#include "lsm.h"
#include "seccomp.h"
#include "seize.h"
#include "fault-injection.h"
#include "asm/dump.h"
......@@ -1195,6 +1196,11 @@ static int dump_one_task(struct pstree_item *item)
goto err;
}
if (fault_injected(FI_DUMP_EARLY)) {
pr_info("fault: CRIU sudden detach\n");
BUG();
}
if (root_ns_mask & CLONE_NEWPID && root_item == item) {
int pfd;
......
......@@ -76,7 +76,7 @@
#include "security.h"
#include "lsm.h"
#include "seccomp.h"
#include "fault-injection.h"
#include "parasite-syscall.h"
#include "protobuf.h"
......@@ -1531,6 +1531,11 @@ static int restore_task_with_children(void *_arg)
if (prepare_sigactions() < 0)
goto err_fini_mnt;
if (fault_injected(FI_RESTORE_ROOT_ONLY)) {
pr_info("fault: Restore root task failure!\n");
BUG();
}
if (create_children_and_session())
goto err_fini_mnt;
......
......@@ -40,6 +40,7 @@
#include "action-scripts.h"
#include "security.h"
#include "irmap.h"
#include "fault-injection.h"
#include "setproctitle.h"
......@@ -257,6 +258,9 @@ int main(int argc, char *argv[], char *envp[])
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
if (fault_injection_init())
return 1;
cr_pb_init();
if (restrict_uid(getuid(), getgid()))
return 1;
......
#include <stdlib.h>
#include "fault-injection.h"
enum faults fi_strategy;
int fault_injection_init()
{
char *val;
int strat;
val = getenv("CRIU_FAULT");
if (val == NULL)
return 0;
strat = atoi(val);
if (strat <= 0 || strat >= FI_MAX)
return -1;
fi_strategy = strat;
return 0;
}
#ifndef __CR_FAULT_INJECTION_H__
#define __CR_FAULT_INJECTION_H__
#include <stdbool.h>
enum faults {
FI_NONE = 0,
FI_DUMP_EARLY,
FI_RESTORE_ROOT_ONLY,
FI_MAX,
};
extern enum faults fi_strategy;
extern int fault_injection_init(void);
static inline bool fault_injected(enum faults f)
{
return fi_strategy == f;
}
#endif
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