8000 daemon/graphdriver/overlay2: set TarOptions.InUserNS for native differ · moby/moby@f8231b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit f8231b5

Browse files
committed
daemon/graphdriver/overlay2: set TarOptions.InUserNS for native differ
Commits b2fd67d (and the follow-up commit f6b8025) updated doesSupportNativeDiff to detect whether the host can support native overlay diffing with userns enabled. As a result, [useNaiveDiff] would now return "false" in cases where it previously would return "true" (and thus skip). However, [overlay2], unlike [fuse-overlay] did not take user namespaces into account, when using the native differ, and it therefore did not set the InUserNS option in TarOptions. As a result pkg/archive.createTarFile would attempt tocreate [device-nodes] through [handleTarTypeBlockCharFifo] which would fail, but the resulting error `EPERM` would be discarded, and `createTarFile` would not return early, therefor attempting to [os.LChown] the missing file, ultimately resulting in an error: failed to Lchown "/dev/console" for UID 0, GID 0: lchown /dev/console: no such file or directory This patch fixes the missing option in overlay. [useNaiveDiff]: https://github.com/moby/moby/blob/47eebd718f332f29a38455b61ee879ced5bc219b/daemon/graphdriver/overlay2/overlay.go#L248-L256 [overlay2]: https://github.com/moby/moby/blob/47eebd718f332f29a38455b61ee879ced5bc219b/daemon/graphdriver/overlay2/overlay.go#L684-L689 [fuse-overlay]: https://github.com/moby/moby/blob/47eebd718f332f29a38455b61ee879ced5bc219b/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go#L456-L462 [device-nodes]: https://github.com/moby/moby/blob/ff1e2c0de72a1bbbe4cdbe1558da57d327899df5/pkg/archive/archive.go#L713-L720 [handleTarTypeBlockCharFifo]: https://github.com/moby/moby/blob/47eebd718f332f29a38455b61ee879ced5bc219b/pkg/archive/archive_unix.go#L110-L114 [os.LChown]: https://github.com/moby/moby/blob/ff1e2c0de72a1bbbe4cdbe1558da57d327899df5/pkg/archive/archive.go#L762-L773 Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 6521057) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent b951474 commit f8231b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

daemon/graphdriver/overlay2/overlay.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strings"
1515
"sync"
1616

17+
"github.com/containerd/containerd/pkg/userns"
1718
"github.com/containerd/continuity/fs"
1819
"github.com/containerd/log"
1920
"github.com/docker/docker/daemon/graphdriver"
@@ -678,14 +679,14 @@ func (d *Driver) ApplyDiff(id string, parent string, diff io.Reader) (size int64
678679
return d.naiveDiff.ApplyDiff(id, parent, diff)
679680
}
680681

681-
// never reach here if we are running in UserNS
682682
applyDir := d.getDiffPath(id)
683683

684684
logger.Debugf("Applying tar in %s", applyDir)
685685
// Overlay doesn't need the parent id to apply the diff
686686
if err := untar(diff, applyDir, &archive.TarOptions{
687687
IDMap: d.idMap,
688688
WhiteoutFormat: archive.OverlayWhiteoutFormat,
689+
InUserNS: userns.RunningInUserNS(),
689690
}); err != nil {
690691
return 0, err
691692
}

0 commit comments

Comments
 (0)
0