diff options
author | Brian Geffon <bgeffon@google.com> | 2019-01-08 12:56:59 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-08 12:58:08 -0800 |
commit | 3676b7ff1ca07e9fec1e380a0c2068390ce5d8de (patch) | |
tree | 8b0c0cc57500993a848f3cf5eba6a0f6ae900275 /pkg/sentry/kernel/task_context.go | |
parent | f95b94fbe3e557b16ed2b78c87e8936c0aeab6c5 (diff) |
Improve loader related error messages returned to users.
PiperOrigin-RevId: 228382827
Change-Id: Ica1d30e0df826bdd77f180a5092b2b735ea5c804
Diffstat (limited to 'pkg/sentry/kernel/task_context.go')
-rw-r--r-- | pkg/sentry/kernel/task_context.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/sentry/kernel/task_context.go b/pkg/sentry/kernel/task_context.go index aaff309f0..ee3e49d17 100644 --- a/pkg/sentry/kernel/task_context.go +++ b/pkg/sentry/kernel/task_context.go @@ -15,9 +15,9 @@ package kernel import ( - "errors" "fmt" + "gvisor.googlesource.com/gvisor/pkg/abi/linux" "gvisor.googlesource.com/gvisor/pkg/cpuid" "gvisor.googlesource.com/gvisor/pkg/sentry/arch" "gvisor.googlesource.com/gvisor/pkg/sentry/context" @@ -26,10 +26,10 @@ import ( "gvisor.googlesource.com/gvisor/pkg/sentry/loader" "gvisor.googlesource.com/gvisor/pkg/sentry/mm" "gvisor.googlesource.com/gvisor/pkg/sentry/usermem" + "gvisor.googlesource.com/gvisor/pkg/syserr" ) -// ErrNoSyscalls is returned if there is no syscall table. -var ErrNoSyscalls = errors.New("no syscall table found") +var errNoSyscalls = syserr.New("no syscall table found", linux.ENOEXEC) // Auxmap contains miscellaneous data for the task. type Auxmap map[string]interface{} @@ -142,7 +142,7 @@ func (t *Task) Stack() *arch.Stack { // * argv: Binary argv // * envv: Binary envv // * fs: Binary FeatureSet -func (k *Kernel) LoadTaskImage(ctx context.Context, mounts *fs.MountNamespace, root, wd *fs.Dirent, maxTraversals *uint, filename string, argv, envv []string, fs *cpuid.FeatureSet) (*TaskContext, error) { +func (k *Kernel) LoadTaskImage(ctx context.Context, mounts *fs.MountNamespace, root, wd *fs.Dirent, maxTraversals *uint, filename string, argv, envv []string, fs *cpuid.FeatureSet) (*TaskContext, *syserr.Error) { // Prepare a new user address space to load into. m := mm.NewMemoryManager(k) defer m.DecUsers(ctx) @@ -155,8 +155,9 @@ func (k *Kernel) LoadTaskImage(ctx context.Context, mounts *fs.MountNamespace, r // Lookup our new syscall table. st, ok := LookupSyscallTable(os, ac.Arch()) if !ok { - // No syscall table found. Yikes. - return nil, ErrNoSyscalls + // No syscall table found. This means that the ELF binary does not match + // the architecture. + return nil, errNoSyscalls } if !m.IncUsers() { |