summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/task_run.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-23 23:28:29 +0000
committergVisor bot <gvisor-bot@google.com>2020-07-23 23:28:29 +0000
commit1d05051701a6f92a093b8948b58f4bf2128eebdd (patch)
tree92a7d5042a2fdadc6d8a024767d949b0768fe896 /pkg/sentry/kernel/task_run.go
parentd82960ab03b27d5c0bd0decb137efc82e34c4fa8 (diff)
parent8fed97794edcbaa7069dbd39604030e4fbb6891c (diff)
Merge release-20200622.1-203-g8fed97794 (automated)
Diffstat (limited to 'pkg/sentry/kernel/task_run.go')
-rw-r--r--pkg/sentry/kernel/task_run.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/task_run.go b/pkg/sentry/kernel/task_run.go
index d654dd997..7d4f44caf 100644
--- a/pkg/sentry/kernel/task_run.go
+++ b/pkg/sentry/kernel/task_run.go
@@ -167,7 +167,22 @@ func (app *runApp) execute(t *Task) taskRunState {
return (*runInterrupt)(nil)
}
- // We're about to switch to the application again. If there's still a
+ // Execute any task work callbacks before returning to user space.
+ if atomic.LoadInt32(&t.taskWorkCount) > 0 {
+ t.taskWorkMu.Lock()
+ queue := t.taskWork
+ t.taskWork = nil
+ atomic.StoreInt32(&t.taskWorkCount, 0)
+ t.taskWorkMu.Unlock()
+
+ // Do not hold taskWorkMu while executing task work, which may register
+ // more work.
+ for _, work := range queue {
+ work.TaskWork(t)
+ }
+ }
+
+ // We're about to switch to the application again. If there's still an
// unhandled SyscallRestartErrno that wasn't translated to an EINTR,
// restart the syscall that was interrupted. If there's a saved signal
// mask, restore it. (Note that restoring the saved signal mask may unblock