From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932582AbdBQEqq (ORCPT ); Thu, 16 Feb 2017 23:46:46 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:44450 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932390AbdBQEqo (ORCPT ); Thu, 16 Feb 2017 23:46:44 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Mika =?utf-8?Q?Penttil=C3=A4?= , Aleksa Sarai , Andy Lutomirski , Attila Fazekas , Jann Horn , Kees Cook , Michal Hocko , Ulrich Obergfell , linux-kernel@vger.kernel.org, David Howells References: <20170213141452.GA30203@redhat.com> <20170213141516.GA30233@redhat.com> <20170213180454.GA2858@redhat.com> Date: Fri, 17 Feb 2017 17:42:09 +1300 In-Reply-To: <20170213180454.GA2858@redhat.com> (Oleg Nesterov's message of "Mon, 13 Feb 2017 19:04:54 +0100") Message-ID: <87k28po2ce.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=1ceaRN-0001Dw-LT;;;mid=<87k28po2ce.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=101.100.131.232;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/9si4/4JlWgB2FAH2lOzLnpiJpeSkJ1ps= X-SA-Exim-Connect-IP: 101.100.131.232 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 * 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.4998] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 1.0 T_XMHurry_00 Hurry and Do Something * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 214 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 3.5 (1.6%), b_tie_ro: 2.4 (1.1%), parse: 1.17 (0.5%), extract_message_metadata: 4.0 (1.9%), get_uri_detail_list: 1.68 (0.8%), tests_pri_-1000: 4.4 (2.1%), tests_pri_-950: 1.21 (0.6%), tests_pri_-900: 1.01 (0.5%), tests_pri_-400: 20 (9.4%), check_bayes: 19 (9.0%), b_tokenize: 6 (2.7%), b_tok_get_all: 6 (2.9%), b_comp_prob: 2.0 (0.9%), b_tok_touch_all: 3.0 (1.4%), b_finish: 0.70 (0.3%), tests_pri_0: 163 (76.2%), check_dkim_signature: 0.52 (0.2%), check_dkim_adsp: 3.0 (1.4%), tests_pri_500: 6 (2.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH V2 1/2] exec: don't wait for zombie threads with cred_guard_mutex held 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > de_thread() waits for other threads with ->cred_guard_mutex held and this > is really bad because the time is not bounded, debugger can delay the exit > and this lock has a lot of users (mostly abusers imo) in fs/proc and more. > And this leads to deadlock if debugger tries to take the same mutex: Oleg. I looked at the history in proc of users of cred_guard_mutex and the proc users are grabbing cred_guard_mutex for the proper semantic reasons. To avoid races with setuid exec that could result in an information disclosure. I do agree that a mutex is the wrong data structure for the job cred_guard_mutex is performing. The job of sorting ensuring debuggers and proc processes see either the old version or the new version of the task. I need to play with the code but I suspect the best we can handle this preventing both security issues and problems in the future is to create a new task struct and populate it appropriate with the new data from exec (at least in the case of setuid exec). I am thinking of generalizing the case of a non-leader exec where we have to assume the leaders pid. I don't yet know what the performance implications would be but that would clean the users up a lot. On that score I believe we can incrementally approach that point and only grab the cred_guard_mutex in exec if we are performing an exec that changes the processes credentials. Right now I don't think it introduces any new security information disclosures but the moving of flush_signal_handlers outside of cred_guard_mutex feels wrong. Eric