Commit ffe5f9b4 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mount: Use issubpath() when checking for submount visibility

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: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
parent e9512502
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment