From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbdCCVeu (ORCPT ); Fri, 3 Mar 2017 16:34:50 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:43503 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752117AbdCCVer (ORCPT ); Fri, 3 Mar 2017 16:34:47 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Aleksa Sarai , Andy Lutomirski , Attila Fazekas , Jann Horn , Kees Cook , Michal Hocko , Ulrich Obergfell , linux-kernel@vger.kernel.org, References: <20170213141452.GA30203@redhat.com> <20170224160354.GA845@redhat.com> <87shmv6ufl.fsf@xmission.com> <20170303173326.GA17899@redhat.com> <87tw7axlr0.fsf@xmission.com> <87d1dyw5iw.fsf@xmission.com> Date: Fri, 03 Mar 2017 14:06:30 -0600 In-Reply-To: <87d1dyw5iw.fsf@xmission.com> (Eric W. Biederman's message of "Fri, 03 Mar 2017 12:59:19 -0600") Message-ID: <87tw7aunuh.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1cjtXl-0005FT-VV;;;mid=<87tw7aunuh.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.234.240;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/PZqiIyYsksiZF+Gf1qqEZqV1qIx7mrGE= X-SA-Exim-Connect-IP: 67.3.234.240 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4878] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 5557 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.4 (0.1%), b_tie_ro: 2.4 (0.0%), parse: 1.21 (0.0%), extract_message_metadata: 26 (0.5%), get_uri_detail_list: 1.80 (0.0%), tests_pri_-1000: 11 (0.2%), tests_pri_-950: 2.0 (0.0%), tests_pri_-900: 1.62 (0.0%), tests_pri_-400: 30 (0.5%), check_bayes: 28 (0.5%), b_tokenize: 10 (0.2%), b_tok_get_all: 8 (0.1%), b_comp_prob: 3.7 (0.1%), b_tok_touch_all: 2.7 (0.0%), b_finish: 0.86 (0.0%), tests_pri_0: 647 (11.6%), check_dkim_signature: 0.84 (0.0%), check_dkim_adsp: 4.7 (0.1%), tests_pri_500: 4832 (86.9%), poll_dns_idle: 4824 (86.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 0/2] fix the traced mt-exec deadlock 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 ebiederm@xmission.com (Eric W. Biederman) writes: > ebiederm@xmission.com (Eric W. Biederman) writes: > >> The big lesson for me, and what was not obvious from your change >> description is that we are changing the user space visible semantics >> of exec+ptrace and that cred_guard_mutex is not at all the problem (as >> we always take cred_guard_mutex in a killable or interruptible way). > > Just to follow up. > > Because the cred_guard_mutex is fine as is we don't need to move > de_thread out from under cred_guard_mutex. We just need to change > de_thread to wait until all of the other threads are zombies. > Which should remove about half your proposed patch. > > The other key thing is that knowning it isn't cred_guard_mutex let's us > know that this kind of deadlock goes all of the way back to when > CLONE_THREAD was merged into the kernel. > > Insteresingly enough looking at zap_other_threads and notify_count I > have found a second bug. When a multi-threaded processes becomes a > zombie we don't send the notification to the parent process until the > non-leader threads have been reaped. Which means ptrace can mess up > sending SIGCHLD to the parent. Bah. I was misreading the code. Nothing but exec uses notify_count and group_exit_task. Eric From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) Subject: Re: [PATCH 0/2] fix the traced mt-exec deadlock Date: Fri, 03 Mar 2017 14:06:30 -0600 Message-ID: <87tw7aunuh.fsf@xmission.com> References: <20170213141452.GA30203@redhat.com> <20170224160354.GA845@redhat.com> <87shmv6ufl.fsf@xmission.com> <20170303173326.GA17899@redhat.com> <87tw7axlr0.fsf@xmission.com> <87d1dyw5iw.fsf@xmission.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <87d1dyw5iw.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> (Eric W. Biederman's message of "Fri, 03 Mar 2017 12:59:19 -0600") Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Oleg Nesterov Cc: Andrew Morton , Aleksa Sarai , Andy Lutomirski , Attila Fazekas , Jann Horn , Kees Cook , Michal Hocko , Ulrich Obergfell , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-api@vger.kernel.org ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) writes: > ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) writes: > >> The big lesson for me, and what was not obvious from your change >> description is that we are changing the user space visible semantics >> of exec+ptrace and that cred_guard_mutex is not at all the problem (as >> we always take cred_guard_mutex in a killable or interruptible way). > > Just to follow up. > > Because the cred_guard_mutex is fine as is we don't need to move > de_thread out from under cred_guard_mutex. We just need to change > de_thread to wait until all of the other threads are zombies. > Which should remove about half your proposed patch. > > The other key thing is that knowning it isn't cred_guard_mutex let's us > know that this kind of deadlock goes all of the way back to when > CLONE_THREAD was merged into the kernel. > > Insteresingly enough looking at zap_other_threads and notify_count I > have found a second bug. When a multi-threaded processes becomes a > zombie we don't send the notification to the parent process until the > non-leader threads have been reaped. Which means ptrace can mess up > sending SIGCHLD to the parent. Bah. I was misreading the code. Nothing but exec uses notify_count and group_exit_task. Eric