Skip to content

Commit 7a7d8c3

Browse files
shailend-ggvisor-bot
authored andcommitted
Fix data race on t.tg.exitStatus in runExitMain
Acquire the t.tg.signalHandlers.mu lock before reading t.tg.exitStatus for the seccheck.PointTaskExit event to prevent a data race with prepareGroupExitLocked. PiperOrigin-RevId: 960540807
1 parent 8f03842 commit 7a7d8c3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/sentry/kernel/task_exit.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,11 @@ func (*runExitMain) execute(t *Task) taskRunState {
244244
t.traceExitEvent()
245245

246246
if seccheck.Global.Enabled(seccheck.PointTaskExit) {
247+
t.tg.signalHandlers.mu.Lock()
248+
exitStatus := int32(t.tg.exitStatus)
249+
t.tg.signalHandlers.mu.Unlock()
247250
info := &pb.TaskExit{
248-
ExitStatus: int32(t.tg.exitStatus),
251+
ExitStatus: exitStatus,
249252
}
250253
fields := seccheck.Global.GetFieldSet(seccheck.PointTaskExit)
251254
if !fields.Context.Empty() {

0 commit comments

Comments
 (0)