[CRIU] [PATCH 1/6] zdtm: add new dumpable01 test to check that dumpable flag is preserved

Filipe Brandenburger filbranden at google.com
Tue Jun 17 20:33:49 PDT 2014


This confirms that the fix in commit d5bb7e9748fd to preserve the dumpable flag
after migration is working as expected.

In this test case, the dumpable flag is expected to always be set to 1, as
test_init will use prctl to reset it to 1 after using setuid and setgid.

Tested:
- # test/zdtm.sh static/dumpable01
  Test: zdtm/live/static/dumpable01, Result: PASS
- # test/zdtm.sh ns/static/dumpable01
  Test: zdtm/live/static/dumpable01, Result: PASS
- Confirmed that the test fails after reverting commit d5bb7e9748fd.

Signed-off-by: Filipe Brandenburger <filbranden at google.com>
---
 test/zdtm.sh                       |  1 +
 test/zdtm/.gitignore               |  1 +
 test/zdtm/live/static/Makefile     |  1 +
 test/zdtm/live/static/dumpable01.c | 48 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+)
 create mode 100644 test/zdtm/live/static/dumpable01.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index e66a8724cbc0..a48e647b9a54 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -107,6 +107,7 @@ static/chroot
 static/chroot-file
 static/rtc
 transition/maps007
+static/dumpable01
 "
 # Duplicate list with ns/ prefix
 TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#ns/#')
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 4636cd8736e1..5dd49056b4b5 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -15,6 +15,7 @@
 /live/static/cwd01
 /live/static/deleted_dev
 /live/static/deleted_unix_sock
+/live/static/dumpable01
 /live/static/env00
 /live/static/eventfs00
 /live/static/fanotify00
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 4d275f5fae8e..83de77ab6a9e 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -109,6 +109,7 @@ TST_NOFILE	=				\
 		stopped				\
 		rtc				\
 		clean_mntns			\
+		dumpable01			\
 #		jobctl00			\
 
 TST_FILE	=				\
diff --git a/test/zdtm/live/static/dumpable01.c b/test/zdtm/live/static/dumpable01.c
new file mode 100644
index 000000000000..2d03c103c3a1
--- /dev/null
+++ b/test/zdtm/live/static/dumpable01.c
@@ -0,0 +1,48 @@
+#include <sys/prctl.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc    = "Check dumpable flag handling (dumpable case)";
+const char *test_author = "Filipe Brandenburger <filbranden at google.com>";
+
+int main(int argc, char **argv)
+{
+	int save_dumpable;
+	int dumpable;
+
+	test_init(argc, argv);
+
+	save_dumpable = prctl(PR_GET_DUMPABLE);
+	if (save_dumpable < 0) {
+		err("error getting prctl(PR_GET_DUMPABLE) before dump");
+		return 1;
+	}
+#ifdef DEBUG
+	test_msg("DEBUG: before dump: dumpable=%d\n", save_dumpable);
+#endif
+
+	/* Wait for criu dump and restore. */
+	test_daemon();
+	test_waitsig();
+
+	dumpable = prctl(PR_GET_DUMPABLE);
+	if (dumpable < 0) {
+		err("error getting prctl(PR_GET_DUMPABLE) after restore");
+		return 1;
+	}
+#ifdef DEBUG
+	test_msg("DEBUG: after dump: dumpable=%d\n", dumpable);
+#endif
+
+	if (dumpable != save_dumpable) {
+		errno = 0;
+		fail("dumpable flag was not preserved over migration");
+		return 1;
+	}
+
+	pass();
+	return 0;
+}
-- 
1.9.3



More information about the CRIU mailing list