Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbdFFTTt (ORCPT ); Tue, 6 Jun 2017 15:19:49 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:59238 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbdFFTTq (ORCPT ); Tue, 6 Jun 2017 15:19:46 -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:37 -0500 Message-Id: <20170606190338.28347-25-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=1dIJvw-0006wd-TG;;;mid=<20170606190338.28347-25-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.121.81.159;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX183GAjvbDiujgmh6xzgALzJnyz5N4sShc4= 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 * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 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.5003] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 12672 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.1 (0.0%), b_tie_ro: 2.9 (0.0%), parse: 1.37 (0.0%), extract_message_metadata: 18 (0.1%), get_uri_detail_list: 3.1 (0.0%), tests_pri_-1000: 8 (0.1%), tests_pri_-950: 1.79 (0.0%), tests_pri_-900: 1.43 (0.0%), tests_pri_-400: 28 (0.2%), check_bayes: 26 (0.2%), b_tokenize: 11 (0.1%), b_tok_get_all: 7 (0.1%), b_comp_prob: 2.9 (0.0%), b_tok_touch_all: 3.1 (0.0%), b_finish: 0.73 (0.0%), tests_pri_0: 210 (1.7%), check_dkim_signature: 0.60 (0.0%), check_dkim_adsp: 3.4 (0.0%), tests_pri_500: 12395 (97.8%), poll_dns_idle: 12378 (97.7%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 25/26] signal: In ptrace_stop use CLD_TRAPPED in all ptrace signals 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: 2316 Lines: 58 If the only job of the signal is to report a ptrace level event set si_code to CLD_TRAPPED instead of possibly CLD_STOPPED. This causes the siginfo of the signals that are sent to match the signinfo of the signals returned by waitid. This is a user visible difference but I don't expect anything will care. In fact this is a return to historical linux behavior. In linux 2.4.0 all ptrace stops were reported through do_notify_parent with CLD_TRAPPED. When do_notify_parent_cldstop was added the CLD_TRAPPED logic was not included and CLD_TRAPPED for ptrace stops was lost. As nothing was said about this case I assume it was an oversight. When waitid was added a little earlier all stops were being reported with do_notify_parent and all ptrace stops were setting CLD_TRAPPED. So initially signals and waitid were in sync with respect to setting CLD_TRAPPED. It is also worth knowing that posix uses documents CLD_TRAPPED as "Traced child has trapped." History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Ref: ca3f74aa7baa ("[PATCH] waitid system call") Fixes: Fixes: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4") Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index ff41e6ee2b5e..0d4ca87f1fee 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1886,9 +1886,9 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info) * separately unless they are going to be identical. */ if (!identical) - do_notify_parent_cldstop(current, true, why); + do_notify_parent_cldstop(current, true, CLD_TRAPPED); if (gstop_done) - do_notify_parent_cldstop(current, false, why); + do_notify_parent_cldstop(current, false, CLD_STOPPED); /* * Don't want to allow preemption here, because @@ -1912,7 +1912,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info) * the real parent of the group stop completion is enough. */ if (gstop_done) - do_notify_parent_cldstop(current, false, why); + do_notify_parent_cldstop(current, false, CLD_STOPPED); /* tasklist protects us from ptrace_freeze_traced() */ __set_current_state(TASK_RUNNING); -- 2.10.1