summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-10-08 11:38:02 -0700
committerShentubot <shentubot@google.com>2018-10-08 11:39:54 -0700
commit569c2b06c47d269d961405fa652d45e51860d005 (patch)
treeaabbf7fc7e786d0699d9ea1d34f7048fb4339761 /pkg/sentry
parente9e8be661328661b5527f1643727b9a13bbeab48 (diff)
Statfs Namelen should be NAME_MAX not PATH_MAX
We accidentally set the wrong maximum. I've also added PATH_MAX and NAME_MAX to the linux abi package. PiperOrigin-RevId: 216221311 Change-Id: I44805fcf21508831809692184a0eba4cee469633
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/loader/elf.go3
-rw-r--r--pkg/sentry/strace/strace.go2
-rw-r--r--pkg/sentry/syscalls/linux/sys_file.go4
-rw-r--r--pkg/sentry/syscalls/linux/sys_stat.go4
-rw-r--r--pkg/sentry/syscalls/linux/sys_thread.go2
5 files changed, 6 insertions, 9 deletions
diff --git a/pkg/sentry/loader/elf.go b/pkg/sentry/loader/elf.go
index f4deaa905..849be5a3d 100644
--- a/pkg/sentry/loader/elf.go
+++ b/pkg/sentry/loader/elf.go
@@ -19,7 +19,6 @@ import (
"debug/elf"
"fmt"
"io"
- "syscall"
"gvisor.googlesource.com/gvisor/pkg/abi"
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
@@ -409,7 +408,7 @@ func loadParsedELF(ctx context.Context, m *mm.MemoryManager, f *fs.File, info el
ctx.Infof("PT_INTERP path too small: %v", phdr.Filesz)
return loadedELF{}, syserror.ENOEXEC
}
- if phdr.Filesz > syscall.PathMax {
+ if phdr.Filesz > linux.PATH_MAX {
ctx.Infof("PT_INTERP path too big: %v", phdr.Filesz)
return loadedELF{}, syserror.ENOEXEC
}
diff --git a/pkg/sentry/strace/strace.go b/pkg/sentry/strace/strace.go
index c99c33c33..f2a22aaa5 100644
--- a/pkg/sentry/strace/strace.go
+++ b/pkg/sentry/strace/strace.go
@@ -133,7 +133,7 @@ func dump(t *kernel.Task, addr usermem.Addr, size uint, maximumBlobSize uint) st
}
func path(t *kernel.Task, addr usermem.Addr) string {
- path, err := t.CopyInString(addr, syscall.PathMax)
+ path, err := t.CopyInString(addr, linux.PATH_MAX)
if err != nil {
return fmt.Sprintf("%#x (error decoding path: %s)", addr, err)
}
diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go
index 97881a1f5..015afda9b 100644
--- a/pkg/sentry/syscalls/linux/sys_file.go
+++ b/pkg/sentry/syscalls/linux/sys_file.go
@@ -115,7 +115,7 @@ func fileOpOn(t *kernel.Task, dirFD kdefs.FD, path string, resolve bool, fn func
// copyInPath copies a path in.
func copyInPath(t *kernel.Task, addr usermem.Addr, allowEmpty bool) (path string, dirPath bool, err error) {
- path, err = t.CopyInString(addr, syscall.PathMax)
+ path, err = t.CopyInString(addr, linux.PATH_MAX)
if err != nil {
return "", false, err
}
@@ -1080,7 +1080,7 @@ func symlinkAt(t *kernel.Task, dirFD kdefs.FD, newAddr usermem.Addr, oldAddr use
// The oldPath is copied in verbatim. This is because the symlink
// will include all details, including trailing slashes.
- oldPath, err := t.CopyInString(oldAddr, syscall.PathMax)
+ oldPath, err := t.CopyInString(oldAddr, linux.PATH_MAX)
if err != nil {
return err
}
diff --git a/pkg/sentry/syscalls/linux/sys_stat.go b/pkg/sentry/syscalls/linux/sys_stat.go
index 6e21b34fd..619a14d7c 100644
--- a/pkg/sentry/syscalls/linux/sys_stat.go
+++ b/pkg/sentry/syscalls/linux/sys_stat.go
@@ -15,8 +15,6 @@
package linux
import (
- "syscall"
-
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
@@ -198,7 +196,7 @@ func statfsImpl(t *kernel.Task, d *fs.Dirent, addr usermem.Addr) error {
Files: info.TotalFiles,
FilesFree: info.FreeFiles,
// Same as Linux for simple_statfs, see fs/libfs.c.
- NameLength: syscall.PathMax,
+ NameLength: linux.NAME_MAX,
FragmentSize: d.Inode.StableAttr.BlockSize,
// Leave other fields 0 like simple_statfs does.
}
diff --git a/pkg/sentry/syscalls/linux/sys_thread.go b/pkg/sentry/syscalls/linux/sys_thread.go
index 0adbf160f..550f63a43 100644
--- a/pkg/sentry/syscalls/linux/sys_thread.go
+++ b/pkg/sentry/syscalls/linux/sys_thread.go
@@ -76,7 +76,7 @@ func Execve(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal
envvAddr := args[2].Pointer()
// Extract our arguments.
- filename, err := t.CopyInString(filenameAddr, syscall.PathMax)
+ filename, err := t.CopyInString(filenameAddr, linux.PATH_MAX)
if err != nil {
return 0, nil, err
}