[CRIU] [PATCH 1/5] fown: Dont fail if owner is a dead pid

Cyrill Gorcunov gorcunov at gmail.com
Fri Dec 7 15:29:44 MSK 2018


A pid owner may already have exited when we're dumping a file,
thus on restore we will not find the pid and should simply
ignore it.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/files.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 3e0c8c4592dd..b12258ad2654 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -741,8 +741,19 @@ int restore_fown(int fd, FownEntry *fown)
 	owner.pid = fown->pid;
 
 	if (fcntl(fd, F_SETOWN_EX, &owner)) {
-		pr_perror("Can't setup %d file owner pid", fd);
-		return -1;
+		if (errno == ESRCH) {
+			/*
+			 * The pid obtained at the dump may no longer
+			 * exist, because the tasks with it has already
+			 * exited. Just ignore it.
+			 */
+			pr_debug("fown: No owner type %d pid %d found on file %d, skipping\n",
+				 owner.type, owner.pid, fd);
+		} else {
+			pr_perror("fown: Can't setup %d file owner type %d pid %d",
+				  fd, owner.type, owner.pid);
+			return -1;
+		}
 	}
 
 	if (setresuid(uids[0], uids[1], uids[2])) {
-- 
2.17.2



More information about the CRIU mailing list