[v3,22/55] pstree: Add pid_ns check in read_pstree_image

Submitted by Kirill Tkhai on April 10, 2017, 8:18 a.m.

Details

Message ID 149181232135.17342.17654633036503507326.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai April 10, 2017, 8:18 a.m.
Sanity check, that we have pid_ns_id. As we dump pid_ns_id
since ids are implemented, they must be always.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/pstree.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/pstree.c b/criu/pstree.c
index 47711c567..601bf1365 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -574,6 +574,15 @@  static int read_pstree_image(pid_t *pid_max)
 			ids = parent->ids;
 		}
 
+		if (!ids || !ids->has_pid_ns_id) {
+			/*
+			 * At least root_item must have ids, and pid_ns_id field
+			 * was populated since ids are introduced.
+			 */
+			pr_err("No pid_ns id\n");
+			break;
+		}
+
 		pi = lookup_create_item(e->pid);
 		if (pi == NULL)
 			break;