Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3541149ybh; Tue, 17 Mar 2020 01:59:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vutHJAmkuboU+GpPhDLKb8Oboupw14OlGqWbcuAwTm7Jxho/bV7qDhgw8A9xvRIC5HjRTyi X-Received: by 2002:a54:4891:: with SMTP id r17mr2680182oic.170.1584435593704; Tue, 17 Mar 2020 01:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584435593; cv=none; d=google.com; s=arc-20160816; b=Qt37Yu3w/lpszbFow/jM838RGojtisSz/MloovprH7/yO7M8AvjZCqU4Bj129FdVSk BuAf9y8RC0IYM3kFaow1Lcteb+Vt0Og1AHJCXnnXeZqcowLCcwMdsKTQXcpyXjLzurwJ 8BumIIGlahxICHrtlYxD0zGRAzIOr357wntn5WdTqeH26uNXZCaoFUhHnlC4JrG482hW lK0yNb2mwQZUeVWeaekGgyG1+hjpUomj0lp8/wguxO/wfUJdgiaEUbF/HNYT24CZhR8C RTAhvHx2YvDVDZWFEPBV8sfz80kc0GirlLVlXaZhgtLLjH3xQf1RWzRud1iTe4q1iRZ+ k9kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5phaytUDERqybzll3wrXLEKcvAErLg4je+EW8ePsyUA=; b=eTXmMcyXbGI/e7vm8WvzMDyIjj739ObFzEhO4OVkctLNyqIP8UxYa50KYv5S0QlBRk ZrOc4o/AhvpmgM//sHx23yFZZUQr1F640FP54FrB/hToW+aAD95XD8jrxRvmTeZjSmDe BFSY/MpNQ1ZrMauRiwlIa2Rq6LpwPXXdUjVAl4vlVkjXUbpzwXLBQUdpdzaw22aCAhzh 3Uw7k2vuDzfwjZmnOWV6TIq2F64FU4aqzT43rkor3bjE+kqwmfrvvAEaVj/aLyxkqcDn bauphfZ+rzypCzB3FJrgU91fHMP9eMFgXj6L53R7r3gIhVNVu45eUb6yJOrKthSArnA1 U8jA== 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=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si1654223otj.157.2020.03.17.01.59.40; Tue, 17 Mar 2020 01:59:53 -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; 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=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbgCQI6L (ORCPT + 99 others); Tue, 17 Mar 2020 04:58:11 -0400 Received: from relay.sw.ru ([185.231.240.75]:60316 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgCQI6K (ORCPT ); Tue, 17 Mar 2020 04:58:10 -0400 Received: from [192.168.15.225] by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jE832-0003KS-Rn; Tue, 17 Mar 2020 11:58:05 +0300 Subject: Re: [PATCH v2 5/5] exec: Add a exec_update_mutex to replace cred_guard_mutex To: Bernd Edlinger , "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: <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: Kirill Tkhai Message-ID: <68528401-58ff-c335-a752-00ebaa433e02@virtuozzo.com> Date: Tue, 17 Mar 2020 11:58:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.03.2020 13:02, Bernd Edlinger wrote: > On 3/14/20 10:57 AM, Bernd Edlinger wrote: >> 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/ >> > > Ah, sorry, forgot this one: > [PATCH v2 3/5] exec: Move cleanup of posix timers on exec out of de_thread > https://lore.kernel.org/lkml/87eeu25y14.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/ 1-4/5 look OK for me. You may add my Reviewed-by: Kirill Tkhai >> [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. >> > > Hope it is correct now. > I haven't seen the new patches on the kernel archives yet, > so I cannot add URLs for them. > > Bernd. >