summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-02-18 01:45:49 +0000
committergVisor bot <gvisor-bot@google.com>2021-02-18 01:45:49 +0000
commit2d9dc3c1b7be34442f224a10013dd5f3823c962a (patch)
treee25228b2da4ae13353eb247d3771352a182fb41e /pkg/sentry
parent45be62df210badd412752214925e0de28887ed54 (diff)
parentf051ec64639b83faabcfe766ff078072def3c2aa (diff)
Merge release-20210208.0-64-gf051ec646 (automated)
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/arch/stack_unsafe.go23
-rw-r--r--pkg/sentry/vfs/mount_unsafe.go5
2 files changed, 6 insertions, 22 deletions
diff --git a/pkg/sentry/arch/stack_unsafe.go b/pkg/sentry/arch/stack_unsafe.go
index a90d297ee..0e478e434 100644
--- a/pkg/sentry/arch/stack_unsafe.go
+++ b/pkg/sentry/arch/stack_unsafe.go
@@ -15,8 +15,6 @@
package arch
import (
- "reflect"
- "runtime"
"unsafe"
"gvisor.dev/gvisor/pkg/marshal/primitive"
@@ -33,35 +31,22 @@ import (
// On error, the contents of the stack and the bottom cursor are undefined.
func (s *Stack) pushAddrSliceAndTerminator(src []usermem.Addr) (int, error) {
// Note: Stack grows upwards, so push the terminator first.
- srcHdr := (*reflect.SliceHeader)(unsafe.Pointer(&src))
switch s.Arch.Width() {
case 8:
nNull, err := primitive.CopyUint64Out(s, StackBottomMagic, 0)
if err != nil {
return 0, err
}
- var dst []uint64
- dstHdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst))
- dstHdr.Data = srcHdr.Data
- dstHdr.Len = srcHdr.Len
- dstHdr.Cap = srcHdr.Cap
- n, err := primitive.CopyUint64SliceOut(s, StackBottomMagic, dst)
- // Ensures src doesn't get GCed until we're done using it through dst.
- runtime.KeepAlive(src)
+ srcAsUint64 := *(*[]uint64)(unsafe.Pointer(&src))
+ n, err := primitive.CopyUint64SliceOut(s, StackBottomMagic, srcAsUint64)
return n + nNull, err
case 4:
nNull, err := primitive.CopyUint32Out(s, StackBottomMagic, 0)
if err != nil {
return 0, err
}
- var dst []uint32
- dstHdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst))
- dstHdr.Data = srcHdr.Data
- dstHdr.Len = srcHdr.Len
- dstHdr.Cap = srcHdr.Cap
- n, err := primitive.CopyUint32SliceOut(s, StackBottomMagic, dst)
- // Ensure src doesn't get GCed until we're done using it through dst.
- runtime.KeepAlive(src)
+ srcAsUint32 := *(*[]uint32)(unsafe.Pointer(&src))
+ n, err := primitive.CopyUint32SliceOut(s, StackBottomMagic, srcAsUint32)
return n + nNull, err
default:
panic("Unsupported arch width")
diff --git a/pkg/sentry/vfs/mount_unsafe.go b/pkg/sentry/vfs/mount_unsafe.go
index 0df023713..c7a78d8f8 100644
--- a/pkg/sentry/vfs/mount_unsafe.go
+++ b/pkg/sentry/vfs/mount_unsafe.go
@@ -17,7 +17,6 @@ package vfs
import (
"fmt"
"math/bits"
- "reflect"
"sync/atomic"
"unsafe"
@@ -153,8 +152,8 @@ func (mt *mountTable) Init() {
func newMountTableSlots(cap uintptr) unsafe.Pointer {
slice := make([]mountSlot, cap, cap)
- hdr := (*reflect.SliceHeader)(unsafe.Pointer(&slice))
- return unsafe.Pointer(hdr.Data)
+ hdr := (*gohacks.SliceHeader)(unsafe.Pointer(&slice))
+ return hdr.Data
}
// Lookup returns the Mount with the given parent, mounted at the given point.