summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-04-14 18:37:19 +0000
committergVisor bot <gvisor-bot@google.com>2021-04-14 18:37:19 +0000
commitca506c33c1f00c4e57f640340178007a813d3454 (patch)
tree52ef7111534dd020c5d026c3acc026769b863ecf /pkg/sentry/kernel
parent3a197f66df7303d3bc89e89beeed02f22debda98 (diff)
parent5c1052b6bb2658208f1afaf423aeac98f30235c1 (diff)
Merge release-20210408.0-30-g5c1052b6b (automated)
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r--pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go31
-rw-r--r--pkg/sentry/kernel/kernel_abi_autogen_unsafe.go9
-rw-r--r--pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go3
3 files changed, 16 insertions, 27 deletions
diff --git a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
index 89239952c..117bb06e7 100644
--- a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
+++ b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go
@@ -12,7 +12,6 @@ import (
"gvisor.dev/gvisor/pkg/gohacks"
"gvisor.dev/gvisor/pkg/hostarch"
"gvisor.dev/gvisor/pkg/marshal"
- "gvisor.dev/gvisor/pkg/safecopy"
"io"
"reflect"
"runtime"
@@ -48,12 +47,12 @@ func (gid *GID) Packed() bool {
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (gid *GID) MarshalUnsafe(dst []byte) {
- safecopy.CopyIn(dst, unsafe.Pointer(gid))
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(gid), uintptr(len(dst)))
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (gid *GID) UnmarshalUnsafe(src []byte) {
- safecopy.CopyOut(unsafe.Pointer(gid), src)
+ gohacks.Memmove(unsafe.Pointer(gid), unsafe.Pointer(&src[0]), uintptr(len(src)))
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
@@ -172,14 +171,9 @@ func MarshalUnsafeGIDSlice(src []GID, dst []byte) (int, error) {
}
size := (*GID)(nil).SizeBytes()
- ptr := unsafe.Pointer(&src)
- val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
-
- length, err := safecopy.CopyIn(dst[:(size*count)], val)
- // Since we bypassed the compiler's escape analysis, indicate that src
- // must live until the use above.
- runtime.KeepAlive(src) // escapes: replaced by intrinsic.
- return length, err
+ dst = dst[:size*count]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(dst)))
+ return size*count, nil
}
// UnmarshalUnsafeGIDSlice is like GID.UnmarshalUnsafe, but for a []GID.
@@ -190,14 +184,9 @@ func UnmarshalUnsafeGIDSlice(dst []GID, src []byte) (int, error) {
}
size := (*GID)(nil).SizeBytes()
- ptr := unsafe.Pointer(&dst)
- val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
-
- length, err := safecopy.CopyOut(val, src[:(size*count)])
- // Since we bypassed the compiler's escape analysis, indicate that dst
- // must live until the use above.
- runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
- return length, err
+ src = src[:(size*count)]
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&src[0]), uintptr(len(src)))
+ return size*count, nil
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
@@ -225,12 +214,12 @@ func (uid *UID) Packed() bool {
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (uid *UID) MarshalUnsafe(dst []byte) {
- safecopy.CopyIn(dst, unsafe.Pointer(uid))
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(uid), uintptr(len(dst)))
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (uid *UID) UnmarshalUnsafe(src []byte) {
- safecopy.CopyOut(unsafe.Pointer(uid), src)
+ gohacks.Memmove(unsafe.Pointer(uid), unsafe.Pointer(&src[0]), uintptr(len(src)))
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
diff --git a/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go b/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go
index 0494f7c31..548178cee 100644
--- a/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go
+++ b/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go
@@ -12,7 +12,6 @@ import (
"gvisor.dev/gvisor/pkg/gohacks"
"gvisor.dev/gvisor/pkg/hostarch"
"gvisor.dev/gvisor/pkg/marshal"
- "gvisor.dev/gvisor/pkg/safecopy"
"io"
"reflect"
"runtime"
@@ -48,12 +47,12 @@ func (tid *ThreadID) Packed() bool {
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (tid *ThreadID) MarshalUnsafe(dst []byte) {
- safecopy.CopyIn(dst, unsafe.Pointer(tid))
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(tid), uintptr(len(dst)))
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (tid *ThreadID) UnmarshalUnsafe(src []byte) {
- safecopy.CopyOut(unsafe.Pointer(tid), src)
+ gohacks.Memmove(unsafe.Pointer(tid), unsafe.Pointer(&src[0]), uintptr(len(src)))
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
@@ -165,12 +164,12 @@ func (v *vdsoParams) Packed() bool {
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (v *vdsoParams) MarshalUnsafe(dst []byte) {
- safecopy.CopyIn(dst, unsafe.Pointer(v))
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(v), uintptr(len(dst)))
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (v *vdsoParams) UnmarshalUnsafe(src []byte) {
- safecopy.CopyOut(unsafe.Pointer(v), src)
+ gohacks.Memmove(unsafe.Pointer(v), unsafe.Pointer(&src[0]), uintptr(len(src)))
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
diff --git a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
index 4ad42efdf..d45cc0a0f 100644
--- a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
+++ b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
@@ -3,6 +3,7 @@ package kernel
import (
"unsafe"
+ "gvisor.dev/gvisor/pkg/gohacks"
"gvisor.dev/gvisor/pkg/sync"
)
@@ -27,7 +28,7 @@ func SeqAtomicLoadTaskGoroutineSchedInfo(seq *sync.SeqCount, ptr *TaskGoroutineS
func SeqAtomicTryLoadTaskGoroutineSchedInfo(seq *sync.SeqCount, epoch sync.SeqCountEpoch, ptr *TaskGoroutineSchedInfo) (val TaskGoroutineSchedInfo, ok bool) {
if sync.RaceEnabled {
- sync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ gohacks.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr