Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7272456ybf; Fri, 6 Mar 2020 14:01:56 -0800 (PST) X-Google-Smtp-Source: ADFU+vtokSHBIayMst6patH42wLPTDqP4ohfrUULK14gfZrakYZXZuf20dXyEV3UR9R60wJLuXHO X-Received: by 2002:a9d:49:: with SMTP id 67mr1791656ota.163.1583532116137; Fri, 06 Mar 2020 14:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583532116; cv=none; d=google.com; s=arc-20160816; b=QJJ0d9zmtmj/a54fNBW55d7Th4ygnHt60TDrKqB8uO+0AlWqK1p37m+oHuzIOd8Pyz ou1Vg+UxwBl9HFHDJxPtdc3DQK2R66iU/LCqnFjis1tWVXaMBHmJjqOPRAxuaT1FAapq VFOOM6TC2ScngtUTkYNdJE+Aw2nr1JG+68oxQHFU81jteYw8jCoCuahAJy+0cFewqgUP ECSujpG1NegpUxVTPqrMDwWboHChWgKksFoMq/IAKhUBrQOVoRLMeDuj0ga/z3BPL3oS OVejHDiYJZWk8PbEN6OYzl2DHU9fa8hemckSmb19X+dUKvr6yWThduvLoY8LSYG2XLda WlvA== 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=YKy+CGzOxyWiwjYW98Sr4anyrajZ9rrke05ZU4z+iRU=; b=jWcjyrt9ZFPaiRhWtwUVQnMkRj/rtonT90fzL1hr9Ws4MiGQAA5WzwMAf0e2FjUJ6R d0NH0LCqmol/sRmdGcd9w9/jQ2Y2ySxLlmG4RgSJYf6lfq78j5eC9FPwWZIOtKXaSDAp oXztlGn3RHc+0/3kGgSwg9ZHDVmqjbKURMcSbVpYwbsa/XRX1f8Q6ogX2m72DJ64edEw G4J8MvFKRXWVJNn0kH8dOR7GQD1WkuA3bpgeS+0XTu50e0Bay6Ih2p1vYT6BOt1TOua2 cAA5xXr83xbbVH+j1PUhHM8gPm5dYqHDT0llOc8YvjxzOBFiAbCan8FW26ukr5zsDsUP aNPw== 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 o7si2454703ote.49.2020.03.06.14.01.43; Fri, 06 Mar 2020 14:01:56 -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 S1726271AbgCFWBM (ORCPT + 99 others); Fri, 6 Mar 2020 17:01:12 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:41264 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgCFWBL (ORCPT ); Fri, 6 Mar 2020 17:01:11 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jAL1o-0007O8-UN; Fri, 06 Mar 2020 15:01:09 -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 1jAL1o-0005iy-3n; Fri, 06 Mar 2020 15:01:08 -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> Date: Fri, 06 Mar 2020 15:58:52 -0600 In-Reply-To: (Bernd Edlinger's message of "Fri, 6 Mar 2020 19:16:08 +0000") Message-ID: <87sgil87s3.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=1jAL1o-0005iy-3n;;;mid=<87sgil87s3.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/nQIAja4Tte/KbD9xIUFWHY/xDf5wuGBw= 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 sa07.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-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.4936] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Bernd Edlinger X-Spam-Relay-Country: X-Spam-Timing: total 336 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 5 (1.6%), b_tie_ro: 4.2 (1.2%), parse: 1.52 (0.5%), extract_message_metadata: 15 (4.6%), get_uri_detail_list: 1.68 (0.5%), tests_pri_-1000: 10 (2.9%), tests_pri_-950: 1.14 (0.3%), tests_pri_-900: 1.01 (0.3%), tests_pri_-90: 28 (8.4%), check_bayes: 27 (7.9%), b_tokenize: 10 (3.0%), b_tok_get_all: 7 (2.2%), b_comp_prob: 3.2 (1.0%), b_tok_touch_all: 3.3 (1.0%), b_finish: 0.65 (0.2%), tests_pri_0: 257 (76.3%), check_dkim_signature: 0.77 (0.2%), check_dkim_adsp: 4.4 (1.3%), poll_dns_idle: 0.49 (0.1%), tests_pri_10: 2.1 (0.6%), tests_pri_500: 10 (3.1%), 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 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. Eric