From c27c9a02aef5a208712d9ea57f8027f09337ab39 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 13 Dec 2024 19:01:11 -0800 Subject: [PATCH] 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 --- pkg/sentry/kernel/task_exit.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/kernel/task_exit.go b/pkg/sentry/kernel/task_exit.go index 38cc377cb..69a174180 100644 --- a/pkg/sentry/kernel/task_exit.go +++ b/pkg/sentry/kernel/task_exit.go @@ -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) } }() }