Explorar o código

Merge pull request #35217 from cpuguy83/fix_chroot_mount_race

Use rslave instead of rprivate in chrootarchive
Sebastiaan van Stijn %!s(int64=7) %!d(string=hai) anos
pai
achega
d891f2e3ca
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      pkg/chrootarchive/chroot_linux.go

+ 7 - 2
pkg/chrootarchive/chroot_linux.go

@@ -26,8 +26,13 @@ func chroot(path string) (err error) {
 		return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
 	}
 
-	// make everything in new ns private
-	if err := mount.MakeRPrivate("/"); err != nil {
+	// Make everything in new ns slave.
+	// Don't use `private` here as this could race where the mountns gets a
+	//   reference to a mount and an unmount from the host does not propagate,
+	//   which could potentially cause transient errors for other operations,
+	//   even though this should be relatively small window here `slave` should
+	//   not cause any problems.
+	if err := mount.MakeRSlave("/"); err != nil {
 		return err
 	}