MCPcopy
hub / github.com/google/gvisor / getTaskPathOperation

Function getTaskPathOperation

pkg/sentry/syscalls/linux/path.go:39–83  ·  view source on GitHub ↗
(t *kernel.Task, dirfd int32, path fspath.Path, emptyPathCheck shouldAllowEmptyPathType, shouldFollowFinalSymlink shouldFollowFinalSymlink)

Source from the content-addressed store, hash-verified

37}
38
39func getTaskPathOperation(t *kernel.Task, dirfd int32, path fspath.Path, emptyPathCheck shouldAllowEmptyPathType, shouldFollowFinalSymlink shouldFollowFinalSymlink) (taskPathOperation, error) {
40 root := t.FSContext().RootDirectory()
41 start := root
42 haveStartRef := false
43 if !path.Absolute {
44 if !path.HasComponents() && !emptyPathCheck.allow() {
45 root.DecRef(t)
46 return taskPathOperation{}, linuxerr.ENOENT
47 }
48 if dirfd == linux.AT_FDCWD {
49 start = t.FSContext().WorkingDirectory()
50 haveStartRef = true
51 } else {
52 dirfile := t.GetFile(dirfd)
53 if dirfile == nil {
54 root.DecRef(t)
55 return taskPathOperation{}, linuxerr.EBADF
56 }
57 defer dirfile.DecRef(t)
58
59 // AT_EMPTY_PATH is allowed only if t's creds are identical to the creds under which the FD was
60 // opened, or if t has CAP_DAC_READ_SEARCH in those creds' userns.
61 // Similar to how Linux handles LOOKUP_LINKAT_EMPTY in path_init() in fs/namei.c.
62 if emptyPathCheck == allowEmptyPathWithCredsCheck {
63 if dirfile.Credentials() != t.Credentials() && !t.HasCapabilityIn(linux.CAP_DAC_READ_SEARCH, dirfile.Credentials().UserNamespace) {
64 root.DecRef(t)
65 return taskPathOperation{}, linuxerr.ENOENT
66 }
67 }
68
69 start = dirfile.VirtualDentry()
70 start.IncRef()
71 haveStartRef = true
72 }
73 }
74 return taskPathOperation{
75 pop: vfs.PathOperation{
76 Root: root,
77 Start: start,
78 Path: path,
79 FollowFinalSymlink: bool(shouldFollowFinalSymlink),
80 },
81 haveStartRef: haveStartRef,
82 }, nil
83}
84
85func (tpop *taskPathOperation) Release(t *kernel.Task) {
86 tpop.pop.Root.DecRef(t)

Callers 15

mknodatFunction · 0.85
openatFunction · 0.85
accessAtFunction · 0.85
ChdirFunction · 0.85
FchdirFunction · 0.85
ChrootFunction · 0.85
PivotRootFunction · 0.85
mkdiratFunction · 0.85
rmdiratFunction · 0.85
symlinkatFunction · 0.85
linkatFunction · 0.85
readlinkatFunction · 0.85

Calls 11

FSContextMethod · 0.80
HasComponentsMethod · 0.80
allowMethod · 0.80
WorkingDirectoryMethod · 0.80
GetFileMethod · 0.80
DecRefMethod · 0.65
CredentialsMethod · 0.65
IncRefMethod · 0.65
RootDirectoryMethod · 0.45
HasCapabilityInMethod · 0.45
VirtualDentryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…