Skip to content

Commit 2f010ec

Browse files
Merge pull request #1622 from vdemeester/import-symlink-from-docker
Remove pkg/symlink from docker/docker and use cyphar/filepath-securejoin
2 parents c4f49e2 + 5945014 commit 2f010ec

File tree

17 files changed

+1970
-331
lines changed

17 files changed

+1970
-331
lines changed

libcontainer/rootfs_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"strings"
1414
"time"
1515

16+
"github.com/cyphar/filepath-securejoin"
1617
"github.com/docker/docker/pkg/mount"
17-
"github.com/docker/docker/pkg/symlink"
1818
"github.com/mrunalp/fileutils"
1919
"github.com/opencontainers/runc/libcontainer/cgroups"
2020
"github.com/opencontainers/runc/libcontainer/configs"
@@ -240,7 +240,7 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
240240
// any previous mounts can invalidate the next mount's destination.
241241
// this can happen when a user specifies mounts within other mounts to cause breakouts or other
242242
// evil stuff to try to escape the container's rootfs.
243-
if dest, err = symlink.FollowSymlinkInScope(dest, rootfs); err != nil {
243+
if dest, err = securejoin.SecureJoin(rootfs, m.Destination); err != nil {
244244
return err
245245
}
246246
if err := checkMountDestination(rootfs, dest); err != nil {
@@ -328,7 +328,7 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
328328
// this can happen when a user specifies mounts within other mounts to cause breakouts or other
329329
// evil stuff to try to escape the container's rootfs.
330330
var err error
331-
if dest, err = symlink.FollowSymlinkInScope(dest, rootfs); err != nil {
331+
if dest, err = securejoin.SecureJoin(rootfs, m.Destination); err != nil {
332332
return err
333333
}
334334
if err := checkMountDestination(rootfs, dest); err != nil {

vendor.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ github.com/godbus/dbus v3
1616
github.com/golang/protobuf 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
1717
# Command-line interface.
1818
github.com/docker/docker 0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d
19+
github.com/cyphar/filepath-securejoin v0.2.1
1920
github.com/docker/go-units v0.2.0
2021
github.com/urfave/cli d53eb991652b1d438abdd34ce4bfa3ef1539108e
2122
golang.org/x/sys 7ddbeae9ae08c6a06a59597f0c9edbc5ff2444ce https://github.com/golang/sys

vendor/github.com/docker/docker/pkg/symlink/LICENSE.BSD renamed to vendor/github.com/cyphar/filepath-securejoin/LICENSE

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cyphar/filepath-securejoin/README.md

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cyphar/filepath-securejoin/join.go

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cyphar/filepath-securejoin/vendor.conf

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cyphar/filepath-securejoin/vfs.go

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)