[CRIU] [PATCH 6/9] mntns: rework validation to support non-root shared bind-mounts
Pavel Emelyanov
xemul at parallels.com
Wed Nov 5 11:11:49 PST 2014
>>> static int validate_shared(struct mount_info *m)
>>> {
>>> - struct mount_info *ct, *t;
>>> + struct mount_info *t, *ct, *cm, *tmp;
>>> + int t_root_len, m_root_len, tpm, mpm;
>>> + LIST_HEAD(children);
>>> +
>>> + /*
>>> + * Check that all mounts in one shared group has the same set of
>>> + * children. Only visible children are accounted. A non-root bind-mount
>>> + * doesn't see children out of its root and it's excpected case.
>>> + *
>>> + * Here is a few conditions:
>>> + * 1. t is wider than m
>>> + * 2. We search a wider mount in the same direction, so when we
>>> + * enumirate all mounts, we can't be sure that all of them
>>> + * has the same set of children.
>>> + */
>>> +
>>> + /*
>>> + * Try to find a mount, which is wider or equal.
>>> + * A is wider than B, if A->root is a substring of B->root.
>>> + */
>>> + list_for_each_entry(t, &m->mnt_share, mnt_share) {
>>> + if (strncmp(t->root, m->root, strlen(t->root)) == 0)
>>
>> What if t->root is "/foo/abc" and m->root is "/foo/abcd"? This strncmp
>> would return 0, but probably t should not even be considered as m's wider
>> mount, shouldn't it?
>
> No, it should not. Thanks.
First idea. We need the is_subpath() helper, that is to be used
here and in validate_mounts' last loop.
And, probably, in this function further too.
Thanks,
Pavel
More information about the CRIU
mailing list