Skip to content

Commit

Permalink
Add limit to page size used by overlay2 driver
Browse files Browse the repository at this point in the history
Go can falsely report a larger page size than supported,
causing overlay2 mount arguments to be truncated. When overlay2
detects the mount arguments have hit the page limit, it will
switch to using relative paths. If this limit is smaller than
the actual page size there is no behavioral problems, but if it
is larger mounts can fail for images with many layers.

Closes moby#27384

cherry-pick from: moby#27520

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Signed-off-by: Lei Jitang <leijitang@huawei.com>
(cherry picked from commit 520034e)
  • Loading branch information
dmcgowan authored and coolljt0725 committed May 3, 2017
1 parent d54bfd2 commit 35e9318
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions daemon/graphdriver/overlay2/overlay.go
Expand Up @@ -421,6 +421,15 @@ func (d *Driver) Get(id string, mountLabel string) (s string, err error) {

pageSize := syscall.Getpagesize()

// Go can return a larger page size than supported by the system
// as of go 1.7. This will be fixed in 1.8 and this block can be
// removed when building with 1.8.
// See https://github.com/golang/go/commit/1b9499b06989d2831e5b156161d6c07642926ee1
// See https://github.com/docker/docker/issues/27384
if pageSize > 4096 {
pageSize = 4096
}

// Use relative paths and mountFrom when the mount data has exceeded
// the page size. The mount syscall fails if the mount data cannot
// fit within a page and relative links make the mount data much
Expand Down

0 comments on commit 35e9318

Please sign in to comment.