diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-04-14 18:37:19 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-14 18:37:19 +0000 |
commit | ca506c33c1f00c4e57f640340178007a813d3454 (patch) | |
tree | 52ef7111534dd020c5d026c3acc026769b863ecf /pkg/sentry/kernel/auth | |
parent | 3a197f66df7303d3bc89e89beeed02f22debda98 (diff) | |
parent | 5c1052b6bb2658208f1afaf423aeac98f30235c1 (diff) |
Merge release-20210408.0-30-g5c1052b6b (automated)
Diffstat (limited to 'pkg/sentry/kernel/auth')
-rw-r--r-- | pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go | 31 |
1 files changed, 10 insertions, 21 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. |