[CRIU] [PATCH 5/9] mount: Use issubpath() when checking for submount visibility

Pavel Emelyanov xemul at parallels.com
Tue Nov 11 06:50:28 PST 2014


When we check whether a submount of a mount is visible in another
mount (shared peer of the latter), we can and should use the new
issubpath helper.

Should because the used strncmp may scan beyond ct_mpnt_rpath if
its length is smaller (no checks for this in the code).

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 mount.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/mount.c b/mount.c
index cd36da0..05444e3 100644
--- a/mount.c
+++ b/mount.c
@@ -473,18 +473,12 @@ static int validate_shared(struct mount_info *m)
 
 		ct_mpnt_rpath = ct->mountpoint + t_mpnt_l; /* path from t->mountpoint to ct->mountpoint */
 
-		/* A */
-
 		/*
-		 * issubpath() can't be used here, because ct_mpnt_rpath should
-		 * not be equal to m_root_rpath. Otherwise ct will be eqaul to
-		 * m or its brother.
+		 * Check whether ct can be is visible at m, i.e. the
+		 * ct's rpath starts (as path) with m's rpath.
 		 */
 
-		if (strncmp(ct_mpnt_rpath, m_root_rpath, len))
-			continue;
-
-		if (ct_mpnt_rpath[len] != '/')
+		if (!issubpath(ct_mpnt_rpath, m_root_rpath))
 			continue;
 
 		list_for_each_entry_safe(cm, tmp, &m->children, siblings) {
-- 
1.8.4.2




More information about the CRIU mailing list