Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2792101ybh; Mon, 9 Mar 2020 13:07:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtbRulFCShsDG55LJQr6bSZkERFYY2Me5AUK0k846X6FdSgRaU0aeoZ8RbP6Zgd2vlspUjf X-Received: by 2002:a05:6830:1511:: with SMTP id k17mr13712717otp.53.1583784473012; Mon, 09 Mar 2020 13:07:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x79si4477647oif.180.2020.03.09.13.07.14; Mon, 09 Mar 2020 13:07:52 -0700 (PDT) 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; arc=fail (body hash mismatch); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgCIUDu convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Mar 2020 16:03:50 -0400 Received: from mail-oln040092074088.outbound.protection.outlook.com ([40.92.74.88]:32348 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726118AbgCIUDu (ORCPT ); Mon, 9 Mar 2020 16:03:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YwJRRzsPfDV6pw8niLXxxARaTQceSzf26gAUJk+Q78sCHOeQiKb9mPTblS6lLAjyAjhuCsOE52US5s8KlGozy6rNitynrMwamzYu7hE0DWbVOc1pR1OMRL/A0VRQ/yO/dTsyLdfRuniCNwDfFQJRDoUDcFdTwtCWUhdQrJJm8svKp5ktcjmcTHEXIfhbhcn7bAhbp2wsJdy90Lr7xcpCpLXgWqQxHVf8tn+FszIbobP6f8AkBTLl2eVRF58Qet/sRA7reEBPdcJQopU14yeOWxtdqw16peAkqFBXNyz6iNzktn66qqnLGL7VGY2DoCaiXTVjixogE1nROF7GeVU6vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oSMJLLgDr15D4VLWggN8xRkZ4pGZITaT8VMWQQSmgvk=; b=P11a1awaQcx8v8tqSj4tpN/xb2Zq/j9cS2gbUD/Vmxp/qkC713N7XeCrgrkyNgcKkcBWBWaOidWl98BnrzIw5qOdhFJCsCS4fF6yQ4PI6MiUor65ji7Fcu3RLhRkavQoEO6KTt4Jx2vmL63GCapKoERe3RioVEbhGFKS+5HFxXrrcyJWAvka9eT5CMshAak82+UQOgLjltMQ+Fxj6oV3BzTP8S9+8MrVc7IN6BSbt/rXGMKmOLDBbcnlDxKtIOixoYLGHCog+cetgoDq7iO4sa2M4VUcK+dn9oS9zLburSV+4/kKoiHa9CNB2kgfM6oU/YAQ1Uh3CWaaJa4eND1+1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DB3EUR04FT034.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::39) by DB3EUR04HT009.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::302) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11; Mon, 9 Mar 2020 20:03:46 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.55) by DB3EUR04FT034.mail.protection.outlook.com (10.152.24.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11 via Frontend Transport; Mon, 9 Mar 2020 20:03:46 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2772.019; Mon, 9 Mar 2020 20:03:46 +0000 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0042.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.16 via Frontend Transport; Mon, 9 Mar 2020 20:03:44 +0000 From: Bernd Edlinger To: "Eric W. Biederman" 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" Subject: Re: [PATCH v2 4/5] exec: Move exec_mmap right after de_thread in flush_old_exec Thread-Topic: [PATCH v2 4/5] exec: Move exec_mmap right after de_thread in flush_old_exec Thread-Index: AQHV9ZIq8LqSeoOzkk+o9CTpCnOInKhAqHsAgAADjVGAAAFjAIAAAk+agAAAywA= Date: Mon, 9 Mar 2020 20:03:46 +0000 Message-ID: References: <87v9nlii0b.fsf@x220.int.ebiederm.org> <87a74xi4kz.fsf@x220.int.ebiederm.org> <87r1y8dqqz.fsf@x220.int.ebiederm.org> <87tv32cxmf.fsf_-_@x220.int.ebiederm.org> <87v9ne5y4y.fsf_-_@x220.int.ebiederm.org> <875zfe5xzb.fsf_-_@x220.int.ebiederm.org> <87tv2xz510.fsf@x220.int.ebiederm.org> <87mu8pz4ex.fsf@x220.int.ebiederm.org> In-Reply-To: <87mu8pz4ex.fsf@x220.int.ebiederm.org> Accept-Language: en-US, en-GB, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: ZR0P278CA0042.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::11) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) x-incomingtopheadermarker: OriginalChecksum:ED1668ACE5B6F42E2EC0B7404924F25A11196849EC0806CBF5A7AE4B20F63F3D;UpperCasedChecksum:15FACC825918DCFFC11AB2907EBB8D4EBF54753EBDBAA58E0FAE0DD48575A447;SizeAsReceived:9985;Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [jGD4KHCtwYTsvQc4p0+xqjqsU8Uw45SI] x-microsoft-original-message-id: <587348ba-6a01-2413-9b4b-f64a1f514ea7@hotmail.de> x-ms-publictraffictype: Email x-incomingheadercount: 50 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: e27f1dd5-758e-4932-b244-08d7c464f9af x-ms-traffictypediagnostic: DB3EUR04HT009: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZpR1yFOseKEmusWU5hW+o9s3YD1lY24qlFYfaX4n5cad/edVd3Jk/8j2cTT06ky0eYQppZ15v0/scxurFQlhToh9G0Qmm8yH2sI3Y77QG/V9dcmsJE6TybdsWxIH8+y60Crwti0Q1xgXYwgnuYfEhAc2uqdEqg+d6mAhDh8TGX5mg+yvrQ3GdKnp22s3ewpi x-ms-exchange-antispam-messagedata: r+bk0gUHakTOjL4n7/G/RzRY/5nUmQupLsoUnZYPNhIIVPCfppSindQ/bjdMmmRdMtZ8iOzWSQVv6IQzclqXFpaYHpFy6GhHxJsy6dSLN8yMXzNE6hGiT4wgYRGAQWVUEFBn9zG4ZAYtiMTYiguJdA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-ID: <100A2EDE7978314BBD2FF1EBC3B5B866@eurprd03.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e27f1dd5-758e-4932-b244-08d7c464f9af X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Mar 2020 20:03:46.4347 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT009 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/9/20 8:58 PM, Eric W. Biederman wrote: > > Ok. I think this has it sorted: > > exec: Move exec_mmap right after de_thread in flush_old_exec > > I have read through the code in exec_mmap and I do not see anything > that depends on sighand or the sighand lock, or on signals in anyway > so this should be safe. > > This rearrangement of code has two significant benefits. It makes > the determination of passing the point of no return by testing bprm->mm > accurate. All failures prior to that point in flush_old_exec are > either truly recoverable or they are fatal. > > Further this consolidates all of the possible indefinite waits for > userspace together at the top of flush_old_exec. The possible wait > for a ptracer on PTRACE_EVENT_EXIT, the possible wait for a page fault > to be resolved in clear_child_tid, and the possible wait for a page > fault in exit_robust_list. > > This consolidation allows the creation of a mutex to replace > cred_guard_mutex that is not held over possible indefinite userspace > waits. Which will allow removing deadlock scenarios from the kernel. > > Reviewed-by: Bernd Edlinger > Signed-off-by: "Eric W. Biederman" > > > I don't think I usually have this many typos. Sigh. > OK. never mind, Bernd.