[CRIU] [PATCH 2/2] ids: Make sure the kIDs obtained from root_ids are sane

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 14 16:50:24 EDT 2013


Otherwise we will get nil dereference in shared_fdt_prepare

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 pstree.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/pstree.c b/pstree.c
index 4f4d938..fb0b25b 100644
--- a/pstree.c
+++ b/pstree.c
@@ -512,6 +512,17 @@ static int prepare_pstree_kobj_ids(void)
 		if (cflags & CLONE_FILES) {
 			int ret;
 
+			/*
+			 * There might be a case when kIDs for
+			 * root task are the same as in root_ids,
+			 * thus it's image corruption and we should
+			 * exit out.
+			 */
+			if (unlikely(!item->parent)) {
+				pr_err("Image corruption on kIDs data\n");
+				return -1;
+			}
+
 			ret = shared_fdt_prepare(item);
 			if (ret)
 				return ret;
-- 
1.8.1.4



More information about the CRIU mailing list