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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6933C3DA4A for ; Fri, 9 Aug 2024 14:40:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 291706B008C; Fri, 9 Aug 2024 10:40:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 272A26B0092; Fri, 9 Aug 2024 10:40:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 109646B0095; Fri, 9 Aug 2024 10:40:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E80FD6B008C for ; Fri, 9 Aug 2024 10:40:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 743C71C4B8A for ; Fri, 9 Aug 2024 14:40:38 +0000 (UTC) X-FDA: 82432968156.20.F347E34 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by imf18.hostedemail.com (Postfix) with ESMTP id F3EA41C0019 for ; Fri, 9 Aug 2024 14:40:35 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=xmission.com; spf=pass (imf18.hostedemail.com: domain of ebiederm@xmission.com designates 166.70.13.232 as permitted sender) smtp.mailfrom=ebiederm@xmission.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723214371; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NTtO2JgJ63YuC9qZnRU8yG2PT1T0/jl0cPtXKJVCVlo=; b=gHZT8atD0aG5ZKflvhp+H9qeypPZ8O5rAKHhJBwMfpLjA3Y1Sm4HOA6tgxpoifNNQkj4zZ vHUHJr/O/aZyMGfxWByU/LjFvuTRtKJoqvsd1xLvPenOZO4hxTO2jbK9lTYskq/n8y9B+t k4VsuiR45A7ud1dmvOE3fXju/3x4DAo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723214371; a=rsa-sha256; cv=none; b=0fOuf4Au8hJwloBcaakgGoL9CaQNPqoTZEfG2bdLZmutz9cyz0g2ZM9raxV+1YabKlyEns +aKejJNEbs5GwbeVq4ZVWPE7ZnkwYzOgwJEaccN/jHjbuaP1jK69PmjIBbnlSNLRjyBbga NS6VEMOhtpk0oN0rkeQZGy3pAjK9i6U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=xmission.com; spf=pass (imf18.hostedemail.com: domain of ebiederm@xmission.com designates 166.70.13.232 as permitted sender) smtp.mailfrom=ebiederm@xmission.com Received: from in01.mta.xmission.com ([166.70.13.51]:53966) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1scQnB-00G0YB-8t; Fri, 09 Aug 2024 08:40:33 -0600 Received: from ip68-227-165-127.om.om.cox.net ([68.227.165.127]:40748 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1scQnA-00EK0p-Ab; Fri, 09 Aug 2024 08:40:32 -0600 From: "Eric W. Biederman" To: Linus Torvalds Cc: Brian Mak , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Oleg Nesterov References: <036CD6AE-C560-4FC7-9B02-ADD08E380DC9@juniper.net> Date: Fri, 09 Aug 2024 09:39:54 -0500 In-Reply-To: (Linus Torvalds's message of "Tue, 6 Aug 2024 11:33:12 -0700") Message-ID: <875xs93glh.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1scQnA-00EK0p-Ab;;;mid=<875xs93glh.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.165.127;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX1/+3r11W3mpJLkTk2peSASOmbgRf8qf3YA= X-SA-Exim-Connect-IP: 68.227.165.127 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH v3] binfmt_elf: Dump smaller VMAs first in ELF cores X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) X-Rspamd-Queue-Id: F3EA41C0019 X-Stat-Signature: 5js6ty9muxe9jxpu9i8jhsnsz8qiqiuy X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723214435-737660 X-HE-Meta: U2FsdGVkX1/FxhpoGsTduZU9KEpcxlt2C5oQcZPxb/HtGhd0VEA6Q4Pgy26Vpk2pTwGopGe3h9RtJXNdX78rt6ISIhAdYj7XNardDCUaRwOA+y9Q8pgNjFZ55X6fz92NZsRrPLWUEETdY294Jq5UKARhUWJtF1ZeJgIigJNPOSMw6/rYEg/XEkJsK7/LTjj9+kw8Njg5BoJusXoE9P8zcXJ3epwW2cSoVVaC4jnTRIBkm5Wvy2OZXJVDMJOt6yiVtnD1AyFjssLdvOzmTgI+fXh0EKgnk7Q71lM8zpnGnviccWDUufJxsGhvvcgbmqC8ZGGEu7XmIJxqcT+aTcgWM6DR//zp7Upoh3lFP6/gC3OS8r9Yi38cYF6zJAJW2MDVG7s91tUSMOJyfif82YuU/8WgNsz/lH9ruXEP4VLLiH7avIgNcEIisTv0iYV4J7H1JHTEbfOXPql5l0gX6v/yX08pgvqTpmXb1nAfdKK8kBPA5D3lfd0jOQDKp+o+ZW0GSOxtlyuKpJ2iR7PvsybdU+VaWKwQiuvCxS8710wwxApdD/oRkQbLJj/LiH1dnnT+KFxkdgoAp7N7Iv8n+5TLuGHmxEECSnLB4AlhaSs4U9sM4JWtQM/B/2QowcQ1aDeSP5urWHzmNBpzmDhHQWGd0YSlWhqwAdSce7DAq28uyh9Xirxxm2PIiQJVdF6EX+vusw1gw+psud8ftY+nb/dUrmnf9MPnyB6GDfl9/OH7RM6fhnbvUXLYLz+JG6FQYk80fytHG20IHWfzX8bewgPx2hUJTjGK6NVpiEsg95VhBCpbmgFFZbYDjg6TsP8r2YMODwkK7GrekxjhJvHO4+K9eEjL8ufEw7TX7LCXymNUH7CsfC15Nkqhrmi0G40YaHSB2vRV30TRj9ixgFm5A6N/23MtG1Nie+hQjqarD/Y/fbPhzJzVtwH1Y1L1bi0RxuJuNqIqLq/OU9PcuFNS1q/ SkhoQWSM 271O1G72mJsux0X32DFwyq3bLcIhI6zJWhZK3eW4GNQiwYm/F5T20otz3ExdTN2Y+KPgOKUxChvcFjyBQCvAm9yzV7m4eEfgfTXXifgPX0k4WoLV95ZJeH1NnuQ9Ahg9AKvlMKcMvgW95b0EyJc6ENKduaQU0+br1LAOgcnxRD1x2GVooczoiRIa9u55klbeU0phwOct2Y6WCFPR8KTtjkCbGfk6AgENopE4+nuBaV4hs3C+049Q60nJi38JETtmprxOA 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: List-Subscribe: List-Unsubscribe: Linus Torvalds writes: > On Tue, 6 Aug 2024 at 11:16, Brian Mak wrote: >> >> @@ -1253,5 +1266,8 @@ static bool dump_vma_snapshot(struct coredump_params *cprm) >> cprm->vma_data_size += m->dump_size; >> } >> >> + sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta), >> + cmp_vma_size, NULL); >> + >> return true; >> } > > Hmm. Realistically we only dump core in ELF, and the order of the > segments shouldn't matter. > > But I wonder if we should do this in the ->core_dump() function > itself, in case it would have mattered for other dump formats? > > IOW, instead of being at the bottom of dump_vma_snapshot(), maybe the > sorting should be at the top of elf_core_dump()? > > And yes, in practice I doubt we'll ever have other dump formats, and > no, a.out isn't doing some miraculous comeback either. > > But I bet you didn't test elf_fdpic_core_dump() even if I bet it (a) > works and (b) nobody cares. > > So moving it to the ELF side might be conceptually the right thing to do? > > (Or is there some reason it needs to be done at snapshot time that I > just didn't fully appreciate?) I asked him to perform this at snapshot time. Plus it is obvious at snapshot time that you can change the allocated array, while it is not so obvious in the ->core_dump methods. I would argue that the long term maintainable thing to do is to merge elf_core_dump and elf_fdpic_core_dump and put all of the code in fs/coredump.c Performing the sort at snapshot time avoids introducing one extra reason why the two elf implementations of elf coredumping are different. I did read through the elf fdpic code quickly and it looks like it should just work no matter which order the vma's are dumped in. Just like the other elf coredump code does. My practical concern is that someone has a coredump thing that walks through the program headers and short circuits the walk because it knows the program headers are all written in order. But the only way to find one of those is to just try it. Eric