[CRIU] [PATCH 3/3] mnt: Make sure we don't hit nil dereference on nested mount

Cyrill Gorcunov gorcunov at openvz.org
Mon Oct 5 06:30:39 PDT 2015


Such case is actually a BUG but while we can resolve
the situation without real bug-on call lets walk in
a gentle way.

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

diff --git a/mount.c b/mount.c
index 383aec6a8dea..c4b84249cd6a 100644
--- a/mount.c
+++ b/mount.c
@@ -359,6 +359,11 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list, bool inser
 				 * the main root.
 				 */
 				parent = tmp_root_mount;
+				if (unlikely(!tmp_root_mount)) {
+					pr_err("Nested mount %d (@%s %s) w/o root insertion detected\n",
+					       m->mnt_id, m->mountpoint, m->root);
+					return NULL;
+				}
 
 				pr_debug("Mountpoint %d (@%s) get parent %d (@%s)\n",
 					 m->mnt_id, m->mountpoint,
-- 
2.4.3



More information about the CRIU mailing list