Files
snapd/cmd
Alfonso Sánchez-Beato 3fbc941e3f cmd/snap-update-ns: prevent keeping unneeded mountpoints
In some cases we were keeping mounts from removed layouts, because we
were not identifying properly the mounts that we wanted to keep, as we
used mountpoint as key for the reuse map used in neededChanges, while
there are corner cases when we mount more that once on a given
mountpoint. This can happen when, say, we have a layout for /dir/sd1
and another one for /dir/sd2/sd3, being the case that /dir/sd1 and
/dir/sd2/sd3 do not exist (but their parent dirs do exist) - /dir/sd2
will be one of the bind mounted directories of the tmpfs that is
created in /dir to have a layout on /dir/sd1, while at the same time a
tmpfs will be mounted in /dir/sd2 so we can have a layout in
/dir/sd2/sd3. So /dir/sd2 is used twice with different filesystem
types (none and tmpfs).

To prevent this, use as key in the reuse map dir+fstype. As we make
sure that mimics are created only once per directory, we should only
have one entry per dir+fstype, being fstype either none or tmpfs.

In the future we should clean-up mountpoints before performing
changes, but that is a bigger change and anyway this fix is needed for
mount namespaces already created by older snapd versions.
2023-01-23 15:49:42 +01:00
..
2022-10-07 12:21:37 +02:00