benchexec
benchexec copied to clipboard
Improve handling of nested mounts
If we create nested containers (e.g., with containerexec) and use overlayfs for some directory in both containers, it looks like the inner containerexec mounts two instances of overlayfs for the same directory, which seems redundant. This is likely caused by the fact that the list of mountpoints in the other container contains the directory twice. We could optimize this and probably also make it more robust by sorting and deduplicating the list of mountpoints in benchexec.container.duplicate_mount_hierarchy.
In order to do this, we should probably switch from using /proc/mounts to /proc/self/mountinfo (documented in man proc), which contains more information. In particular, with this file we can correctly determine the list of visible mounts without those that are hidden by other mounts on top, and ignore the latter.