diff options
-rw-r--r-- | pkg/abi/linux/fs.go | 6 | ||||
-rw-r--r-- | pkg/sentry/loader/elf.go | 3 | ||||
-rw-r--r-- | pkg/sentry/strace/strace.go | 2 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_file.go | 4 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_stat.go | 4 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_thread.go | 2 |
6 files changed, 12 insertions, 9 deletions
diff --git a/pkg/abi/linux/fs.go b/pkg/abi/linux/fs.go index 00b239351..32a0812b4 100644 --- a/pkg/abi/linux/fs.go +++ b/pkg/abi/linux/fs.go @@ -28,6 +28,12 @@ const ( V9FS_MAGIC = 0x01021997 ) +// Filesystem path limits, from uapi/linux/limits.h. +const ( + NAME_MAX = 255 + PATH_MAX = 4096 +) + // Statfs is struct statfs, from uapi/asm-generic/statfs.h. type Statfs struct { // Type is one of the filesystem magic values, defined above. 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 } |