kernel: use the kernel context to run task destroy actions

A task context can be used only if actions are executed in a task goroutine.
In addition, these actions are executed asynchronously, so the task can be
destroyed.

Reported-by: syzbot+a9f3e03ea801374b8089@syzkaller.appspotmail.com
PiperOrigin-RevId: 706078457
This commit is contained in:
Andrei Vagin
2024-12-13 19:08:53 -08:00
committed by gVisor bot
parent bd0cbf8071
commit c27c9a02ae
+2 -1
View File
@@ -798,13 +798,14 @@ func (t *Task) execOnDestroyActions() {
if len(actions) == 0 {
return
}
ctx := t.k.SupervisorContext()
// Block S/R until all actions is executed.
t.k.tasks.aioGoroutines.Add(1)
// Run in another goroutine to avoid extra lock dependencies.
go func() {
defer t.k.tasks.aioGoroutines.Done()
for act := range actions {
act.TaskDestroyAction(t)
act.TaskDestroyAction(ctx)
}
}()
}