From fc4357a8b09ec625c7d9b26c8903084a2215d1e0 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 12 Mar 2020 18:11:07 -0700 Subject: [PATCH] libct/msMoveRoot: rm redundant filepath.Abs() calls 1. rootfs is already validated to be kosher by (*ConfigValidator).rootfs() 2. mount points from /proc/self/mountinfo are absolute and clean, too Signed-off-by: Kir Kolyshkin --- libcontainer/rootfs_linux.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go index 774181590..bc13b580a 100644 --- a/libcontainer/rootfs_linux.go +++ b/libcontainer/rootfs_linux.go @@ -810,18 +810,10 @@ func msMoveRoot(rootfs string) error { return err } - absRootfs, err := filepath.Abs(rootfs) - if err != nil { - return err - } - for _, info := range mountinfos { - p, err := filepath.Abs(info.Mountpoint) - if err != nil { - return err - } + p := info.Mountpoint // Umount every syfs and proc file systems, except those under the container rootfs - if (info.Fstype != "proc" && info.Fstype != "sysfs") || filepath.HasPrefix(p, absRootfs) { + if (info.Fstype != "proc" && info.Fstype != "sysfs") || filepath.HasPrefix(p, rootfs) { continue } // Be sure umount events are not propagated to the host.