[CRIU] [PATCH 4/6] kdat: Make sure we're readin cache from tmpfs

Cyrill Gorcunov gorcunov at gmail.com
Tue Apr 3 20:46:48 MSK 2018


When we're saving kdat we check if fs is laying on
is on tmpfs thus on machine reboot it get removed
and regenerated on next run. Still there is no
proof that when we're reading it the underlied
fs has not been changed. Lets add this check.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/kerndat.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/criu/kerndat.c b/criu/kerndat.c
index 798cb16274e4..227d429f9dde 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -840,6 +840,7 @@ static int kerndat_x86_has_ptrace_fpu_xsave_bug(void)
 
 static int kerndat_try_load_cache(void)
 {
+	struct statfs s;
 	int fd, ret;
 
 	fd = open(KERNDAT_CACHE_FILE, O_RDONLY);
@@ -855,6 +856,12 @@ static int kerndat_try_load_cache(void)
 		return -1;
 	}
 
+	if (fstatfs(fd, &s) < 0 || s.f_type != TMPFS_MAGIC) {
+		pr_warn("Can't read kdat cache from non-tempfs\n");
+		close(fd);
+		return -1;
+	}
+
 	close(fd);
 
 	if (ret != sizeof(kdat) ||
-- 
2.14.3



More information about the CRIU mailing list