Skip to content

Commit

Permalink
Merge pull request #1309 from giuseppe/overlay-no-recursive-open-tree…
Browse files Browse the repository at this point in the history
…-clone

overlay: do not clone source recursively
  • Loading branch information
rhatdan committed Aug 17, 2022
2 parents 9ba108e + b49ea12 commit d3f1078
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions drivers/overlay/idmapped_utils.go
Expand Up @@ -21,17 +21,6 @@ type attr struct {
userNs uint64
}

const (
// _MOUNT_ATTR_IDMAP - Idmap mount to @userns_fd in struct mount_attr
_MOUNT_ATTR_IDMAP = 0x00100000 //nolint:golint

// _OPEN_TREE_CLONE - Clone the source path mount
_OPEN_TREE_CLONE = 0x00000001 //nolint:golint

// _MOVE_MOUNT_F_EMPTY_PATH - Move the path referenced by the fd
_MOVE_MOUNT_F_EMPTY_PATH = 0x00000004 //nolint:golint
)

// openTree is a wrapper for the open_tree syscall
func openTree(path string, flags int) (fd int, err error) {
var _p0 *byte
Expand Down Expand Up @@ -61,7 +50,7 @@ func moveMount(fdTree int, target string) (err error) {
return err
}

flags := _MOVE_MOUNT_F_EMPTY_PATH
flags := unix.MOVE_MOUNT_F_EMPTY_PATH

_, _, e1 := syscall.Syscall6(uintptr(unix.SYS_MOVE_MOUNT),
uintptr(fdTree), uintptr(unsafe.Pointer(_p1)),
Expand Down Expand Up @@ -98,14 +87,14 @@ func createIDMappedMount(source, target string, pid int) error {
}

var attr attr
attr.attrSet = _MOUNT_ATTR_IDMAP
attr.attrSet = unix.MOUNT_ATTR_IDMAP
attr.attrClr = 0
attr.propagation = 0
attr.userNs = uint64(userNsFile.Fd())

defer userNsFile.Close()

targetDirFd, err := openTree(source, _OPEN_TREE_CLONE|unix.AT_RECURSIVE)
targetDirFd, err := openTree(source, unix.OPEN_TREE_CLONE)
if err != nil {
return err
}
Expand Down

0 comments on commit d3f1078

Please sign in to comment.