Skip to content

Commit b3dff6b

Browse files
committed
Merge pull request #11911 from ekzhang:patch-1
PiperOrigin-RevId: 783044386
2 parents 7323f1d + 3f7bca1 commit b3dff6b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/sentry/vfs/vfs.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,16 @@ func (vfs *VirtualFilesystem) MkdirAllAt(ctx context.Context, currentPath string
878878
Start: root,
879879
Path: fspath.Parse(currentPath),
880880
}
881+
882+
// For the StatAt() operation, we follow final symlinks so that we don't
883+
// produce errors when the final component is a symlink to a directory.
884+
//
885+
// However, keep the old pop unchanged when passing to MkdirAt() below
886+
// because MkdirAt() must not follow the final symlink. This is enforced
887+
// by preconditions of FilesystemImpl.MkdirAt().
888+
pop.FollowFinalSymlink = true
881889
stat, err := vfs.StatAt(ctx, creds, pop, &StatOptions{Mask: linux.STATX_TYPE})
890+
pop.FollowFinalSymlink = false
882891
switch {
883892
case err == nil:
884893
if mustBeDir && (stat.Mask&linux.STATX_TYPE == 0 || stat.Mode&linux.FileTypeMask != linux.ModeDirectory) {

0 commit comments

Comments
 (0)