Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751989AbdFFTOs (ORCPT ); Tue, 6 Jun 2017 15:14:48 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:58134 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751471AbdFFTOn (ORCPT ); Tue, 6 Jun 2017 15:14:43 -0400 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Ingo Molnar , Thomas Gleixner , Kees Cook , Roland McGrath , Al Viro , David Howells , "Michael Kerrisk (man-pages)" , "Eric W. Biederman" Date: Tue, 6 Jun 2017 14:03:32 -0500 Message-Id: <20170606190338.28347-20-ebiederm@xmission.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170606190338.28347-1-ebiederm@xmission.com> References: <877f0pym71.fsf@xmission.com> <20170606190338.28347-1-ebiederm@xmission.com> X-XM-SPF: eid=1dIJvE-0006wd-Ft;;;mid=<20170606190338.28347-20-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.121.81.159;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19ue2O/+BPaKAD3JjqrV37ZXej2K+6I/8o= X-SA-Exim-Connect-IP: 97.121.81.159 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 5539 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.2 (0.0%), b_tie_ro: 1.57 (0.0%), parse: 0.76 (0.0%), extract_message_metadata: 12 (0.2%), get_uri_detail_list: 1.32 (0.0%), tests_pri_-1000: 6 (0.1%), tests_pri_-950: 1.22 (0.0%), tests_pri_-900: 1.00 (0.0%), tests_pri_-400: 20 (0.4%), check_bayes: 19 (0.3%), b_tokenize: 7 (0.1%), b_tok_get_all: 6 (0.1%), b_comp_prob: 1.82 (0.0%), b_tok_touch_all: 2.9 (0.1%), b_finish: 0.68 (0.0%), tests_pri_0: 390 (7.0%), check_dkim_signature: 0.52 (0.0%), check_dkim_adsp: 215 (3.9%), tests_pri_500: 5103 (92.1%), poll_dns_idle: 5097 (92.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 20/26] wait: Don't pass the list to wait_consider_task X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2167 Lines: 60 The list a task is found on is not really relevant to wait, so stop passing the list in and write the conditions in such a way as to not take the list into consideration. This is technically user visible due to __WNOTHREAD but is very unlikely to matter in practice. Signed-off-by: "Eric W. Biederman" --- kernel/exit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 8f3825b22de5..c783d5fb5ab3 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1329,8 +1329,7 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) * then ->notask_error is 0 if @p is an eligible child, * or still -ECHILD. */ -static int wait_consider_task(struct wait_opts *wo, int ptrace, - struct task_struct *p) +static int wait_consider_task(struct wait_opts *wo, struct task_struct *p) { /* * We can race with wait_task_zombie() from another thread. @@ -1356,11 +1355,13 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace, * and reaping will be cascaded to the real parent when the * ptracer detaches. */ - if ((exit_state == EXIT_TRACEE) && ptrace) + if ((exit_state == EXIT_TRACEE) && same_thread_group(current, p->parent)) return wait_task_zombie(wo, exit_state, p); /* Is this task past the point where ptrace cares? */ - if (unlikely((exit_state == EXIT_TRACED) && ptrace)) + if (unlikely((exit_state == EXIT_TRACED) && + !(same_thread_group(current, p->real_parent) && + thread_group_leader(p)))) return 0; /* @@ -1414,7 +1415,7 @@ static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk) struct task_struct *p; list_for_each_entry(p, &tsk->children, sibling) { - int ret = wait_consider_task(wo, 0, p); + int ret = wait_consider_task(wo, p); if (ret) return ret; @@ -1428,7 +1429,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk) struct task_struct *p; list_for_each_entry(p, &tsk->ptraced, ptrace_entry) { - int ret = wait_consider_task(wo, 1, p); + int ret = wait_consider_task(wo, p); if (ret) return ret; -- 2.10.1