Skip to content

Commit 97f5ee4

Browse files
committed
Only remount if requested flags differ from current
Do not remount a bind mount to enable flags unless non-default flags are provided for the requested mount. This solves a problem with user namespaces and remount of bind mount permissions. Docker-DCO-1.1-Signed-off-by: Phil Estes <[email protected]> (github: estesp)
1 parent 902ccd0 commit 97f5ee4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libcontainer/rootfs_linux.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
167167
return err
168168
}
169169
// bind mount won't change mount options, we need remount to make mount options effective.
170-
if err := remount(m, rootfs); err != nil {
171-
return err
170+
// first check that we have non-default options required before attempting a remount
171+
if m.Flags&^(syscall.MS_REC|syscall.MS_REMOUNT|syscall.MS_BIND) != 0 {
172+
// only remount if unique mount options are set
173+
if err := remount(m, rootfs); err != nil {
174+
return err
175+
}
172176
}
177+
173178
if m.Relabel != "" {
174179
if err := label.Validate(m.Relabel); err != nil {
175180
return err

0 commit comments

Comments
 (0)