diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2018-08-14 10:33:53 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-14 10:34:56 -0700 |
commit | 66b0f3e15a60df21f67d37dc6e420d1825acacfe (patch) | |
tree | acbc517ef43714249d9c342141dec193d3ec56ad /pkg/sentry | |
parent | dde836a91858ceee25dbe023263752b39ae21274 (diff) |
Fix bind() on overlays.
InodeOperations.Bind now returns a Dirent which will be cached in the Dirent
tree.
When an overlay is in-use, Bind cannot return the Dirent created by the upper
filesystem because the Dirent does not know about the overlay. Instead,
overlayBind must create a new overlay-aware Inode and Dirent and return that.
This is analagous to how Lookup and overlayLookup work.
PiperOrigin-RevId: 208670710
Change-Id: I6390affbcf94c38656b4b458e248739b4853da29
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/fs/inode_overlay.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pkg/sentry/fs/inode_overlay.go b/pkg/sentry/fs/inode_overlay.go index 34e62a4a2..e18e095a0 100644 --- a/pkg/sentry/fs/inode_overlay.go +++ b/pkg/sentry/fs/inode_overlay.go @@ -364,7 +364,23 @@ func overlayBind(ctx context.Context, o *overlayEntry, name string, data unix.Bo if o.upper == nil { return nil, syserror.EOPNOTSUPP } - return o.upper.InodeOperations.Bind(ctx, o.upper, name, data, perm) + d, err := o.upper.InodeOperations.Bind(ctx, o.upper, name, data, perm) + if err != nil { + return nil, err + } + + // Grab the inode and drop the dirent, we don't need it. + inode := d.Inode + inode.IncRef() + d.DecRef() + + // Create a new overlay entry and dirent for the socket. + entry, err := newOverlayEntry(ctx, inode, nil, false) + if err != nil { + inode.DecRef() + return nil, err + } + return NewDirent(newOverlayInode(ctx, entry, inode.MountSource), name), nil } func overlayBoundEndpoint(o *overlayEntry, path string) unix.BoundEndpoint { |