diff options
author | Jamie Liu <jamieliu@google.com> | 2019-03-29 16:24:29 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-29 16:25:33 -0700 |
commit | 26e8d9981fcf6d08199a9fd9c609d9715c3cf37e (patch) | |
tree | bcf90e47301f46a6d702e8c7fdccf3428ab038bf /pkg/sentry/syscalls | |
parent | dcf66133314712b9ba042dbbb289c29d00a2497a (diff) |
Use kernel.Task.CopyScratchBuffer in syscalls/linux where possible.
PiperOrigin-RevId: 241072126
Change-Id: Ib4d9f58f550732ac4c5153d3cf159a5b1a9749da
Diffstat (limited to 'pkg/sentry/syscalls')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_prctl.go | 2 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_socket.go | 2 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_stat.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_prctl.go b/pkg/sentry/syscalls/linux/sys_prctl.go index 4938f27bd..7a29bd9b7 100644 --- a/pkg/sentry/syscalls/linux/sys_prctl.go +++ b/pkg/sentry/syscalls/linux/sys_prctl.go @@ -75,7 +75,7 @@ func Prctl(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscall case linux.PR_GET_NAME: addr := args[1].Pointer() - buf := make([]byte, linux.TASK_COMM_LEN) + buf := t.CopyScratchBuffer(linux.TASK_COMM_LEN) len := copy(buf, t.Name()) if len < linux.TASK_COMM_LEN { buf[len] = 0 diff --git a/pkg/sentry/syscalls/linux/sys_socket.go b/pkg/sentry/syscalls/linux/sys_socket.go index 564357bac..49e6f4aeb 100644 --- a/pkg/sentry/syscalls/linux/sys_socket.go +++ b/pkg/sentry/syscalls/linux/sys_socket.go @@ -516,7 +516,7 @@ func SetSockOpt(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sy if optLen > maxOptLen { return 0, nil, syscall.EINVAL } - buf := make([]byte, optLen) + buf := t.CopyScratchBuffer(int(optLen)) if _, err := t.CopyIn(optValAddr, &buf); err != nil { return 0, nil, err } diff --git a/pkg/sentry/syscalls/linux/sys_stat.go b/pkg/sentry/syscalls/linux/sys_stat.go index 8d6a8f616..bdfb9b3ef 100644 --- a/pkg/sentry/syscalls/linux/sys_stat.go +++ b/pkg/sentry/syscalls/linux/sys_stat.go @@ -133,7 +133,7 @@ func stat(t *kernel.Task, d *fs.Dirent, dirPath bool, statAddr usermem.Addr) err // common syscall for many applications, and t.CopyObjectOut has // noticeable performance impact due to its many slice allocations and // use of reflection. - b := make([]byte, 0, linux.SizeOfStat) + b := t.CopyScratchBuffer(int(linux.SizeOfStat))[:0] // Dev (uint64) b = binary.AppendUint64(b, usermem.ByteOrder, uint64(d.Inode.StableAttr.DeviceID)) |