Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1290614ybz; Wed, 29 Apr 2020 19:01:47 -0700 (PDT) X-Google-Smtp-Source: APiQypJjiQxOMBmEpTpalyXhFFq1wxkoDIF4Vbj6eT3+LGfxA8UFXIKnpciM1I/3q961q5ZvLfL+ X-Received: by 2002:a17:906:4310:: with SMTP id j16mr649060ejm.102.1588212107452; Wed, 29 Apr 2020 19:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588212107; cv=none; d=google.com; s=arc-20160816; b=bZ1qS/sYVaPWzVHqq6Xf2yHHzf3XVnUA0A3lzfe6YFIqvUA1qN5cYBak0i4MPibkm2 G+QyCn72e6ddumt/UEYiWfICBheJ1HynIZ8VsK/Se+M1UHMELt5/odKX51l7twyXtRod irGvbUg4t64cp7rQt9HF2N1x90Ib64FYMmVqrmRoIrXcXDNpKr5aixEnmad+QbRKesxY NRHIPj2dtqbtaJbV36inM+8qqqvCPZj0bTPBeF7Ei7nWO2YlZMTjDaLPAmTP5o2kvZy9 TX/Tdim3SxFIAiJUDVPOrwARtfVwrgqXY+H1tItKJVpueK7Q9IUcVNEjHNZEpHvmyYbx hjzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=JXD7QtQAFQNQ159EDLF6PpvLvyKOttqf1/AouMvJmy4=; b=eyGIQQAd6H1TkV9IEKJqt1ow+kq1We7OGaSMF208T/GsrG53MKrz0diKK2GOtzsCaI NIN5fr+jPeRG+GXf+gC9gkpIho4nexQXWR3IhOFaTAGevRWxoDgCUhfkHPRODbG87yeL YRpbFeHt/+bDFEW5KC91VSAzmmG6P5VWQCvDTHCSLjFUlRk8PuGBChS2BUi2qKxJfFP6 6TIl00z81DMmEbXBadDazrUG/mQcxeKVI63rtbZI7mX7Va2OIWXTUHObURPVjR8uvBmr h/C04g7PmR7J5hYIxULaxF8VgR1TGjBE481qInHKyE7hnNXuuXyngmTo1XAW8dng/IbF JuKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b="U/bgW78L"; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=jpEXcJur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si4895638edr.227.2020.04.29.19.01.24; Wed, 29 Apr 2020 19:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b="U/bgW78L"; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=jpEXcJur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbgD3B7w (ORCPT + 99 others); Wed, 29 Apr 2020 21:59:52 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:51728 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726282AbgD3B7v (ORCPT ); Wed, 29 Apr 2020 21:59:51 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id F416F4999C; Wed, 29 Apr 2020 21:59:47 -0400 (EDT) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=ErazowRay1P/AwFSRhYIU6Y2Vtg=; b=U/bgW7 8LRuDwed7cFJI+OLHcNjS2azezYw4bDECsXxOtmXzamJa8j9tAdCdRFr37MXprd5 ErxVxpe2KVIBpAKAVf2dKTwzyPiZ3RDGm+EfMP70RzW2Zf/0ARTOupK3h0F1z+hz mQJPY4L14N4+MX2vB7h1kvD7/e18IFTZLuIv8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id EA42A4999B; Wed, 29 Apr 2020 21:59:47 -0400 (EDT) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=OH9QgA1zs57t3X+399BRoLLVjiVfyd9x67bP0Lvx9VY=; b=jpEXcJureDScwgQSTF9eHzcwhmQuFrOHxRs892SZDNVkINIFS5TbHDpabFpo7Gs7IHlBnmskokz8D4i2YY5ViibSy+NBswTJ776BfV1BmS29V/WPbozOzfLFQDTEEXWotrT//LfOGQVTKKoMRDg2y4UW+ua6jfMPr/mLDlS+tJQ= Received: from yoda.home (unknown [24.203.50.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 6E06D4999A; Wed, 29 Apr 2020 21:59:47 -0400 (EDT) (envelope-from nico@fluxnic.net) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 91EAD2DA0A91; Wed, 29 Apr 2020 21:59:46 -0400 (EDT) Date: Wed, 29 Apr 2020 21:59:46 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux admin cc: Jann Horn , 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, Christophe Lyon Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there In-Reply-To: <20200429215620.GM1551@shell.armlinux.org.uk> Message-ID: References: <20200429214954.44866-1-jannh@google.com> <20200429215620.GM1551@shell.armlinux.org.uk> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: 44EB08B6-8A86-11EA-B6B5-D1361DBA3BAF-78420484!pb-smtp2.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Apr 2020, Russell King - ARM Linux admin wrote: > 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.) It's been a while since I worked with it. However Christophe Lyon (in CC) added support for ARM FDPIC to mainline gcc recently, so hopefully he might still be set up and able to help. Nicolas