From 507a15dce974d0cff18253ba50af29d6579bacc5 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 28 May 2019 18:02:07 -0700 Subject: Always wait on tracee children After bf959931ddb88c4e4366e96dd22e68fa0db9527c ("wait/ptrace: assume __WALL if the child is traced") (Linux 4.7), tracees are always eligible for waiting, regardless of type. PiperOrigin-RevId: 250399527 --- pkg/sentry/kernel/task_exit.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'pkg/sentry/kernel') diff --git a/pkg/sentry/kernel/task_exit.go b/pkg/sentry/kernel/task_exit.go index 2e1e46582..158e665d3 100644 --- a/pkg/sentry/kernel/task_exit.go +++ b/pkg/sentry/kernel/task_exit.go @@ -803,13 +803,17 @@ type WaitOptions struct { } // Preconditions: The TaskSet mutex must be locked (for reading or writing). -func (o *WaitOptions) matchesTask(t *Task, pidns *PIDNamespace) bool { +func (o *WaitOptions) matchesTask(t *Task, pidns *PIDNamespace, tracee bool) bool { if o.SpecificTID != 0 && o.SpecificTID != pidns.tids[t] { return false } if o.SpecificPGID != 0 && o.SpecificPGID != pidns.pgids[t.tg.processGroup] { return false } + // Tracees are always eligible. + if tracee { + return true + } if t == t.tg.leader && t.tg.terminationSignal == linux.SIGCHLD { return o.NonCloneTasks } @@ -903,7 +907,7 @@ func (t *Task) waitParentLocked(opts *WaitOptions, parent *Task) (*WaitResult, b anyWaitableTasks := false for child := range parent.children { - if !opts.matchesTask(child, parent.tg.pidns) { + if !opts.matchesTask(child, parent.tg.pidns, false) { continue } // Non-leaders don't notify parents on exit and aren't eligible to @@ -946,7 +950,7 @@ func (t *Task) waitParentLocked(opts *WaitOptions, parent *Task) (*WaitResult, b } } for tracee := range parent.ptraceTracees { - if !opts.matchesTask(tracee, parent.tg.pidns) { + if !opts.matchesTask(tracee, parent.tg.pidns, true) { continue } // Non-leaders do notify tracers on exit. -- cgit v1.2.3