[CRIU] [PATCH 02/12] kerndat: Reshuffle loginuid a bit
Pavel Emelyanov
xemul at virtuozzo.com
Mon Apr 24 13:06:57 PDT 2017
Add separate check for readability of loginuids.
And split routines a little bit.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-check.c | 20 +++++++++++++++++---
criu/include/kerndat.h | 2 +-
criu/kerndat.c | 30 +++++++++++++++++++-----------
3 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/criu/cr-check.c b/criu/cr-check.c
index c5fba9c..fbd566e 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -1045,10 +1045,10 @@ static int check_userns(void)
static int check_loginuid(void)
{
- if (kerndat_loginuid(false) < 0)
- return -1;
+ int ret;
- if (!kdat.has_loginuid) {
+ ret = check_loginuid_op(true);
+ if (ret != 1) {
pr_warn("Loginuid restore is OFF.\n");
return -1;
}
@@ -1056,6 +1056,19 @@ static int check_loginuid(void)
return 0;
}
+static int check_loginuid_r(void)
+{
+ int ret;
+
+ ret = check_loginuid_op(false);
+ if (ret != 1) {
+ pr_warn("Loginuid dump is OFF.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static int check_compat_cr(void)
{
#ifdef CONFIG_COMPAT
@@ -1273,6 +1286,7 @@ static struct feature_list feature_list[] = {
{ "seccomp_suspend", check_ptrace_suspend_seccomp },
{ "seccomp_filters", check_ptrace_dump_seccomp_filters },
{ "loginuid", check_loginuid },
+ { "loginuid_r", check_loginuid_r },
{ "cgroupns", check_cgroupns },
{ "autofs", check_autofs },
{ "tcp_half_closed", check_tcp_half_closed },
diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
index 722fad3..ab76e25 100644
--- a/criu/include/kerndat.h
+++ b/criu/include/kerndat.h
@@ -14,7 +14,7 @@ extern int kerndat_init(void);
extern int kerndat_init_rst(void);
extern int kerndat_get_dirty_track(void);
extern int kerndat_fdinfo_has_lock(void);
-extern int kerndat_loginuid(bool only_dump);
+extern int check_loginuid_op(bool full);
enum pagemap_func {
PM_UNKNOWN,
diff --git a/criu/kerndat.c b/criu/kerndat.c
index cd7bc7d..951b09a 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -444,22 +444,18 @@ static int get_ipv6()
return 0;
}
-int kerndat_loginuid(bool only_dump)
+int check_loginuid_op(bool full)
{
unsigned int saved_loginuid;
int ret;
- kdat.has_loginuid = false;
-
/* No such file: CONFIG_AUDITSYSCALL disabled */
saved_loginuid = parse_pid_loginuid(PROC_SELF, &ret, true);
if (ret < 0)
return 0;
- if (only_dump) {
- kdat.has_loginuid = true;
- return 0;
- }
+ if (!full)
+ return 1;
/*
* From kernel v3.13-rc2 it's possible to unset loginuid value,
@@ -472,8 +468,20 @@ int kerndat_loginuid(bool only_dump)
if (prepare_loginuid(saved_loginuid, LOG_WARN) < 0)
return 0;
- kdat.has_loginuid = true;
- return 0;
+ return 1;
+}
+
+static int kerndat_loginuid(bool for_restore)
+{
+ int ret;
+
+ kdat.has_loginuid = false;
+ ret = check_loginuid_op(for_restore);
+ if (ret > 0) {
+ kdat.has_loginuid = true;
+ ret = 0;
+ }
+ return ret;
}
static int kerndat_iptables_has_xtlocks(void)
@@ -660,7 +668,7 @@ int kerndat_init(void)
if (!ret)
ret = get_ipv6();
if (!ret)
- ret = kerndat_loginuid(true);
+ ret = kerndat_loginuid(false);
if (!ret)
ret = kerndat_iptables_has_xtlocks();
if (!ret)
@@ -698,7 +706,7 @@ int kerndat_init_rst(void)
if (!ret)
ret = get_ipv6();
if (!ret)
- ret = kerndat_loginuid(false);
+ ret = kerndat_loginuid(true);
if (!ret)
ret = kerndat_iptables_has_xtlocks();
if (!ret)
--
2.5.5
More information about the CRIU
mailing list