From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58D29C83000 for ; Wed, 29 Apr 2020 21:57:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0F3420757 for ; Wed, 29 Apr 2020 21:57:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="lcgeCqTd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0F3420757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A08BC8E0005; Wed, 29 Apr 2020 17:57:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 992A48E0001; Wed, 29 Apr 2020 17:57:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8819B8E0005; Wed, 29 Apr 2020 17:57:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 6C9B38E0001 for ; Wed, 29 Apr 2020 17:57:17 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 27C124DBF for ; Wed, 29 Apr 2020 21:57:17 +0000 (UTC) X-FDA: 76762254114.20.pen67_3f8e02590871b X-HE-Tag: pen67_3f8e02590871b X-Filterd-Recvd-Size: 4980 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 21:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JhIri9Htg0/sN4w6AP/QH7wGRCJsnU/YBI0zvtCnrSE=; b=lcgeCqTdF0/C0XnarY+tI1cLA aTp5plAUZgVFOpQPCrwnTtLwHs8XQhIGrDDx+4JmRdD5VmjaNjo3kqPh/BRBwYRi0ULZSpSwWY0mW TrgemlMVjy5uQmTWtkwO2jv40d3R3lIxts3PSghFetSH2TbL4JnhiGlJwhTroVW/CX7SpjTyhrZpn X/Ez408/p4adJYNff4cxI3KCA5uQPjgzUfuiEZ4LI1/jdP1WfABKNM6VQy8G4/iB464EHLhHoNUBC marQIPhja3Ndlo+onDkpOu7bNy8Fc8qEEX+yBrHUbV6/UqmfyOGOxXHgP9SDfhe6A2l8poddWJOzu YD58Ko3aw==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:51674) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTugs-0001oF-Rn; Wed, 29 Apr 2020 22:56:27 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jTugm-0001S9-Ad; Wed, 29 Apr 2020 22:56:20 +0100 Date: Wed, 29 Apr 2020 22:56:20 +0100 From: Russell King - ARM Linux admin To: Jann Horn , Nicolas Pitre Cc: Andrew Morton , Linus Torvalds , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Alexander Viro , "Eric W . Biederman" , Oleg Nesterov , linux-arm-kernel@lists.infradead.org, Mark Salter , Aurelien Jacquiot , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there Message-ID: <20200429215620.GM1551@shell.armlinux.org.uk> References: <20200429214954.44866-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200429214954.44866-1-jannh@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 29, 2020 at 11:49:49PM +0200, Jann Horn wrote: > At the moment, we have that rather ugly mmget_still_valid() helper to > work around : ELF core dumping > doesn't take the mmap_sem while traversing the task's VMAs, and if > anything (like userfaultfd) then remotely messes with the VMA tree, > fireworks ensue. So at the moment we use mmget_still_valid() to bail > out in any writers that might be operating on a remote mm's VMAs. > > With this series, I'm trying to get rid of the need for that as > cleanly as possible. > In particular, I want to avoid holding the mmap_sem across unbounded > sleeps. > > > Patches 1, 2 and 3 are relatively unrelated cleanups in the core > dumping code. > > Patches 4 and 5 implement the main change: Instead of repeatedly > accessing the VMA list with sleeps in between, we snapshot it at the > start with proper locking, and then later we just use our copy of > the VMA list. This ensures that the kernel won't crash, that VMA > metadata in the coredump is consistent even in the presence of > concurrent modifications, and that any virtual addresses that aren't > being concurrently modified have their contents show up in the core > dump properly. > > The disadvantage of this approach is that we need a bit more memory > during core dumping for storing metadata about all VMAs. > > After this series has landed, we should be able to rip out > mmget_still_valid(). > > > Testing done so far: > > - Creating a simple core dump on X86-64 still works. > - The created coredump on X86-64 opens in GDB, and both the stack and the > exectutable look vaguely plausible. > - 32-bit ARM compiles with FDPIC support, both with MMU and !MMU config. > > I'm CCing some folks from the architectures that use FDPIC in case > anyone wants to give this a spin. I've never had any reason to use FDPIC, and I don't have any binaries that would use it. Nicolas Pitre added ARM support, so I guess he would be the one to talk to about it. (Added Nicolas.) -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up