diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-09-16 09:13:19 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-16 09:13:19 +0000 |
commit | ce5807fdb4a544ef045be0f8641aa88341ca1f9a (patch) | |
tree | 91c5040b4555592a65472496d274dfb9dd14188f /pkg/sentry/kernel | |
parent | 6ca48576e8a40e169dc10e17084bbceecf8a0055 (diff) | |
parent | 9ef1c7992232e82b8e6214dd1dd61a23ee9419a9 (diff) |
Merge release-20200907.0-58-g9ef1c7992 (automated)
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go | 32 | ||||
-rw-r--r-- | pkg/sentry/kernel/fd_table_refs.go | 3 | ||||
-rw-r--r-- | pkg/sentry/kernel/fs_context_refs.go | 3 | ||||
-rw-r--r-- | pkg/sentry/kernel/kernel_abi_autogen_unsafe.go | 12 | ||||
-rw-r--r-- | pkg/sentry/kernel/process_group_refs.go | 3 | ||||
-rw-r--r-- | pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go | 6 | ||||
-rw-r--r-- | pkg/sentry/kernel/session_refs.go | 3 | ||||
-rw-r--r-- | pkg/sentry/kernel/shm/shm_refs.go | 3 | ||||
-rw-r--r-- | pkg/sentry/kernel/task_usermem.go | 17 |
9 files changed, 39 insertions, 43 deletions
diff --git a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go index 2c76bf792..e7892288b 100644 --- a/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go +++ b/pkg/sentry/kernel/auth/auth_abi_autogen_unsafe.go @@ -52,7 +52,7 @@ func (u *UID) UnmarshalUnsafe(src []byte) { // CopyOutN implements marshal.Marshallable.CopyOutN. //go:nosplit -func (u *UID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, error) { +func (u *UID) 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)) @@ -60,7 +60,7 @@ func (u *UID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, er hdr.Len = u.SizeBytes() hdr.Cap = u.SizeBytes() - length, err := task.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that u // must live until the use above. runtime.KeepAlive(u) // escapes: replaced by intrinsic. @@ -69,13 +69,13 @@ func (u *UID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, er // CopyOut implements marshal.Marshallable.CopyOut. //go:nosplit -func (u *UID) CopyOut(task marshal.Task, addr usermem.Addr) (int, error) { - return u.CopyOutN(task, addr, u.SizeBytes()) +func (u *UID) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + return u.CopyOutN(cc, addr, u.SizeBytes()) } // CopyIn implements marshal.Marshallable.CopyIn. //go:nosplit -func (u *UID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { +func (u *UID) 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)) @@ -83,7 +83,7 @@ func (u *UID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { hdr.Len = u.SizeBytes() hdr.Cap = u.SizeBytes() - length, err := task.CopyInBytes(addr, buf) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that u // must live until the use above. runtime.KeepAlive(u) // escapes: replaced by intrinsic. @@ -141,7 +141,7 @@ func (g *GID) UnmarshalUnsafe(src []byte) { // CopyOutN implements marshal.Marshallable.CopyOutN. //go:nosplit -func (g *GID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, error) { +func (g *GID) 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)) @@ -149,7 +149,7 @@ func (g *GID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, er hdr.Len = g.SizeBytes() hdr.Cap = g.SizeBytes() - length, err := task.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that g // must live until the use above. runtime.KeepAlive(g) // escapes: replaced by intrinsic. @@ -158,13 +158,13 @@ func (g *GID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, er // CopyOut implements marshal.Marshallable.CopyOut. //go:nosplit -func (g *GID) CopyOut(task marshal.Task, addr usermem.Addr) (int, error) { - return g.CopyOutN(task, addr, g.SizeBytes()) +func (g *GID) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + return g.CopyOutN(cc, addr, g.SizeBytes()) } // CopyIn implements marshal.Marshallable.CopyIn. //go:nosplit -func (g *GID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { +func (g *GID) 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)) @@ -172,7 +172,7 @@ func (g *GID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { hdr.Len = g.SizeBytes() hdr.Cap = g.SizeBytes() - length, err := task.CopyInBytes(addr, buf) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that g // must live until the use above. runtime.KeepAlive(g) // escapes: replaced by intrinsic. @@ -197,7 +197,7 @@ func (g *GID) WriteTo(w io.Writer) (int64, error) { // CopyGIDSliceIn copies in a slice of GID objects from the task's memory. //go:nosplit -func CopyGIDSliceIn(task marshal.Task, addr usermem.Addr, dst []GID) (int, error) { +func CopyGIDSliceIn(cc marshal.CopyContext, addr usermem.Addr, dst []GID) (int, error) { count := len(dst) if count == 0 { return 0, nil @@ -214,7 +214,7 @@ func CopyGIDSliceIn(task marshal.Task, addr usermem.Addr, dst []GID) (int, error hdr.Len = size * count hdr.Cap = size * count - length, err := task.CopyInBytes(addr, buf) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that dst // must live until the use above. runtime.KeepAlive(dst) // escapes: replaced by intrinsic. @@ -223,7 +223,7 @@ func CopyGIDSliceIn(task marshal.Task, addr usermem.Addr, dst []GID) (int, error // CopyGIDSliceOut copies a slice of GID objects to the task's memory. //go:nosplit -func CopyGIDSliceOut(task marshal.Task, addr usermem.Addr, src []GID) (int, error) { +func CopyGIDSliceOut(cc marshal.CopyContext, addr usermem.Addr, src []GID) (int, error) { count := len(src) if count == 0 { return 0, nil @@ -240,7 +240,7 @@ func CopyGIDSliceOut(task marshal.Task, addr usermem.Addr, src []GID) (int, erro hdr.Len = size * count hdr.Cap = size * count - length, err := task.CopyOutBytes(addr, buf) // escapes: okay. + length, err := cc.CopyOutBytes(addr, buf) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that src // must live until the use above. runtime.KeepAlive(src) // escapes: replaced by intrinsic. diff --git a/pkg/sentry/kernel/fd_table_refs.go b/pkg/sentry/kernel/fd_table_refs.go index 8973cac8a..a630289c9 100644 --- a/pkg/sentry/kernel/fd_table_refs.go +++ b/pkg/sentry/kernel/fd_table_refs.go @@ -2,11 +2,10 @@ package kernel import ( "fmt" + "gvisor.dev/gvisor/pkg/log" refs_vfs1 "gvisor.dev/gvisor/pkg/refs" "runtime" "sync/atomic" - - "gvisor.dev/gvisor/pkg/log" ) // ownerType is used to customize logging. Note that we use a pointer to T so diff --git a/pkg/sentry/kernel/fs_context_refs.go b/pkg/sentry/kernel/fs_context_refs.go index c0e01dbb3..e8bb1e6ee 100644 --- a/pkg/sentry/kernel/fs_context_refs.go +++ b/pkg/sentry/kernel/fs_context_refs.go @@ -2,11 +2,10 @@ package kernel import ( "fmt" + "gvisor.dev/gvisor/pkg/log" refs_vfs1 "gvisor.dev/gvisor/pkg/refs" "runtime" "sync/atomic" - - "gvisor.dev/gvisor/pkg/log" ) // ownerType is used to customize logging. Note that we use a pointer to T so diff --git a/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go b/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go index c8945fb0e..eaa2ebdb3 100644 --- a/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go +++ b/pkg/sentry/kernel/kernel_abi_autogen_unsafe.go @@ -51,7 +51,7 @@ func (t *ThreadID) UnmarshalUnsafe(src []byte) { // CopyOutN implements marshal.Marshallable.CopyOutN. //go:nosplit -func (t *ThreadID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (int, error) { +func (t *ThreadID) 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)) @@ -59,7 +59,7 @@ func (t *ThreadID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (in hdr.Len = t.SizeBytes() hdr.Cap = t.SizeBytes() - length, err := task.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that t // must live until the use above. runtime.KeepAlive(t) // escapes: replaced by intrinsic. @@ -68,13 +68,13 @@ func (t *ThreadID) CopyOutN(task marshal.Task, addr usermem.Addr, limit int) (in // CopyOut implements marshal.Marshallable.CopyOut. //go:nosplit -func (t *ThreadID) CopyOut(task marshal.Task, addr usermem.Addr) (int, error) { - return t.CopyOutN(task, addr, t.SizeBytes()) +func (t *ThreadID) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + return t.CopyOutN(cc, addr, t.SizeBytes()) } // CopyIn implements marshal.Marshallable.CopyIn. //go:nosplit -func (t *ThreadID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { +func (t *ThreadID) 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)) @@ -82,7 +82,7 @@ func (t *ThreadID) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) { hdr.Len = t.SizeBytes() hdr.Cap = t.SizeBytes() - length, err := task.CopyInBytes(addr, buf) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. // Since we bypassed the compiler's escape analysis, indicate that t // must live until the use above. runtime.KeepAlive(t) // escapes: replaced by intrinsic. diff --git a/pkg/sentry/kernel/process_group_refs.go b/pkg/sentry/kernel/process_group_refs.go index 5ff83ab96..4b257d548 100644 --- a/pkg/sentry/kernel/process_group_refs.go +++ b/pkg/sentry/kernel/process_group_refs.go @@ -2,11 +2,10 @@ package kernel import ( "fmt" + "gvisor.dev/gvisor/pkg/log" refs_vfs1 "gvisor.dev/gvisor/pkg/refs" "runtime" "sync/atomic" - - "gvisor.dev/gvisor/pkg/log" ) // ownerType is used to customize logging. Note that we use a pointer to T so diff --git a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go index a0f2fe45c..90148bbb2 100644 --- a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go +++ b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go @@ -1,12 +1,12 @@ package kernel import ( - "unsafe" - "fmt" - "gvisor.dev/gvisor/pkg/sync" "reflect" "strings" + "unsafe" + + "gvisor.dev/gvisor/pkg/sync" ) // SeqAtomicLoad returns a copy of *ptr, ensuring that the read does not race diff --git a/pkg/sentry/kernel/session_refs.go b/pkg/sentry/kernel/session_refs.go index 9c51eda6c..204fdd060 100644 --- a/pkg/sentry/kernel/session_refs.go +++ b/pkg/sentry/kernel/session_refs.go @@ -2,11 +2,10 @@ package kernel import ( "fmt" + "gvisor.dev/gvisor/pkg/log" refs_vfs1 "gvisor.dev/gvisor/pkg/refs" "runtime" "sync/atomic" - - "gvisor.dev/gvisor/pkg/log" ) // ownerType is used to customize logging. Note that we use a pointer to T so diff --git a/pkg/sentry/kernel/shm/shm_refs.go b/pkg/sentry/kernel/shm/shm_refs.go index 0da23fa5f..4bffdd0b3 100644 --- a/pkg/sentry/kernel/shm/shm_refs.go +++ b/pkg/sentry/kernel/shm/shm_refs.go @@ -2,11 +2,10 @@ package shm import ( "fmt" + "gvisor.dev/gvisor/pkg/log" refs_vfs1 "gvisor.dev/gvisor/pkg/refs" "runtime" "sync/atomic" - - "gvisor.dev/gvisor/pkg/log" ) // ownerType is used to customize logging. Note that we use a pointer to T so diff --git a/pkg/sentry/kernel/task_usermem.go b/pkg/sentry/kernel/task_usermem.go index 14d765af1..ce134bf54 100644 --- a/pkg/sentry/kernel/task_usermem.go +++ b/pkg/sentry/kernel/task_usermem.go @@ -18,6 +18,7 @@ import ( "math" "gvisor.dev/gvisor/pkg/abi/linux" + "gvisor.dev/gvisor/pkg/marshal" "gvisor.dev/gvisor/pkg/syserror" "gvisor.dev/gvisor/pkg/usermem" ) @@ -280,29 +281,29 @@ func (t *Task) IovecsIOSequence(addr usermem.Addr, iovcnt int, opts usermem.IOOp }, nil } -// CopyContext wraps a task to allow copying memory to and from the -// task memory with user specified usermem.IOOpts. -type CopyContext struct { +// copyContext implements marshal.CopyContext. It wraps a task to allow copying +// memory to and from the task memory with custom usermem.IOOpts. +type copyContext struct { *Task opts usermem.IOOpts } // AsCopyContext wraps the task and returns it as CopyContext. -func (t *Task) AsCopyContext(opts usermem.IOOpts) *CopyContext { - return &CopyContext{t, opts} +func (t *Task) AsCopyContext(opts usermem.IOOpts) marshal.CopyContext { + return ©Context{t, opts} } // CopyInString copies a string in from the task's memory. -func (t *CopyContext) CopyInString(addr usermem.Addr, maxLen int) (string, error) { +func (t *copyContext) CopyInString(addr usermem.Addr, maxLen int) (string, error) { return usermem.CopyStringIn(t, t.MemoryManager(), addr, maxLen, t.opts) } // CopyInBytes copies task memory into dst from an IO context. -func (t *CopyContext) CopyInBytes(addr usermem.Addr, dst []byte) (int, error) { +func (t *copyContext) CopyInBytes(addr usermem.Addr, dst []byte) (int, error) { return t.MemoryManager().CopyIn(t, addr, dst, t.opts) } // CopyOutBytes copies src into task memoryfrom an IO context. -func (t *CopyContext) CopyOutBytes(addr usermem.Addr, src []byte) (int, error) { +func (t *copyContext) CopyOutBytes(addr usermem.Addr, src []byte) (int, error) { return t.MemoryManager().CopyOut(t, addr, src, t.opts) } |