[CRIU] [PATCHv2 3/2] cr-check: add userns/loginuid checks to extra features
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Jan 10 06:32:07 PST 2017
All kernel options, features that depend on kernel version
should be checked with `criu check`.
Cc: Pavel Emelyanov <xemul at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/cr-check.c | 68 +++++++++++++++++++++++++++++----------------------------
1 file changed, 35 insertions(+), 33 deletions(-)
diff --git a/criu/cr-check.c b/criu/cr-check.c
index 03ee1e9bc4b6..57cab6ff90ca 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -1044,6 +1044,39 @@ static int check_uffd(void)
return 0;
}
+static int check_userns(void)
+{
+ int ret;
+ unsigned long size = 0;
+
+ ret = access("/proc/self/ns/user", F_OK);
+ if (ret) {
+ pr_perror("No userns proc file");
+ return -1;
+ }
+
+ ret = prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
+ if (ret < 0) {
+ pr_perror("prctl: PR_SET_MM_MAP_SIZE is not supported");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int check_loginuid(void)
+{
+ if (kerndat_loginuid(false) < 0)
+ return -1;
+
+ if (!kdat.has_loginuid) {
+ pr_warn("Loginuid restore is OFF.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static int check_compat_cr(void)
{
if (kdat_compat_sigreturn_test())
@@ -1153,6 +1186,8 @@ int cr_check(void)
ret |= check_cgroupns();
ret |= check_tcp_window();
ret |= check_tcp_halt_closed();
+ ret |= check_userns();
+ ret |= check_loginuid();
}
/*
@@ -1183,39 +1218,6 @@ static int check_tun(void)
return check_tun_cr(-1);
}
-static int check_userns(void)
-{
- int ret;
- unsigned long size = 0;
-
- ret = access("/proc/self/ns/user", F_OK);
- if (ret) {
- pr_perror("No userns proc file");
- return -1;
- }
-
- ret = prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
- if (ret < 0) {
- pr_perror("prctl: PR_SET_MM_MAP_SIZE is not supported");
- return -1;
- }
-
- return 0;
-}
-
-static int check_loginuid(void)
-{
- if (kerndat_loginuid(false) < 0)
- return -1;
-
- if (!kdat.has_loginuid) {
- pr_warn("Loginuid restore is OFF.\n");
- return -1;
- }
-
- return 0;
-}
-
struct feature_list {
char *name;
int (*func)();
--
2.11.0
More information about the CRIU
mailing list