[Devel] [PATCH criu v7-u5 1/2] mount: restore_task_mnt_ns - Lookup for mount namespace conditionally

Cyrill Gorcunov gorcunov at gmail.com
Sat Jul 22 13:27:08 MSK 2017


In case if our parent is a dead task (zombie) we should lookup
for parent ids which will be inherited on restore. Otherwise
parent->ids may be nil and SIGSEGV produced.

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

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/mount.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index 2ec94b3..1066663 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -3069,6 +3069,7 @@ int restore_task_mnt_ns(struct pstree_item *current)
 		return 0;
 
 	if (current->ids && current->ids->has_mnt_ns_id) {
+		struct pstree_item *next = current->parent;
 		unsigned int id = current->ids->mnt_ns_id;
 		struct ns_id *nsid;
 
@@ -3081,8 +3082,10 @@ int restore_task_mnt_ns(struct pstree_item *current)
 		 * already there, otherwise it will have to do
 		 * setns().
 		 */
-		if (current->parent && id == current->parent->ids->mnt_ns_id)
-			return 0;
+		for (; next; next = next->parent) {
+			if (next->ids && id == next->ids->mnt_ns_id)
+				return 0;
+		}
 
 		nsid = lookup_ns_by_id(id, &mnt_ns_desc);
 		if (nsid == NULL) {
-- 
2.7.5



More information about the Devel mailing list