[Devel] files-reg: forbid migration of opened device files on NFS

Submitted by Stanislav Kinsburskiy on June 27, 2017, 11:32 a.m.

Details

Message ID 20170627113224.24166.90224.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "files-reg: forbid migration of opened device files on NFS"
Headers show

Commit Message

Stanislav Kinsburskiy June 27, 2017, 11:32 a.m.
NFS is replaced by FUSE-based SPFS on restore. And SPFS is mounted via
libfuse, which uses "MS_NODEV" mount option.
Thus it's impossible to open a device file on SPFS.
This patch forbids dumping to prevent restore failure.

https://jira.sw.ru/browse/PSBM-55590

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 criu/files-reg.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 6e97a72..ee80b61 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1350,6 +1350,25 @@  static bool should_check_size(int flags)
 	return true;
 }
 
+static bool unsupported_nfs_file(const struct fd_link *link,
+				 const struct fd_parms *parms)
+{
+	if (parms->fs_type != NFS_SUPER_MAGIC)
+		return false;
+
+	if (S_ISCHR(parms->stat.st_mode)) {
+		pr_err("Character devices ([%s]) migration on NFS are not supported\n", &link->name[1]);
+		return true;
+	}
+
+	if (S_ISBLK(parms->stat.st_mode)) {
+		pr_err("Block devices ([%s]) migration on NFS are not supported\n", &link->name[1]);
+		return true;
+	}
+
+	return false;
+}
+
 int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
 {
 	struct fd_link _link, *link;
@@ -1400,6 +1419,11 @@  int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
 		return -1;
 	}
 
+	if (unsupported_nfs_file(link, p)) {
+		pr_err("The path [%s] is not supported\n", &link->name[1]);
+		return -1;
+	}
+
 	if (check_path_remap(link, p, lfd, id, nsid))
 		return -1;
 	rfe.name	= &link->name[1];

Comments

Dmitry Safonov June 29, 2017, 6:23 p.m.
On 06/27/2017 02:32 PM, Stanislav Kinsburskiy wrote:
> NFS is replaced by FUSE-based SPFS on restore. And SPFS is mounted via
> libfuse, which uses "MS_NODEV" mount option.
> Thus it's impossible to open a device file on SPFS.
> This patch forbids dumping to prevent restore failure.
> 
> https://jira.sw.ru/browse/PSBM-55590
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
> --- >   criu/files-reg.c |   24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)

Applied to vz-criu, released in criu-3.0.0.15-1.vz7