diff options
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go | 36 | ||||
-rw-r--r-- | pkg/sentry/kernel/kernel_abi_autogen_unsafe.go | 36 |
2 files changed, 48 insertions, 24 deletions
diff --git a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go index 393dcea8c..770e66602 100644 --- a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go +++ b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go @@ -23,13 +23,15 @@ func (gid *GID) SizeBytes() int { } // MarshalBytes implements marshal.Marshallable.MarshalBytes. -func (gid *GID) MarshalBytes(dst []byte) { +func (gid *GID) MarshalBytes(dst []byte) []byte { hostarch.ByteOrder.PutUint32(dst[:4], uint32(*gid)) + return dst[4:] } // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. -func (gid *GID) UnmarshalBytes(src []byte) { +func (gid *GID) UnmarshalBytes(src []byte) []byte { *gid = GID(uint32(hostarch.ByteOrder.Uint32(src[:4]))) + return src[4:] } // Packed implements marshal.Marshallable.Packed. @@ -40,13 +42,17 @@ func (gid *GID) Packed() bool { } // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. -func (gid *GID) MarshalUnsafe(dst []byte) { - gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(gid), uintptr(gid.SizeBytes())) +func (gid *GID) MarshalUnsafe(dst []byte) []byte { + size := gid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(gid), uintptr(size)) + return dst[size:] } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. -func (gid *GID) UnmarshalUnsafe(src []byte) { - gohacks.Memmove(unsafe.Pointer(gid), unsafe.Pointer(&src[0]), uintptr(gid.SizeBytes())) +func (gid *GID) UnmarshalUnsafe(src []byte) []byte { + size := gid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(gid), unsafe.Pointer(&src[0]), uintptr(size)) + return src[size:] } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -190,13 +196,15 @@ func (uid *UID) SizeBytes() int { } // MarshalBytes implements marshal.Marshallable.MarshalBytes. -func (uid *UID) MarshalBytes(dst []byte) { +func (uid *UID) MarshalBytes(dst []byte) []byte { hostarch.ByteOrder.PutUint32(dst[:4], uint32(*uid)) + return dst[4:] } // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. -func (uid *UID) UnmarshalBytes(src []byte) { +func (uid *UID) UnmarshalBytes(src []byte) []byte { *uid = UID(uint32(hostarch.ByteOrder.Uint32(src[:4]))) + return src[4:] } // Packed implements marshal.Marshallable.Packed. @@ -207,13 +215,17 @@ func (uid *UID) Packed() bool { } // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. -func (uid *UID) MarshalUnsafe(dst []byte) { - gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(uid), uintptr(uid.SizeBytes())) +func (uid *UID) MarshalUnsafe(dst []byte) []byte { + size := uid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(uid), uintptr(size)) + return dst[size:] } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. -func (uid *UID) UnmarshalUnsafe(src []byte) { - gohacks.Memmove(unsafe.Pointer(uid), unsafe.Pointer(&src[0]), uintptr(uid.SizeBytes())) +func (uid *UID) UnmarshalUnsafe(src []byte) []byte { + size := uid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(uid), unsafe.Pointer(&src[0]), uintptr(size)) + return src[size:] } // 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 83ed0f8ac..fe5ee7463 100644 --- a/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go +++ b/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go @@ -23,13 +23,15 @@ func (tid *ThreadID) SizeBytes() int { } // MarshalBytes implements marshal.Marshallable.MarshalBytes. -func (tid *ThreadID) MarshalBytes(dst []byte) { +func (tid *ThreadID) MarshalBytes(dst []byte) []byte { hostarch.ByteOrder.PutUint32(dst[:4], uint32(*tid)) + return dst[4:] } // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. -func (tid *ThreadID) UnmarshalBytes(src []byte) { +func (tid *ThreadID) UnmarshalBytes(src []byte) []byte { *tid = ThreadID(int32(hostarch.ByteOrder.Uint32(src[:4]))) + return src[4:] } // Packed implements marshal.Marshallable.Packed. @@ -40,13 +42,17 @@ func (tid *ThreadID) Packed() bool { } // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. -func (tid *ThreadID) MarshalUnsafe(dst []byte) { - gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(tid), uintptr(tid.SizeBytes())) +func (tid *ThreadID) MarshalUnsafe(dst []byte) []byte { + size := tid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(tid), uintptr(size)) + return dst[size:] } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. -func (tid *ThreadID) UnmarshalUnsafe(src []byte) { - gohacks.Memmove(unsafe.Pointer(tid), unsafe.Pointer(&src[0]), uintptr(tid.SizeBytes())) +func (tid *ThreadID) UnmarshalUnsafe(src []byte) []byte { + size := tid.SizeBytes() + gohacks.Memmove(unsafe.Pointer(tid), unsafe.Pointer(&src[0]), uintptr(size)) + return src[size:] } // CopyOutN implements marshal.Marshallable.CopyOutN. @@ -111,7 +117,7 @@ func (v *vdsoParams) SizeBytes() int { } // MarshalBytes implements marshal.Marshallable.MarshalBytes. -func (v *vdsoParams) MarshalBytes(dst []byte) { +func (v *vdsoParams) MarshalBytes(dst []byte) []byte { hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicReady)) dst = dst[8:] hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicBaseCycles)) @@ -128,10 +134,11 @@ func (v *vdsoParams) MarshalBytes(dst []byte) { dst = dst[8:] hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.realtimeFrequency)) dst = dst[8:] + return dst } // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. -func (v *vdsoParams) UnmarshalBytes(src []byte) { +func (v *vdsoParams) UnmarshalBytes(src []byte) []byte { v.monotonicReady = uint64(hostarch.ByteOrder.Uint64(src[:8])) src = src[8:] v.monotonicBaseCycles = int64(hostarch.ByteOrder.Uint64(src[:8])) @@ -148,6 +155,7 @@ func (v *vdsoParams) UnmarshalBytes(src []byte) { src = src[8:] v.realtimeFrequency = uint64(hostarch.ByteOrder.Uint64(src[:8])) src = src[8:] + return src } // Packed implements marshal.Marshallable.Packed. @@ -157,13 +165,17 @@ func (v *vdsoParams) Packed() bool { } // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. -func (v *vdsoParams) MarshalUnsafe(dst []byte) { - gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(v), uintptr(v.SizeBytes())) +func (v *vdsoParams) MarshalUnsafe(dst []byte) []byte { + size := v.SizeBytes() + gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(v), uintptr(size)) + return dst[size:] } // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. -func (v *vdsoParams) UnmarshalUnsafe(src []byte) { - gohacks.Memmove(unsafe.Pointer(v), unsafe.Pointer(&src[0]), uintptr(v.SizeBytes())) +func (v *vdsoParams) UnmarshalUnsafe(src []byte) []byte { + size := v.SizeBytes() + gohacks.Memmove(unsafe.Pointer(v), unsafe.Pointer(&src[0]), uintptr(size)) + return src[size:] } // CopyOutN implements marshal.Marshallable.CopyOutN. |