[CRIU] [PATCH 1/2] zdtm: check a ghost file in a read-only directory

Andrey Vagin avagin at openvz.org
Tue Apr 19 00:42:04 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

=[log]=> dump/zdtm/static/unlink_fstat00/39/1/restore.log
------------------------ grep Error ------------------------
(00.097701)      4: Error (files-reg.c:1231): Can't link zdtm/static/unlink_fstat00.test/test\file'
(00.097707)      4: Error (files-reg.c:1431): Can't link zdtm/static/unlink_fstat00.test/test\file'
(00.097952)      1: Error (cr-restore.c:1404): 4 exited, status=1
(00.108085) Error (cr-restore.c:1407): 64 killed by signal 9: Killed
(00.114341) Error (cr-restore.c:2246): Restoring FAILED.
------------------------ ERROR OVER ------------------------

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/Makefile            |  2 +-
 test/zdtm/static/unlink_fstat00.c    | 10 ++++++++--
 test/zdtm/static/unlink_fstat00.desc |  1 +
 3 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100644 test/zdtm/static/unlink_fstat00.desc

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 31f7f87..76a17d6 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -163,7 +163,6 @@ TST_FILE	=				\
 		deleted_unix_sock		\
 		sk-unix-rel			\
 		deleted_dev			\
-		unlink_fstat00			\
 		unlink_fstat01			\
 		unlink_fstat01+			\
 		unlink_fstat02			\
@@ -220,6 +219,7 @@ TST_DIR		=				\
 		cgroup02			\
 		cgroup03			\
 		cgroup_stray		\
+		unlink_fstat00			\
 		mntns_open			\
 		mntns_link_remap		\
 		mntns_link_ghost		\
diff --git a/test/zdtm/static/unlink_fstat00.c b/test/zdtm/static/unlink_fstat00.c
index 4965dbc..56ff8bb 100644
--- a/test/zdtm/static/unlink_fstat00.c
+++ b/test/zdtm/static/unlink_fstat00.c
@@ -5,13 +5,14 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <string.h>
+#include <linux/limits.h>
 
 #include "zdtmtst.h"
 
 const char *test_doc	= "Open, unlink, change size, seek, migrate, check size";
 
-char *filename;
-TEST_OPTION(filename, string, "file name", 1);
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
 
 int main(int argc, char ** argv)
 {
@@ -23,14 +24,19 @@ int main(int argc, char ** argv)
 	uint8_t buf[fsize];
 	struct stat fst;
 	uint32_t crc;
+	char filename[PATH_MAX];
 
 	test_init(argc, argv);
 
+	snprintf(filename, sizeof(filename), "%s/test\\file'\n\"un%%linkfstat00", dirname);
+
+	mkdir(dirname, 0700);
 	fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
 	if (fd < 0) {
 		pr_perror("can't open %s", filename);
 		exit(1);
 	}
+	chmod(dirname, 0500);
 
 	if (fstat(fd, &fst) < 0) {
 		pr_perror("can't get file info %s before", filename);
diff --git a/test/zdtm/static/unlink_fstat00.desc b/test/zdtm/static/unlink_fstat00.desc
new file mode 100644
index 0000000..48e131a
--- /dev/null
+++ b/test/zdtm/static/unlink_fstat00.desc
@@ -0,0 +1 @@
+{ "flags" : "suid" }
-- 
2.5.0



More information about the CRIU mailing list