Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp7933006pjo; Fri, 6 Mar 2020 14:32:36 -0800 (PST) X-Google-Smtp-Source: ADFU+vtB9j3wCNpgNnnwAN+tNI83HnLUKAfyHqW0BQ3DT+MxJo6dhBPNSuWzfYwYTxevTssX+c+j X-Received: by 2002:aca:af97:: with SMTP id y145mr4138582oie.24.1583533956798; Fri, 06 Mar 2020 14:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583533956; cv=none; d=google.com; s=arc-20160816; b=BzBcFPNbY7lGag/KrioAo6icT0o3iNZmoBrbhO2+4F0/ReNTtxBkKbKJF20Qx39omr 2aXBPglUeQv/DUPQj78WHyAmz+UAKplhiJcjBK0f0CE+kPj8tCbsDirLxc5245HIHqDp AGWZJKyTYT4JeCLKsbQYswBJNac0OzkGCJuZHPgKhVtPbSPAszTmNW06zXN4zcztZBxj wiyVzMUq0L7TviODqLcKVsCkw6T01Q2y4z9YSOkAdt3X2P7Gnn6wVBAuf6y8G7Zi30WP A9bdf6bPKhMohjPsKM7myLDacBN7b01j9OL3s7mJWcQ/dUthwNgGc3SIFTzg0qq5Iyz3 pPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from; bh=W/W93cTz8vzm8GaU7iJGAeGAqCHBQkprJHzulOfYhiE=; b=rUX9k3XPMs/ocMFnh0cmUAWnXYstbCwqag0p/X3qPlvSE72WC2sKl8RuL05Nas6vZB exIHkU9vxjH+GXh71M1IH/QM04anFh5oz5oDJICp323Rasx490yvwqQMdHXivrG2AtAu hHzuZq1AKWJpcmY1tJLKB/tKvVFhFlITyxBX6obvU5RXlDeYc2197N4OVMHcfAD5PA1e RjGWh4BBI57XD3m824q9WIAFqsMI4a7kjUcZ7e1IcIDGfAT6bJXKeRtXYK0E7WIyXIVH jQiU1VzGdsPCFWzeDWfPNljuT2eXhR5Udm80v7hCSJdPMvKQkN2BDrTM3ur03QizN6e0 v7tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si423590oim.30.2020.03.06.14.32.24; Fri, 06 Mar 2020 14:32:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgCFWcJ (ORCPT + 99 others); Fri, 6 Mar 2020 17:32:09 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:54190 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgCFWcI (ORCPT ); Fri, 6 Mar 2020 17:32:08 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jALVa-00024g-VC; Fri, 06 Mar 2020 15:31:55 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jALVa-0002B2-6m; Fri, 06 Mar 2020 15:31:54 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Bernd Edlinger Cc: Christian Brauner , Kees Cook , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra \(Intel\)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Greg Kroah-Hartman , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "linux-fsdevel\@vger.kernel.org" , "linux-mm\@kvack.org" , "stable\@vger.kernel.org" , "linux-api\@vger.kernel.org" References: <202003021531.C77EF10@keescook> <20200303085802.eqn6jbhwxtmz4j2x@wittgenstein> <87v9nlii0b.fsf@x220.int.ebiederm.org> <87a74xi4kz.fsf@x220.int.ebiederm.org> <87r1y8dqqz.fsf@x220.int.ebiederm.org> <87tv32cxmf.fsf_-_@x220.int.ebiederm.org> <87imjicxjw.fsf_-_@x220.int.ebiederm.org> <87k13yawpp.fsf@x220.int.ebiederm.org> <87sgil87s3.fsf@x220.int.ebiederm.org> Date: Fri, 06 Mar 2020 16:29:39 -0600 In-Reply-To: <87sgil87s3.fsf@x220.int.ebiederm.org> (Eric W. Biederman's message of "Fri, 06 Mar 2020 15:58:52 -0600") Message-ID: <87a74t86cs.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jALVa-0002B2-6m;;;mid=<87a74t86cs.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+eje1q6R54wdjNfMaNYFoLyq/4r+j8hDE= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa02.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,XMNoVowels, XMSubLong autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4987] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Bernd Edlinger X-Spam-Relay-Country: X-Spam-Timing: total 325 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.3 (0.7%), b_tie_ro: 1.69 (0.5%), parse: 0.76 (0.2%), extract_message_metadata: 12 (3.7%), get_uri_detail_list: 1.08 (0.3%), tests_pri_-1000: 23 (7.1%), tests_pri_-950: 1.00 (0.3%), tests_pri_-900: 0.84 (0.3%), tests_pri_-90: 27 (8.3%), check_bayes: 26 (7.9%), b_tokenize: 9 (2.8%), b_tok_get_all: 8 (2.4%), b_comp_prob: 1.80 (0.6%), b_tok_touch_all: 3.3 (1.0%), b_finish: 0.70 (0.2%), tests_pri_0: 248 (76.4%), check_dkim_signature: 0.43 (0.1%), check_dkim_adsp: 2.1 (0.6%), poll_dns_idle: 0.80 (0.2%), tests_pri_10: 1.74 (0.5%), tests_pri_500: 5 (1.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 2/2] exec: Add a exec_update_mutex to replace cred_guard_mutex 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ebiederm@xmission.com (Eric W. Biederman) writes: > Bernd Edlinger writes: > >> On 3/6/20 6:17 AM, Eric W. Biederman wrote: >>> Bernd Edlinger writes: >>> >>>> On 3/5/20 10:16 PM, Eric W. Biederman wrote: >>>>> >>>>> The cred_guard_mutex is problematic. The cred_guard_mutex is held >>>>> over the userspace accesses as the arguments from userspace are read. >>>>> The cred_guard_mutex is held of PTRACE_EVENT_EXIT as the the other >>>>> threads are killed. The cred_guard_mutex is held over >>>>> "put_user(0, tsk->clear_child_tid)" in exit_mm(). >>>>> >> >> I am all for this patch, and the direction it is heading, Eric. >> >> I just wanted to add a note that I think it is >> possible that exec_mm_release can also invoke put_user(0, tsk->clear_child_tid), >> under the new exec_update_mutex, since vm_access increments the >> mm->mm_users, under the cred_update_mutex, but releases the mutex, >> and the caller can hold the reference for a while and then exec_mmap is not >> releasing the last reference. > > Good catch. I really appreciate your close look at the details. > > I am wondering if process_vm_readv and process_vm_writev could be > safely changed to use mmgrab and mmdrop, instead of mmget and mmput. > > That would resolve the potential issue you have pointed out. I just > haven't figured out if it is safe. The mm code has been seriously > refactored since I knew how it all worked. Nope, mmget can not be replaced by mmgrab. It might be possible to do something creative like store a cred in place of the userns on the mm and use that for mm_access permission checks. Still we are talking a pretty narrow window, and a case that no one has figured out how to trigger yet. So I will leave that corner case as something for future improvements. Eric