snap-update-ns incorrectly sorts mount profile entries

Bug #1828357 reported by Zygmunt Krynicki on 2019-05-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
High
Zygmunt Krynicki

Bug Description

When snap-update-ns processes a pair of mount profiles, current and desired, to determine what needs to be done to transform the current mount profile into the desired mount profile.

The diff-like algorithm works on an array of structures that describe a fstab-like mount entry. Each entry has a destination, or mount location, a mount source and some mount options. The structures are sorted by mount destination, with some quirks, like always doing "over mount" type operations ahead of all other operations.

I believe this algorithm is incorrect because of the following observations:

- a layout creating a tmpfs in $SNAP/foo is sorted AFTER a content bind mount creating a file in $SNAP/foo/a
- the algorithm does not understand bind mounts, where both the mount destination and a mount source is a path, considering only the destination path.

I believe the algorithm should be changed to topological sorting where bind mounts are represented by nodes with two outgoing edges and regular mounts are represented by nodes with only one edge.

Zygmunt Krynicki (zyga) on 2019-05-09
description: updated
Changed in snapd:
assignee: nobody → Zygmunt Krynicki (zyga)
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers