MCPcopy Index your code
hub / github.com/google/gvisor / LoadTaskImage

Method LoadTaskImage

pkg/sentry/kernel/task_image.go:141–174  ·  view source on GitHub ↗

LoadTaskImage loads a specified file into a new TaskImage. It also returns the new credentials for the task after execve and a bool indicating whether the task is executing with elevated privileges. args.MemoryManager does not need to be set by the caller.

(ctx context.Context, args loader.LoadArgs)

Source from the content-addressed store, hash-verified

139//
140// args.MemoryManager does not need to be set by the caller.
141func (k *Kernel) LoadTaskImage(ctx context.Context, args loader.LoadArgs) (*TaskImage, *auth.Credentials, bool, *syserr.Error) {
142 // Prepare a new user address space to load into.
143 m, merr := mm.NewMemoryManager(k, k.mf)
144 if merr != nil {
145 log.Warningf("Failed to create new memory manager: %v", merr)
146 return nil, nil, false, syserr.ErrNoMemory
147 }
148 defer m.DecUsers(ctx)
149 args.MemoryManager = m
150
151 info, creds, secureExec, err := loader.Load(ctx, args, k.extraAuxv, k.vdso)
152 if err != nil {
153 return nil, nil, false, err
154 }
155
156 // Lookup our new syscall table.
157 st, ok := LookupSyscallTable(info.OS, info.Arch.Arch())
158 if !ok {
159 // No syscall table found. This means that the ELF binary does not match
160 // the architecture.
161 return nil, nil, false, errNoSyscalls
162 }
163
164 if !m.IncUsers() {
165 panic("Failed to increment users count on new MM")
166 }
167 return &TaskImage{
168 Name: info.Name,
169 Arch: info.Arch,
170 MemoryManager: m,
171 fu: k.futexes.Fork(),
172 st: st,
173 }, creds, secureExec, nil
174}

Callers 2

CreateProcessMethod · 0.95
executeMethod · 0.80

Calls 8

DecUsersMethod · 0.95
IncUsersMethod · 0.95
NewMemoryManagerFunction · 0.92
WarningfFunction · 0.92
LoadFunction · 0.92
LookupSyscallTableFunction · 0.85
ArchMethod · 0.65
ForkMethod · 0.65

Tested by

no test coverage detected