diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-09-30 21:49:10 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-30 21:49:10 +0000 |
commit | 59fa797a7af50f12b828915ff8de062d0fd1f552 (patch) | |
tree | 4d3b1dd64ce53aa13b4c43eeb9fc4cf9c0134da9 /pkg/abi | |
parent | 75fd25d8c8d3cd93994c73062b89856332cff984 (diff) | |
parent | 38704d9b667b9ebabc3f694a6508b37ead567b6f (diff) |
Merge release-20200921.0-91-g38704d9b6 (automated)
Diffstat (limited to 'pkg/abi')
-rw-r--r-- | pkg/abi/linux/ioctl.go | 20 | ||||
-rw-r--r-- | pkg/abi/linux/linux_abi_autogen_unsafe.go | 94 |
2 files changed, 113 insertions, 1 deletions
diff --git a/pkg/abi/linux/ioctl.go b/pkg/abi/linux/ioctl.go index dc9ac7e7c..7df02dd6d 100644 --- a/pkg/abi/linux/ioctl.go +++ b/pkg/abi/linux/ioctl.go @@ -121,9 +121,27 @@ const ( // Constants from uapi/linux/fsverity.h. const ( - FS_IOC_ENABLE_VERITY = 1082156677 + FS_IOC_ENABLE_VERITY = 1082156677 + FS_IOC_MEASURE_VERITY = 3221513862 ) +// DigestMetadata is a helper struct for VerityDigest. +// +// +marshal +type DigestMetadata struct { + DigestAlgorithm uint16 + DigestSize uint16 +} + +// SizeOfDigestMetadata is the size of struct DigestMetadata. +const SizeOfDigestMetadata = 4 + +// VerityDigest is struct from uapi/linux/fsverity.h. +type VerityDigest struct { + Metadata DigestMetadata + Digest []byte +} + // IOC outputs the result of _IOC macro in asm-generic/ioctl.h. func IOC(dir, typ, nr, size uint32) uint32 { return uint32(dir)<<_IOC_DIRSHIFT | typ<<_IOC_TYPESHIFT | nr<<_IOC_NRSHIFT | size<<_IOC_SIZESHIFT diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go index 834752961..b6f87d678 100644 --- a/pkg/abi/linux/linux_abi_autogen_unsafe.go +++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go @@ -19,6 +19,7 @@ var _ marshal.Marshallable = (*CapUserData)(nil) var _ marshal.Marshallable = (*CapUserHeader)(nil) var _ marshal.Marshallable = (*ClockT)(nil) var _ marshal.Marshallable = (*ControlMessageCredentials)(nil) +var _ marshal.Marshallable = (*DigestMetadata)(nil) var _ marshal.Marshallable = (*ExtensionName)(nil) var _ marshal.Marshallable = (*FOwnerEx)(nil) var _ marshal.Marshallable = (*FUSEAttr)(nil) @@ -3829,6 +3830,99 @@ func (r *RobustListHead) WriteTo(writer io.Writer) (int64, error) { } // SizeBytes implements marshal.Marshallable.SizeBytes. +func (d *DigestMetadata) SizeBytes() int { + return 4 +} + +// MarshalBytes implements marshal.Marshallable.MarshalBytes. +func (d *DigestMetadata) MarshalBytes(dst []byte) { + usermem.ByteOrder.PutUint16(dst[:2], uint16(d.DigestAlgorithm)) + dst = dst[2:] + usermem.ByteOrder.PutUint16(dst[:2], uint16(d.DigestSize)) + dst = dst[2:] +} + +// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. +func (d *DigestMetadata) UnmarshalBytes(src []byte) { + d.DigestAlgorithm = uint16(usermem.ByteOrder.Uint16(src[:2])) + src = src[2:] + d.DigestSize = uint16(usermem.ByteOrder.Uint16(src[:2])) + src = src[2:] +} + +// Packed implements marshal.Marshallable.Packed. +//go:nosplit +func (d *DigestMetadata) Packed() bool { + return true +} + +// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. +func (d *DigestMetadata) MarshalUnsafe(dst []byte) { + safecopy.CopyIn(dst, unsafe.Pointer(d)) +} + +// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. +func (d *DigestMetadata) UnmarshalUnsafe(src []byte) { + safecopy.CopyOut(unsafe.Pointer(d), src) +} + +// CopyOutN implements marshal.Marshallable.CopyOutN. +//go:nosplit +func (d *DigestMetadata) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error) { + // Construct a slice backed by dst's underlying memory. + var buf []byte + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) + hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) + hdr.Len = d.SizeBytes() + hdr.Cap = d.SizeBytes() + + length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + // Since we bypassed the compiler's escape analysis, indicate that d + // must live until the use above. + runtime.KeepAlive(d) // escapes: replaced by intrinsic. + return length, err +} + +// CopyOut implements marshal.Marshallable.CopyOut. +//go:nosplit +func (d *DigestMetadata) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + return d.CopyOutN(cc, addr, d.SizeBytes()) +} + +// CopyIn implements marshal.Marshallable.CopyIn. +//go:nosplit +func (d *DigestMetadata) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + // Construct a slice backed by dst's underlying memory. + var buf []byte + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) + hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) + hdr.Len = d.SizeBytes() + hdr.Cap = d.SizeBytes() + + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. + // Since we bypassed the compiler's escape analysis, indicate that d + // must live until the use above. + runtime.KeepAlive(d) // escapes: replaced by intrinsic. + return length, err +} + +// WriteTo implements io.WriterTo.WriteTo. +func (d *DigestMetadata) WriteTo(writer io.Writer) (int64, error) { + // Construct a slice backed by dst's underlying memory. + var buf []byte + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) + hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(d))) + hdr.Len = d.SizeBytes() + hdr.Cap = d.SizeBytes() + + length, err := writer.Write(buf) + // Since we bypassed the compiler's escape analysis, indicate that d + // must live until the use above. + runtime.KeepAlive(d) // escapes: replaced by intrinsic. + return int64(length), err +} + +// SizeBytes implements marshal.Marshallable.SizeBytes. func (i *IPCPerm) SizeBytes() int { return 48 } |