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 | |
parent | 3a197f66df7303d3bc89e89beeed02f22debda98 (diff) | |
parent | 5c1052b6bb2658208f1afaf423aeac98f30235c1 (diff) |
Merge release-20210408.0-30-g5c1052b6b (automated)
Diffstat (limited to 'pkg/sentry')
9 files changed, 52 insertions, 67 deletions
diff --git a/pkg/sentry/arch/arch_abi_autogen_unsafe.go b/pkg/sentry/arch/arch_abi_autogen_unsafe.go index 6ab83879c..92fb07615 100644 --- a/pkg/sentry/arch/arch_abi_autogen_unsafe.go +++ b/pkg/sentry/arch/arch_abi_autogen_unsafe.go @@ -15,7 +15,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" @@ -67,7 +66,7 @@ func (s *SignalAct) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SignalAct) MarshalUnsafe(dst []byte) { if s.Mask.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } else { // Type SignalAct doesn't have a packed layout in memory, fallback to MarshalBytes. s.MarshalBytes(dst) @@ -77,7 +76,7 @@ func (s *SignalAct) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SignalAct) UnmarshalUnsafe(src []byte) { if s.Mask.Packed() { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type SignalAct doesn't have a packed layout in memory, fallback to UnmarshalBytes. s.UnmarshalBytes(src) @@ -211,12 +210,12 @@ func (s *SignalInfo) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SignalInfo) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SignalInfo) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -312,12 +311,12 @@ func (s *SignalStack) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SignalStack) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SignalStack) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. diff --git a/pkg/sentry/arch/arch_amd64_abi_autogen_unsafe.go b/pkg/sentry/arch/arch_amd64_abi_autogen_unsafe.go index d8f71795b..e15495e50 100644 --- a/pkg/sentry/arch/arch_amd64_abi_autogen_unsafe.go +++ b/pkg/sentry/arch/arch_amd64_abi_autogen_unsafe.go @@ -17,7 +17,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" @@ -170,7 +169,7 @@ func (s *SignalContext64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SignalContext64) MarshalUnsafe(dst []byte) { if s.Oldmask.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } else { // Type SignalContext64 doesn't have a packed layout in memory, fallback to MarshalBytes. s.MarshalBytes(dst) @@ -180,7 +179,7 @@ func (s *SignalContext64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SignalContext64) UnmarshalUnsafe(src []byte) { if s.Oldmask.Packed() { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type SignalContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. s.UnmarshalBytes(src) @@ -313,7 +312,7 @@ func (u *UContext64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (u *UContext64) MarshalUnsafe(dst []byte) { if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(u)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(len(dst))) } else { // Type UContext64 doesn't have a packed layout in memory, fallback to MarshalBytes. u.MarshalBytes(dst) @@ -323,7 +322,7 @@ func (u *UContext64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (u *UContext64) UnmarshalUnsafe(src []byte) { if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() { - safecopy.CopyOut(unsafe.Pointer(u), src) + gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type UContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. u.UnmarshalBytes(src) diff --git a/pkg/sentry/arch/arch_arm64_abi_autogen_unsafe.go b/pkg/sentry/arch/arch_arm64_abi_autogen_unsafe.go index 40d0c1c75..cedd9688e 100644 --- a/pkg/sentry/arch/arch_arm64_abi_autogen_unsafe.go +++ b/pkg/sentry/arch/arch_arm64_abi_autogen_unsafe.go @@ -17,7 +17,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" @@ -76,7 +75,7 @@ func (f *FpsimdContext) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (f *FpsimdContext) MarshalUnsafe(dst []byte) { if f.Head.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(f)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(f), uintptr(len(dst))) } else { // Type FpsimdContext doesn't have a packed layout in memory, fallback to MarshalBytes. f.MarshalBytes(dst) @@ -86,7 +85,7 @@ func (f *FpsimdContext) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (f *FpsimdContext) UnmarshalUnsafe(src []byte) { if f.Head.Packed() { - safecopy.CopyOut(unsafe.Pointer(f), src) + gohacks.Memmove(unsafe.Pointer(f), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type FpsimdContext doesn't have a packed layout in memory, fallback to UnmarshalBytes. f.UnmarshalBytes(src) @@ -235,7 +234,7 @@ func (s *SignalContext64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SignalContext64) MarshalUnsafe(dst []byte) { if s.Fpsimd64.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } else { // Type SignalContext64 doesn't have a packed layout in memory, fallback to MarshalBytes. s.MarshalBytes(dst) @@ -245,7 +244,7 @@ func (s *SignalContext64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SignalContext64) UnmarshalUnsafe(src []byte) { if s.Fpsimd64.Packed() { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type SignalContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. s.UnmarshalBytes(src) @@ -396,7 +395,7 @@ func (u *UContext64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (u *UContext64) MarshalUnsafe(dst []byte) { if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(u)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(len(dst))) } else { // Type UContext64 doesn't have a packed layout in memory, fallback to MarshalBytes. u.MarshalBytes(dst) @@ -406,7 +405,7 @@ func (u *UContext64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (u *UContext64) UnmarshalUnsafe(src []byte) { if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() { - safecopy.CopyOut(unsafe.Pointer(u), src) + gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type UContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. u.UnmarshalBytes(src) @@ -523,12 +522,12 @@ func (a *aarch64Ctx) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (a *aarch64Ctx) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(a)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(a), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (a *aarch64Ctx) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(a), src) + gohacks.Memmove(unsafe.Pointer(a), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. 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 diff --git a/pkg/sentry/syscalls/linux/linux_abi_autogen_unsafe.go b/pkg/sentry/syscalls/linux/linux_abi_autogen_unsafe.go index 0eb2e184b..6201b2feb 100644 --- a/pkg/sentry/syscalls/linux/linux_abi_autogen_unsafe.go +++ b/pkg/sentry/syscalls/linux/linux_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" @@ -212,12 +211,12 @@ func (r *rlimit64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (r *rlimit64) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(r)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(r), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (r *rlimit64) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(r), src) + gohacks.Memmove(unsafe.Pointer(r), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -301,12 +300,12 @@ func (s *SchedParam) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *SchedParam) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *SchedParam) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -399,12 +398,12 @@ func (u *userSockFprog) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (u *userSockFprog) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(u)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (u *userSockFprog) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(u), src) + gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -520,12 +519,12 @@ func (m *MessageHeader64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (m *MessageHeader64) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(m)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (m *MessageHeader64) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(m), src) + gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -619,7 +618,7 @@ func (m *multipleMessageHeader64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (m *multipleMessageHeader64) MarshalUnsafe(dst []byte) { if m.msgHdr.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(m)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(len(dst))) } else { // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to MarshalBytes. m.MarshalBytes(dst) @@ -629,7 +628,7 @@ func (m *multipleMessageHeader64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (m *multipleMessageHeader64) UnmarshalUnsafe(src []byte) { if m.msgHdr.Packed() { - safecopy.CopyOut(unsafe.Pointer(m), src) + gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. m.UnmarshalBytes(src) diff --git a/pkg/sentry/syscalls/linux/vfs2/vfs2_abi_autogen_unsafe.go b/pkg/sentry/syscalls/linux/vfs2/vfs2_abi_autogen_unsafe.go index d9e2dd3d9..97fc5d2a8 100644 --- a/pkg/sentry/syscalls/linux/vfs2/vfs2_abi_autogen_unsafe.go +++ b/pkg/sentry/syscalls/linux/vfs2/vfs2_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" @@ -53,12 +52,12 @@ func (s *sigSetWithSize) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (s *sigSetWithSize) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(s)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (s *sigSetWithSize) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(s), src) + gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -174,12 +173,12 @@ func (m *MessageHeader64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (m *MessageHeader64) MarshalUnsafe(dst []byte) { - safecopy.CopyIn(dst, unsafe.Pointer(m)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(len(dst))) } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (m *MessageHeader64) UnmarshalUnsafe(src []byte) { - safecopy.CopyOut(unsafe.Pointer(m), src) + gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(len(src))) } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -273,7 +272,7 @@ func (m *multipleMessageHeader64) Packed() bool { // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. func (m *multipleMessageHeader64) MarshalUnsafe(dst []byte) { if m.msgHdr.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(m)) + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(len(dst))) } else { // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to MarshalBytes. m.MarshalBytes(dst) @@ -283,7 +282,7 @@ func (m *multipleMessageHeader64) MarshalUnsafe(dst []byte) { // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. func (m *multipleMessageHeader64) UnmarshalUnsafe(src []byte) { if m.msgHdr.Packed() { - safecopy.CopyOut(unsafe.Pointer(m), src) + gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(len(src))) } else { // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. m.UnmarshalBytes(src) diff --git a/pkg/sentry/time/seqatomic_parameters_unsafe.go b/pkg/sentry/time/seqatomic_parameters_unsafe.go index e57055fc7..357e476ec 100644 --- a/pkg/sentry/time/seqatomic_parameters_unsafe.go +++ b/pkg/sentry/time/seqatomic_parameters_unsafe.go @@ -3,6 +3,7 @@ package time import ( "unsafe" + "gvisor.dev/gvisor/pkg/gohacks" "gvisor.dev/gvisor/pkg/sync" ) @@ -27,7 +28,7 @@ func SeqAtomicLoadParameters(seq *sync.SeqCount, ptr *Parameters) Parameters { func SeqAtomicTryLoadParameters(seq *sync.SeqCount, epoch sync.SeqCountEpoch, ptr *Parameters) (val Parameters, 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 |