From patchwork Fri Aug 2 22:37:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Mak X-Patchwork-Id: 13752085 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 3767EC3DA4A for ; Fri, 2 Aug 2024 22:37:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 980856B007B; Fri, 2 Aug 2024 18:37:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 930CB6B0083; Fri, 2 Aug 2024 18:37:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 782CA6B0085; Fri, 2 Aug 2024 18:37:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B0B16B007B for ; Fri, 2 Aug 2024 18:37:51 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 14727413E3 for ; Fri, 2 Aug 2024 22:37:51 +0000 (UTC) X-FDA: 82408769142.02.4407C24 Received: from mx0b-00273201.pphosted.com (mx0b-00273201.pphosted.com [67.231.152.164]) by imf28.hostedemail.com (Postfix) with ESMTP id B30ABC0008 for ; Fri, 2 Aug 2024 22:37:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=juniper.net header.s=PPS1017 header.b=lYLGcNTk; dkim=none ("invalid DKIM record") header.d=juniper.net header.s=selector1 header.b="GqUv9h/C"; spf=pass (imf28.hostedemail.com: domain of makb@juniper.net designates 67.231.152.164 as permitted sender) smtp.mailfrom=makb@juniper.net; dmarc=pass (policy=reject) header.from=juniper.net; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722638237; a=rsa-sha256; cv=pass; b=ikyDVB6MM5CyFy6Xk7fNCsB0xl4aO+7uRtq0uJI8DQInoQIwxD+8W0Md3tzgbDuZMAO4lA 5885o9pxnp69tXfrqFXkg56sXRCSb8nNPm3PBTqYuRHUzL5Id7K8iux2Qcv0Y+p0eclNuI QvaYqCUxNsI+x0pe0KV3kEIAnmpxELo= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=juniper.net header.s=PPS1017 header.b=lYLGcNTk; dkim=none ("invalid DKIM record") header.d=juniper.net header.s=selector1 header.b="GqUv9h/C"; spf=pass (imf28.hostedemail.com: domain of makb@juniper.net designates 67.231.152.164 as permitted sender) smtp.mailfrom=makb@juniper.net; dmarc=pass (policy=reject) header.from=juniper.net; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722638237; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=YNG8Ew/NWAPAh8pu7dohZmYYKAKO+ze9L7LbrIJbAjc=; b=y+sBlQAHChiITXdnBYz9VPeR97rVx8hWCF8Lzd1MPOBNd8/Wy3JD+8txGC3gexyTCAHjAN MIiEk0skopqqEX0unGz+KNW9bZI7IX0R6VRx6BJsh4jQLm7j2AL6D/xoHniyLBrVHZJFa+ rHlIzi+i/AZoSuYm0sKwSAhOS9XSdhg= Received: from pps.filterd (m0108160.ppops.net [127.0.0.1]) by mx0b-00273201.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 472ITlkl018314; Fri, 2 Aug 2024 15:37:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; h= cc:content-id:content-transfer-encoding:content-type:date:from :message-id:mime-version:subject:to; s=PPS1017; bh=YNG8Ew/NWAPAh 8pu7dohZmYYKAKO+ze9L7LbrIJbAjc=; b=lYLGcNTk5m9iGwX+8PmO6CxWzk394 bna7J5+NHvKJ+EU+BM75u3O6gf1hExkrS+wgb18Khg6y7MePpvtXwSMlunc+lHJl DBkrIxaXbjXCvBg4Wsy2YoXzgIWuZ9taXaN+g8pVzfP/mXdCWy+vUDvOpVZVsQ9R k4SDj6+1G73V8lrwgM8a9B/ftNqu/Rq9GIU6CU2wZTdNifEmk1p4qvL3IfKpcUvH UmCApu8AnCpEH4u/8UwU2eeR64nkYZWX7bYz4sp0Suk9izStI92RcXNLkDQHjXx9 UP7z/yP1bHpG5oXqKWZOcP9q3XFkSGhGKbvRBEvNxlLtl3eJNyp6Ck08Q== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azlp17010004.outbound.protection.outlook.com [40.93.12.4]) by mx0b-00273201.pphosted.com (PPS) with ESMTPS id 40rjdk40gh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 15:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AveIP0cx+U2XGMKb0LIfMREeL1S7sd4O6xAXH1STSApA77kS6JZ4sq1Fb3NMuswFjB9QlH/9iq2PNkdijbcdUdCQx/aLD1ngvk4L6kwL3ZqbtUfb5JZmok0uQlJzjWlKp54mMLUIqcPuoRTKaLXj53pLqcCOyQrwLSDV4yQHfw1LyFsNmMN1GSWQtGbdCCVd9CN66SEhKwsim8zJJQg1vFu5GUvfHJEo4p/d54i59hBgKNZp+b4qKsHR78me2hEm8jLBWU7xVr/QNFNqxQ63w4L8j2UnTpgbe9GJhAE4hEzuSkD51lAmponrYJRxxVWh/ORyPUPY/BsYE9mHoSsw/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YNG8Ew/NWAPAh8pu7dohZmYYKAKO+ze9L7LbrIJbAjc=; b=HRWnMmo661o33Zh55d1e5LD61IaOH9tLHbqhU46dEuAdh08YNjmG2VUMxE34U0UgXRvt0EVQy0cfNynoB5HGjPGsJc6F2hXMkx28AI/zBXLSYHrlLDRBHGeQj3TaJTPE7FRv7LDyYUuhtUeR/8UEl3EsvFISsKcmBuo0urO4dLxQdN6hnNyrBxxUjm8dZcUJToDlk9dhKkfcDSI6uAT22YNO5wwK5oQxfhCTrT3RbYVjIDMWmDFj1J2MNc+7wK8jLNCNw/PZ+KBW3RL+ggAsraKuBMUBCmxlRhqzCUaUFeRrOXvKM0abL8whjyjEBu7D/ft6J/GjB5/6EudQNuUwYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=juniper.net; dmarc=pass action=none header.from=juniper.net; dkim=pass header.d=juniper.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YNG8Ew/NWAPAh8pu7dohZmYYKAKO+ze9L7LbrIJbAjc=; b=GqUv9h/COkfBwRtQqwPl0V9fEJkN+EyxuUf294Y6APNaRWuYx9GwLUU51xkGyiIbqMplUHR8zwnf54UBDoe8ic8DQZQV/OyJseovf+H/2N3fbQY1qF/MZOIMKTZ68Rgu/FvCM1+/Tz4cWgdzE2w0UCF5nUQ71Rvvuga0WKAB3d4= Received: from SN6PR05MB6752.namprd05.prod.outlook.com (2603:10b6:805:bc::31) by DS0PR05MB9151.namprd05.prod.outlook.com (2603:10b6:8:c5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Fri, 2 Aug 2024 22:37:38 +0000 Received: from SN6PR05MB6752.namprd05.prod.outlook.com ([fe80::919:cd1e:18d2:5bd2]) by SN6PR05MB6752.namprd05.prod.outlook.com ([fe80::919:cd1e:18d2:5bd2%5]) with mapi id 15.20.7807.026; Fri, 2 Aug 2024 22:37:37 +0000 From: Brian Mak To: "Eric W. Biederman" , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" CC: Oleg Nesterov Subject: [PATCH v2] binfmt_elf: Dump smaller VMAs first in ELF cores Thread-Topic: [PATCH v2] binfmt_elf: Dump smaller VMAs first in ELF cores Thread-Index: AQHa5SyT0fa0xUD8R0S0K3p3byXrDg== Date: Fri, 2 Aug 2024 22:37:37 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR05MB6752:EE_|DS0PR05MB9151:EE_ x-ms-office365-filtering-correlation-id: fa8bc306-3838-439d-62af-08dcb343b61a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: un5n852M6qo+4OXm1k9p6pPrAkzKEs0dcWRvekQZC1nwmjSQgCgWSQ0ueHwXJHAsXREaMz/4cIHxQ+KJIvdG81iHPnSbFCIl/pJbS3F3yCbAjg+IAiBz1O2eQBdl1J2YYUvrpnwNIyL9aVWIu458383SJ3FUFMG63HxAIS7zSzD/fCDA/PTBbNjT1hZ6ZG1lSWDyKdCKJrtBrpuGeVGne+Ka+npISvA0HlB8TRsAaX9Je6OuGveUDKPQJ3I0R1a5DWlv9cbrtVXYFRIEJf1FrA6QFYbRRkrZQW1Qwyn+oUx4k9dGdvrtZ9NxEnqNE+EZ52Bmvs264mFNs3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0h7B5caHisMEoIK/oTyJj9ir8gubSA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR05MB6752.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: 2B1T6Y/gYygUG1HzWJD5K3yYOL0iiRxcdpaB/xok89m+kINT7pwwdJp5dIH5nenoVcnsRgdipk+ypLXSrxEsagzR0BsKzYYmgp8RGRkW4F3Y89ACXqEp2lbiXY7iBbKYH4TTOFsI9QlJDv9EfVsGpyKWVL180AhOtbA/RRYd75hG573oYCFa6LsXS1pPHQ/ODIjNyXLjqexTwIgU1lDr9Zj0Z45oYNqEAn95sYyB2LMmJ02AzW/IAKsJbSaADxH8s46zKnnABJtVahAFrst/f7oIugApQIwVlGqFuHoJLAD/2776qvCejqk/z7hd8wbfNUKiHzkHb26X9W7FFN35/OTh0olWmVkCxknCa1rTVUXIdIqMHgJi9IocB88CG7k3gAJMaXQF4C1u27CTZPSzlLrav91uIfAEf2qe8G3oMfakrfYtT3FoWAUhAlfuVtanPDhxIFmHALMlQQN5Rm+oawkxy6WMh/lSQwl0YrpQhgoD1DkQV0+l88/2lYx4ktjduuipVclNH5R7LyreMDoIzc1UNnAdbTqYa6b5MddXr0FgJ5NIGT1tLokJGaJl6/7J6ZZkkFSdrzoKamwuFlDFvY60Il/iM7sl52T2iS2w+WMnDLEMD9RP/YPs+L2RK/fM6DizhXtB64fow+TRhxnKbny0NYPbIfe7KdiADAwSjqBTFS7sqVRdnvcLGUVDKO/BhKLkca6cfZbAhkVU/2s9D7l7GxOkaTj9LC8SWuPN+gqqVsJleZj5v2J1Qq3HQK/eWaDOTpEpBM4WRnZqhYXEtmkwrkzNPKjloGb3aSi89tsX3S7iNN0zYcSUJkXcecxXnd3m7fZZaHPenJtTcC56m5Ol6kkQMtRpT9Ov9XRWCtE4/+j8LeITN//WFywTWaI+e2/0qzeLDzhFR7+mOywW5KLsJ2Zz9cAlnfdfzvsUveLbjeCvEuek5TJ9tj2W9lk8Tgpjy2iAh0hu9hzOQb1Og1oerPq9IF8KB/1uio5uEFVceu0y+NhjY0eIzCV7boO2IARj2CxMYtBz9KSOPvzE6boqDMHml/Og63t/MsT1XyNqvcJXjdraFlsLyzv6sfA/DUwIjXeJVbH4gfqfNiNP8VQWZ50jLtxRWEJWs2PhnCjxAcLEh8KrZqmp6e6MO2tWyyuxqPcThAbHXoxIl7OU1qZYYsF45NX1KIXqKFWNuTXyGlxfCAl3rL09mp/NIVnaYZC1dTiS7M09NB0jIWk0SGv55M+AAUWjZqwxqDmXDLFH1Q+OF3IRrfQVEnHlPeg9tyIs9oGMjQsHgXudeZRk1vno3E4zQvGVYgGDElIM9Uo9n6FM6N2Uzp+91RxqqfWuAPmqYrqfnOBVua1QTan/d4cjSGunN2W/5XND0QFbU2Avj4Ppff1wjlxJCOwXN/tQxrnaHbCtBgyRoHdDENmkOpyyffQUWSWEwYs+AJqS6EussNlUYPBKV2Ux+ESocaoIqNkWoEuq201QKPXg3w10kzEr2AbOT4OqpNf63cvg0+F6QFtik+vIfYvTxaf/h8zxgIamwUylG2ouB9MfNQbrGCB5Pi3gy9CkNF2Q6wWoVooy7dH3KDjC6Q4Cu/plnW1a Content-ID: <1566CC8F20ACAA4D871883ADB800A869@namprd05.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR05MB6752.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa8bc306-3838-439d-62af-08dcb343b61a X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2024 22:37:37.8841 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: FFsIZBUyInzyHrBg/EkoUUH0+6K1HCx3wBl75zo4APza1mwm+ot//rFeBOugCdadUPJxx5fbuiMKiL69w5+gpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR05MB9151 X-Proofpoint-GUID: iWcQCK7Q0GgfB8-e4uD5ET2FlX5AFimG X-Proofpoint-ORIG-GUID: iWcQCK7Q0GgfB8-e4uD5ET2FlX5AFimG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_18,2024-08-02_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 malwarescore=0 impostorscore=0 suspectscore=0 spamscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=849 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020157 X-Stat-Signature: u7q7nhyfoutmb9tgc8sfq1dhbikf5wp5 X-Rspamd-Queue-Id: B30ABC0008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722638266-681451 X-HE-Meta: U2FsdGVkX18yv4txpMTcFpBirPQouDUbfCHaFz2P/IpxXl0PUZRQrHFiV8cjgnTFdRVG3doRw3AVWOCloQM0GBrDlky0Dm0epWMjtU1VPCCl2k9HBaO2sQN2gwiBbLtYNp6jKNa7bSnHiv80BJT4SwFScMm06eUwGL6GhQXuS34f9R77i7kk2P9iAb+bjCEZiRoa4QrAD5LTCJLb3bOMnAwiDciCjAy1fyNn/Y43Enwre5j77O7yGiiuTavHXptrjfpkR9K7KHn0ylIYirqHk8a1HIK9kC5PiJzRSmKlxB2+LwKQvc3tHSKtg75sqAuS3KZRTL8vkdpjCrm0+dxogQfjsbJDMu/T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aOftjJkbfSl3hlTnNwtXkkKtQJ76UJYqKcY9ZPtPcd1cl5cHveSsmjLojBGIKZyc115ctbJbId5ERYlG9EbIfj19bOuafVUUEvtr9IyORhvJDf/fyB87s41DuSbhANiqdeoUne8yRf8B8LGBEVU4C9TI5boTnoLWt6P3yEdKQ= 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: Large cores may be truncated in some scenarios, such as with daemons with stop timeouts that are not large enough or lack of disk space. This impacts debuggability with large core dumps since critical information necessary to form a usable backtrace, such as stacks and shared library information, are omitted. Attempting to find all the VMAs necessary to form a proper backtrace and then prioritizing those VMAs specifically while core dumping is complex. So instead, we can mitigate the impact of core dump truncation by dumping smaller VMAs first, which may be more likely to contain memory necessary to form a usable backtrace. By sorting VMAs by dump size and dumping in that order, we have a simple, yet effective heuristic. Signed-off-by: Brian Mak --- v2: Edited commit message to include more reasoning for sorting VMAs Removed conditional VMA sorting with debugfs knob Above edits suggested by Eric Biederman fs/binfmt_elf.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) base-commit: 94ede2a3e9135764736221c080ac7c0ad993dc2d diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 19fa49cd9907..7feadbdd9ee6 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1990,6 +1991,20 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum, shdr4extnum->sh_info = segs; } +static int cmp_vma_size(const void *vma_meta_lhs_ptr, const void *vma_meta_rhs_ptr) +{ + const struct core_vma_metadata *vma_meta_lhs = *(const struct core_vma_metadata **) + vma_meta_lhs_ptr; + const struct core_vma_metadata *vma_meta_rhs = *(const struct core_vma_metadata **) + vma_meta_rhs_ptr; + + if (vma_meta_lhs->dump_size < vma_meta_rhs->dump_size) + return -1; + if (vma_meta_lhs->dump_size > vma_meta_rhs->dump_size) + return 1; + return 0; +} + /* * Actual dumper * @@ -2008,6 +2023,7 @@ static int elf_core_dump(struct coredump_params *cprm) struct elf_shdr *shdr4extnum = NULL; Elf_Half e_phnum; elf_addr_t e_shoff; + struct core_vma_metadata **sorted_vmas = NULL; /* * The number of segs are recored into ELF header as 16bit value. @@ -2071,9 +2087,20 @@ static int elf_core_dump(struct coredump_params *cprm) if (!dump_emit(cprm, phdr4note, sizeof(*phdr4note))) goto end_coredump; + /* Allocate memory to sort VMAs and sort. */ + sorted_vmas = kvmalloc_array(cprm->vma_count, sizeof(*sorted_vmas), GFP_KERNEL); + + if (!sorted_vmas) + goto end_coredump; + + for (i = 0; i < cprm->vma_count; i++) + sorted_vmas[i] = cprm->vma_meta + i; + + sort(sorted_vmas, cprm->vma_count, sizeof(*sorted_vmas), cmp_vma_size, NULL); + /* Write program headers for segments dump */ for (i = 0; i < cprm->vma_count; i++) { - struct core_vma_metadata *meta = cprm->vma_meta + i; + struct core_vma_metadata *meta = sorted_vmas[i]; struct elf_phdr phdr; phdr.p_type = PT_LOAD; @@ -2111,7 +2138,7 @@ static int elf_core_dump(struct coredump_params *cprm) dump_skip_to(cprm, dataoff); for (i = 0; i < cprm->vma_count; i++) { - struct core_vma_metadata *meta = cprm->vma_meta + i; + struct core_vma_metadata *meta = sorted_vmas[i]; if (!dump_user_range(cprm, meta->start, meta->dump_size)) goto end_coredump; @@ -2129,6 +2156,7 @@ static int elf_core_dump(struct coredump_params *cprm) free_note_info(&info); kfree(shdr4extnum); kfree(phdr4note); + kvfree(sorted_vmas); return has_dumped; }