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)
| 139 | // |
| 140 | // args.MemoryManager does not need to be set by the caller. |
| 141 | func (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 | } |
no test coverage detected