Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1119516ybh; Sat, 14 Mar 2020 18:34:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vth+vh7F5DZMMNlGW+N7Ct09qNj/gWZJvN8QVscu2k5nBQQSiuqZNS98UjFx+46XxpgIRoq X-Received: by 2002:a9d:4505:: with SMTP id w5mr3300951ote.262.1584236069129; Sat, 14 Mar 2020 18:34:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1584236069; cv=pass; d=google.com; s=arc-20160816; b=n8xQhf5JATBh5H3ROi5bNVKks/05YW1wU3Dx3aRYWY5yf3jZabbkFlf1+uSfSHEqJp EE3eBfNeWpEV3Z4JX0RKdWLsRZ793g+KOKTdct2QiWbMCv2s46rq54rjxnSJAWES2/Yd pOdiDOQfsNiza38MBtYDzwijvbPY6VtwfUu7nnIT8/uQ8JuygjGSYP+mlf4bGJCNvDiU rceW0/Z1uc+eaz4YIfAwqJu/Ehy7CuxiVQx+95K5Ncql09emT4TTi9sMGIfoEBkE3QGJ cP3rHEEF70idaRW4l/Jxv/ds9ieTsEA0GeNDpNMYWzv9hQ4EtURTcpu7jAvuCGzT9iEj QC6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject; bh=0t14d3vmYMBeBtGI1RMkCE1K2Eye6ORicjQh/aQM3N0=; b=UVPJ13oyCUmf8/fto+yVsa6LqK4Mw2NR3iIzcFBjF1dMHwf1KBAiZhOQUrcmbINRdO exasHzXAt6MOLP5x3ityp1oMvtVy3plzXDk0zC+ec5JfGyeP/J1d0cFk8J2QaRYNCxBs xDPtXsvMANa3uQFzeqomIJqSu8D5IdcBV7RfSHXZ4cllPAQMQV83tNcqwYQce2ZNvjV0 l9SS/LF2XreWkwH7QESlhyrXMfxEFRuZ4vuEZaOnhdENiwNs6nWUK7tdoJMCCiRByZwT fmCwCVo/SF8dS107o+gZL7Nmz0YheiNZwz8id5XgorPpehzwz39RXudSS5dM9IFa139a ITdg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hotmail.de dkim=pass dkdomain=hotmail.de dmarc=pass fromdomain=hotmail.de); 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si7723741otj.242.2020.03.14.18.34.17; Sat, 14 Mar 2020 18:34:29 -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=pass (i=1 spf=pass spfdomain=hotmail.de dkim=pass dkdomain=hotmail.de dmarc=pass fromdomain=hotmail.de); 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 S1726883AbgCOBeC (ORCPT + 99 others); Sat, 14 Mar 2020 21:34:02 -0400 Received: from mail-oln040092075105.outbound.protection.outlook.com ([40.92.75.105]:4992 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726705AbgCOBeA (ORCPT ); Sat, 14 Mar 2020 21:34:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q+4M/xmhc023myQhgFcVgK9e5m3S/6YcivxKKHqF971tzl/d1IjZZB6vajrlVR/3ANsXohcq2I3kanwvWJVPYB1OMD17aiHgPffPk8jPA6GudjlDD/CZQw6OQ8esLf8XkVFYgDiHb5ZjY6AyjI/X+bvzCh3z11qv2hTNgCvkn4ilKAVDaT1sKHvfsMBWuzKcQglMwBM1LxBdCsX2wSsfVJxqlFr2teyVN4sqbUaUPYWZDKELgxjHGsgZ/NDY238EBm1+xpYCkwLlOQmWP0bOkPg3aJxjwkoKy5glZZ0ZmUbbeQ6h1Yb04pHbkgukZvqeHh8zDIBnL9GvUT9fHCO05A== 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=0t14d3vmYMBeBtGI1RMkCE1K2Eye6ORicjQh/aQM3N0=; b=BKZPqoHj7tWWah96/MVM93xT7Z2ea/UZClZxfhlGbQf9Fxelf7J/qZOX2YZF27oJEHoZal+44UdFdPnj2X3Fw5/YHewtX7CHqw/vn9E7k5krb6esB8RgS+G5qPdsK8E3lCX72PcrEi4zCyeYnH2DXpADDerExXKRD0K7nWi9xqmT3+eaFpqz9Lzm+GVwANhZhCcWURUHNhmzBsXqqg1glXPJ2A/bwhUbTWpovmjr1sVgvc+ErKCV5nR62H5yAn1kD5PiqWRrAFCW1KbNCmdTJgXfVvNrfSYsEU1d4BjfIQ/91Vc4s5JY+z3bir2r//z5h3KRbH5NkBBZB5vpoyMoRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from DB3EUR04FT009.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::38) by DB3EUR04HT180.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Sat, 14 Mar 2020 09:57:13 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.54) by DB3EUR04FT009.mail.protection.outlook.com (10.152.24.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Sat, 14 Mar 2020 09:57:13 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:FF41864A883BD405ABA604C0AF65CA0A23BDC59744F8CBC7816B6A046E5E1DF5;UpperCasedChecksum:74E380B2237A95D772639194018BAF266B3CFDC8E72DFFDA53E86DBC29C52239;SizeAsReceived:10362;Count:50 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.2814.018; Sat, 14 Mar 2020 09:57:13 +0000 Subject: Re: [PATCH v2 5/5] exec: Add a exec_update_mutex to replace cred_guard_mutex To: Kirill Tkhai , "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" 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> <87zhcq4jdj.fsf_-_@x220.int.ebiederm.org> <87d09hn4kt.fsf@x220.int.ebiederm.org> <87lfo5lju6.fsf@x220.int.ebiederm.org> <6002ac56-025a-d50f-e89d-1bf42a072323@virtuozzo.com> From: Bernd Edlinger Message-ID: Date: Sat, 14 Mar 2020 10:57:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <6002ac56-025a-d50f-e89d-1bf42a072323@virtuozzo.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::15) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.18 via Frontend Transport; Sat, 14 Mar 2020 09:57:05 +0000 X-Microsoft-Original-Message-ID: X-TMN: [dJMluiESOM82Wyv2Ut3LbvVwuH1v2vrc] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 02c07a97-1088-47f3-bd76-08d7c7fe1193 X-MS-TrafficTypeDiagnostic: DB3EUR04HT180: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lCPnaL6f8n7O6hBYVhT/p8DbBrrs3yAla2HphQ0DWv4UnlsONnH3y4qrDhgVjbfIP61KEMn6qPdm5wLqMcwc7g5dWAPVWrRlpUhvHhzCTVc59RvzA7ehUWJlNExknLoyQX0Lg45fwftHjLUB8wtUQykZC2WFAr8rihe5xEBVIPYBNNxnuvXfQjYHuYaOZvn3Yu6oTDqGIc+OBGwWRq8nvxHtvtHg/JpYQOcMszIOb+Q= X-MS-Exchange-AntiSpam-MessageData: Wn3kgHSfZD8gnOmY8gYrzpN0s5mmImPooFZkCxnxl4y4Q3tUDTiMYIbiScCXplHL1redMUXp3MipSNj/W/GIh5twJNCCHOTvw10F8CAGdI7WCBNRhTexlGloGxXNpBiNJUlprsOSBaCOKXD38YyrHg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02c07a97-1088-47f3-bd76-08d7c7fe1193 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2020 09:57:13.0178 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/13/20 10:13 AM, Kirill Tkhai wrote: > > Despite this should fix the problem, this looks like a broken puzzle. > > We can't use bprm->cred as an identifier whether the mutex was locked or not. > We can check for bprm->cred in regard to cred_guard_mutex, because of there is > strong rule: "cred_guard_mutex is becomes locked together with bprm->cred assignment > (see prepare_bprm_creds()), and it becomes unlocked together with bprm->cred zeroing". > Take attention on modularity of all this: there is no dependencies between anything else. > > In regard to newly introduced exec_update_mutex, your fix and source patch way look like > an obfuscation. The mutex becomes deadly glued to unrelated bprm->cred and bprm->mm, > and this introduces the problems in the future modifications and support of all involved > entities. If someone wants to move some functions in relation to each other, there will > be a pain, and this person will have to go again the same dependencies and bug way, > Eric stepped on in the original patch. > Okay, yes, valid points you make, thanks. I just wanted to understand what was exactly wrong with this patch, since the failure mode looked a lot like it was failing because of something clobbering the data unexpectedly. So I have posted a few updated patch for the failed one here: [PATCH v3 5/5] exec: Add a exec_update_mutex to replace cred_guard_mutex [PATCH] pidfd: Use new infrastructure to fix deadlocks in execve which replaces these: [PATCH v2 5/5] exec: Add a exec_update_mutex to replace cred_guard_mutex https://lore.kernel.org/lkml/87zhcq4jdj.fsf_-_@x220.int.ebiederm.org/ [PATCH] pidfd: Stop taking cred_guard_mutex https://lore.kernel.org/lkml/87wo7svy96.fsf_-_@x220.int.ebiederm.org/ and a new patch series to fix deadlock in ptrace_attach and update doc: [PATCH 0/2] exec: Fix dead-lock in de_thread with ptrace_attach [PATCH 1/2] exec: Fix dead-lock in de_thread with ptrace_attach [PATCH 2/2] doc: Update documentation of ->exec_*_mutex Other patches needed, still valid: [PATCH v2 1/5] exec: Only compute current once in flush_old_exec https://lore.kernel.org/lkml/87pndm5y3l.fsf_-_@x220.int.ebiederm.org/ [PATCH v2 2/5] exec: Factor unshare_sighand out of de_thread and call it separately https://lore.kernel.org/lkml/87k13u5y26.fsf_-_@x220.int.ebiederm.org/ [PATCH v2 4/5] exec: Move exec_mmap right after de_thread in flush_old_exec https://lore.kernel.org/lkml/875zfe5xzb.fsf_-_@x220.int.ebiederm.org/ [PATCH 1/4] exec: Fix a deadlock in ptrace https://lore.kernel.org/lkml/AM6PR03MB517033EAD25BED15CC84E17DE4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 2/4] selftests/ptrace: add test cases for dead-locks https://lore.kernel.org/lkml/AM6PR03MB51703199741A2C27A78980FFE4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 3/4] mm: docs: Fix a comment in process_vm_rw_core https://lore.kernel.org/lkml/AM6PR03MB5170ED6D4D216EEEEF400136E4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 4/4] kernel: doc: remove outdated comment cred.c https://lore.kernel.org/lkml/AM6PR03MB517039DB07AB641C194FEA57E4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 1/4] kernel/kcmp.c: Use new infrastructure to fix deadlocks in execve https://lore.kernel.org/lkml/AM6PR03MB517057A2269C3A4FB287B76EE4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 2/4] proc: Use new infrastructure to fix deadlocks in execve https://lore.kernel.org/lkml/AM6PR03MB51705D211EC8E7EA270627B1E4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 3/4] proc: io_accounting: Use new infrastructure to fix deadlocks in execve https://lore.kernel.org/lkml/AM6PR03MB5170BD2476E35068E182EFA4E4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ [PATCH 4/4] perf: Use new infrastructure to fix deadlocks in execve https://lore.kernel.org/lkml/AM6PR03MB517035DEEDB9C8699CB6B34EE4FF0@AM6PR03MB5170.eurprd03.prod.outlook.com/ I think most of the existing patches are already approved, but if there are still change requests, please let me know. Thanks Bernd.