Fix races in kernel.(*Task).Value()

PiperOrigin-RevId: 209627180
Change-Id: Idc84afd38003427e411df6e75abfabd9174174e1
This commit is contained in:
Ian Gudger 2018-08-21 11:15:15 -07:00 committed by Shentubot
parent 47d5a12ce5
commit 9c407382b0
1 changed files with 6 additions and 0 deletions

View File

@ -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())