summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/task.go
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-08-21 11:15:15 -0700
committerShentubot <shentubot@google.com>2018-08-21 11:16:17 -0700
commit9c407382b031f16160f83383ef8b0d419457829a (patch)
tree321ffca15d4a441c909266e452c37f47f4b56a75 /pkg/sentry/kernel/task.go
parent47d5a12ce565a2a63fca3fd70cc073f9883bacd0 (diff)
Fix races in kernel.(*Task).Value()
PiperOrigin-RevId: 209627180 Change-Id: Idc84afd38003427e411df6e75abfabd9174174e1
Diffstat (limited to 'pkg/sentry/kernel/task.go')
-rw-r--r--pkg/sentry/kernel/task.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/task.go b/pkg/sentry/kernel/task.go
index 19029adb1..0f83c0a39 100644
--- a/pkg/sentry/kernel/task.go
+++ b/pkg/sentry/kernel/task.go
@@ -568,12 +568,18 @@ func (t *Task) Value(key interface{}) interface{} {
case CtxPIDNamespace:
return t.tg.pidns
case CtxUTSNamespace:
+ t.mu.Lock()
+ defer t.mu.Unlock()
return t.utsns
case CtxIPCNamespace:
+ t.mu.Lock()
+ defer t.mu.Unlock()
return t.ipcns
case CtxTask:
return t
case auth.CtxCredentials:
+ t.mu.Lock()
+ defer t.mu.Unlock()
return t.creds
case context.CtxThreadGroupID:
return int32(t.ThreadGroup().ID())