From patchwork Wed Jul 31 22:14:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Mak X-Patchwork-Id: 13749285 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 D120FC3DA64 for ; Wed, 31 Jul 2024 22:14:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EB146B0083; Wed, 31 Jul 2024 18:14:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39A9B6B0088; Wed, 31 Jul 2024 18:14:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ED0B6B0089; Wed, 31 Jul 2024 18:14:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EEEFD6B0083 for ; Wed, 31 Jul 2024 18:14:30 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9B24C1C209F for ; Wed, 31 Jul 2024 22:14:30 +0000 (UTC) X-FDA: 82401452700.15.182F7D3 Received: from mx0a-00273201.pphosted.com (mx0a-00273201.pphosted.com [208.84.65.16]) by imf13.hostedemail.com (Postfix) with ESMTP id 354F82001F for ; Wed, 31 Jul 2024 22:14:27 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=juniper.net header.s=PPS1017 header.b=FA3YRJav; dkim=none ("invalid DKIM record") header.d=juniper.net header.s=selector1 header.b=YRnS9tRK; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf13.hostedemail.com: domain of makb@juniper.net designates 208.84.65.16 as permitted sender) smtp.mailfrom=makb@juniper.net; dmarc=pass (policy=reject) header.from=juniper.net ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722464011; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=YflLRIY8DI4aOnDtpKIdHMlIeX9xbOo9BxY47Q3hTZc=; b=NIPvANriJDH6Pm3UsrdUMnSspfPSeMuvbn1QyFJwjpcLSUwWUcGD2ZODG1Tv1ELRCjONX4 K55oNRw+JxIrcAB50wbDs+N6M/qRmW/wnve/+5BXRScVa9zWbAzhZ2vSPrMOovZUB49I2W rSzdbJ1DQkRSrVp2reGgIQCSXLW0dT8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722464011; a=rsa-sha256; cv=pass; b=Rr/xYvbNrLq8WXKhSxW75gqpuNvGTVxgCrNQ9tFt4TeW4zV0HMssTbWL7gyS6zgaX20mJ8 n65Zt41dmj0+QdF5pt37f87tVee7UTPYJjNLEyp6+BFgjJhDKDDU14vP8ylhKCTxHv2RBs 53H+S16o9b/4f0X2qeOsCPajA+r19I8= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=juniper.net header.s=PPS1017 header.b=FA3YRJav; dkim=none ("invalid DKIM record") header.d=juniper.net header.s=selector1 header.b=YRnS9tRK; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf13.hostedemail.com: domain of makb@juniper.net designates 208.84.65.16 as permitted sender) smtp.mailfrom=makb@juniper.net; dmarc=pass (policy=reject) header.from=juniper.net Received: from pps.filterd (m0108159.ppops.net [127.0.0.1]) by mx0a-00273201.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46VE9d93016978; Wed, 31 Jul 2024 15:14:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; h= content-id:content-transfer-encoding:content-type:date:from :message-id:mime-version:subject:to; s=PPS1017; bh=YflLRIY8DI4aO nDtpKIdHMlIeX9xbOo9BxY47Q3hTZc=; b=FA3YRJavQesdmoJjqmh/qOSleM+7z ZUXKYDAVheHNps1OPbz7caIwzjroKUpvftByLuIQkZZXtZ6EBqPy1+4ESephvHDO 7PzwQqRwOR8mLYLCPl5gVcXScmWgBbeCTkcjegtyhJ3WlHQh8I7UXK+rik9FdC0s SpOsCvSPBfjkGYVFQA7NU3WkNvZGIIu0if5JmpbNjXzvXfLYtaPB6yOKcG2qeOJJ Wmu/U/4ipZ2yX6enLNNpd1lHChsnadSGk4G3id+/5Nx9qXDhgXIOqo2UhyMaDx41 UIPdEMw3E5WiNZlRJxFISr+dJog7epwjts/sIipAv7AwCLfhaQSafqgsg== Received: from cy4pr05cu001.outbound.protection.outlook.com (mail-westcentralusazlp17010007.outbound.protection.outlook.com [40.93.6.7]) by mx0a-00273201.pphosted.com (PPS) with ESMTPS id 40mxussq3d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 15:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=unmyrvE//DFsr5AiOdskbe6iiBzx6aa1aPC8BlHwgWxgyNXpHaJV40JUoKNuzVtUtQV096Kx/Vqm1gDQ4PECFxPFv0Ahc7EXtOFIV3ewVk9ntcn1vQp8OVXB2KIfI9FeSFD8bpzRHanyRQ4371D6f6jHOid8/wv4WNb27kXpBdyWkFBTO+Shk0mi9DSxB9m/GAUlkVM2X9HTskLgidkpQK+y44mFx2zJr1fv+Fomuitzi7oUIpd9SLolIjMZVKbksTOqQX/9ricjItBIHBKOJipluOXT6vTxuQxeAKFpjfBoA53CdQrDF9qp/Rb6iYy+R2fez3R2Glb3cIy7aVbccA== 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=YflLRIY8DI4aOnDtpKIdHMlIeX9xbOo9BxY47Q3hTZc=; b=vzxDdKe8l72cICbyDOwwbbJP/ATjkKcxMT9eXwLB1QpwP7Pbpzu18dlQjkLhxuqjpQDRKHjtgzOwUtpNvhmTWb7JgbXTvkt1cR12/jx1CtR7Pqr7tFAnkcV0DEP+dBnOD/Pf4lE9vmAMoID/DnD5rZUFaxypJADu69hZJbU44D7VXsMmlSYqnQtW1F9sdbchIbS9UUJm8OU+zOV7VuQXOwCtTmOYBxcCibWcdWCBSHb8KSv1BB/RVKDiXGRAxF2PQBA7MgAXJR3RLswzTnERfg8jDwxih4QEeju8c/mGM2/XDg7+klNZpEap1lEPweMG1+ctDoCdwZstOahVzkbuoQ== 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=YflLRIY8DI4aOnDtpKIdHMlIeX9xbOo9BxY47Q3hTZc=; b=YRnS9tRKV0sgOI+A968lcWoQmRu2BLsnhcgaZmI1hKHXf36PFlEsZAusGhMZJhBMzctocdGqjQP00LO6835FePNM7nEt26sNJT+SBkc5zOeQcGdVF25lTIkhAzllNeXvziNiWv0jJcmkyWBe+wK/vSd93Igd7R8YyVgBT8NWBL8= Received: from BYAPR05MB6743.namprd05.prod.outlook.com (2603:10b6:a03:78::26) by SJ2PR05MB10356.namprd05.prod.outlook.com (2603:10b6:a03:557::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19; Wed, 31 Jul 2024 22:14:15 +0000 Received: from BYAPR05MB6743.namprd05.prod.outlook.com ([fe80::12f7:2690:537b:bacf]) by BYAPR05MB6743.namprd05.prod.outlook.com ([fe80::12f7:2690:537b:bacf%6]) with mapi id 15.20.7807.026; Wed, 31 Jul 2024 22:14:15 +0000 From: Brian Mak To: Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: [RFC PATCH] binfmt_elf: Dump smaller VMAs first in ELF cores Thread-Topic: [RFC PATCH] binfmt_elf: Dump smaller VMAs first in ELF cores Thread-Index: AQHa45b6H7qt2DxWIUm3KHixJZvP5w== Date: Wed, 31 Jul 2024 22:14:15 +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: BYAPR05MB6743:EE_|SJ2PR05MB10356:EE_ x-ms-office365-filtering-correlation-id: eca11b77-1aa5-464d-410f-08dcb1ae1d23 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: E6NRzAH+Vop0fauMNDXWcjP1VFJrg63VZ0WFLq2j3dvs9ue5IxnoSMeESvwKkgzgyoTByHPmoevnyNPZ4RQOADFdP1XEwZ8TIAdHzEVChO0FgE6qHCAnTniFQLpYE8JWcbIbOjvOxjKqoFAgQiusDl+ZT9tMlNYJtRcyixG5/lCvWET4YZ+2iIeePylDm3xLu//qcvvpY6owe/04q9FDRVgBHD60vhfU7AEtYPO2KhafJoNU0/d766ipFSwv5zaBHeoxBXSb9F3SirQH/h2ib+3ndscgHazE6kVh7nHMTrojU4/C/SAUwkT8fA8Onldf/WFOzcOdPeIwFmgXWYCS4cA0s0NbAEKZQxTHBgt/920afxzbMPcXNHPIopeTd3jnC/K3vWvims9dCynP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FV:NSPM;H:BYAPR05MB6743.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: adEd+BMlz+TJvP1HvXUcOCMc7qh8qM4qXRQUOX+myLis3BBZQ9bRlKSQO7MnvK3YnbgBK0dUznfxuhpxB1tzdghXqO8s4N48YlJ20z6/r9hlC8UEGHzonIoyDeG5R+YCnysa0SM8rvE0cTD9TYsRCZ8Ui6BLdskqWxucv6KzH+ByoABuJIm9Yb6vm+EofcxnlqutFuzj6fDoF3kQiGHHM5pV479M/PUbzrJjPlsrJl0hK/8e4eBpHpugvfyh4S/WDYnVTe7qOgucU6Nl/Y35wSk3RW2rlzlzg5PTHzBYmoxSFIKiWVf64fiKhhzY6BRDbLAEgSlSf5F5Xd2h/AQksjIn0sntbXrdhFv49wVWwlXC7elJQmg6OTCz4bH3p4786oLPweitWMNC1xFrB8OqgJxXMR5sr4isFIxq4qBe0Yw6u9IHOeKOQmtSF1af0gIuk6yGP9KRCg0lqVb4e6LYWLFcRtix1tfXtq68SFsWaSO3ARE2grhFPiM0s000U0UOf0yKFgTvVUg7wv+OyYgTj8K8EOCsAJ/+3G8O2Vax136MAzha9GaveQACZcyDQaWQ52UFnxvumpw7speLJm0NbJfO632ZSICEBrkBytjRsSE4oblPSqp3TKhq2APxOgMjXjde58UP/VpG6pl/gsY3zzBFDg5utSoBKFssLXxZjMNUaZr15Q2ij8mkxV7/08ArYtCfifYX8PnPKaT5cOdG3mzrWVMyx4VYXDE7w4mmQSfFsZtCF5ooXqpg3jNOnv/mp0o6EalzYoPUju2eGiGKYlJ0mzbcmYBZoiNCKKPvQv12Rvj4MMqahEVXNVi3dyE+nG/7heq4LXXBZG+yuJHYje5zCBSk+RzioXDk08TkZnFhlmUrDBporh5h2MTohxu/pF21jIj5XBfboE4pE4Dsfse/ahh1yw+KZjbVHB5U06ViLfjcEKpvcI4SMlic7I9HgRFbSbpPlPnz3/5PB3LDZrSbw7ngXlz0nozlOSVdIZdxGVllPkEloZzxgNwt9bNmVchAYF993RwUmsSg5Zni/zoONZ3V16oBtY2HLm1vcXGsjljjMcUnD/RkVLY6SP376QfkrbMWAWR4H2B9fMpmWevbHcsMJEnI+Q13cz2fNFR2wQGkw62/DqReerBBm8A3J2BlCJVGKsuvqz2ZkpTTu6LnicMLICNcsaAEC8TNW7w1x47LmYqdKzgeWcxymWqsAiWfgkA/TD4v52bHwqZjdl5yxlC9RNwWT4YTmPpXZw6GLaMP/GOfvR7jhxunS6OujGkVxSQgvHMShjk5zanhAN5c+xS6Wa9qmb3/l6d7UfCGjEpwiTYLkhG/a4+sGQZANMOBkNcnZXqikuYUehW3uFrBScMEklq2+xf5zI/Xf7+jrGjx5hz1UZg4OPToHEvNEz9VvFqRMkEMBCnZi7tDQhY+a99K5GBDCqQGvpt27uilWZC8RH6miWiqTCwOqBMcZbunAQVaB1DPPEW7u6MFJYb+fvHy2YUQ8ZP7zn5xeMLyj8IW5H92bnU9t4nH1Fjw5/z9aoLoQTi5MA4DKVMh2+qIB5e00S1B34VIhB/8Z84iXUFnvNjM9XcXC8y7Ty4X Content-ID: <3C62EEFADFD9394895817721668CD1B3@namprd05.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR05MB6743.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eca11b77-1aa5-464d-410f-08dcb1ae1d23 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2024 22:14:15.0865 (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: WjHPvamN6l8U2OKkYXHYju5A8UluCyD/ofQh3GA2r6d5ejCQ0+3GmqdRVk3oJGoJe/ISJ0OJScfQGTWzxUk54Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR05MB10356 X-Proofpoint-ORIG-GUID: vYo-ZZqU-OVkY9aLgfGgBKuVvcMJlDV6 X-Proofpoint-GUID: vYo-ZZqU-OVkY9aLgfGgBKuVvcMJlDV6 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-07-31_10,2024-07-31_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 spamscore=0 suspectscore=0 clxscore=1011 impostorscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 mlxlogscore=745 mlxscore=0 phishscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407310156 X-Stat-Signature: d6acgu3uus9g3wm8h5r8odirdiamtxcs X-Rspamd-Queue-Id: 354F82001F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722464067-298099 X-HE-Meta: U2FsdGVkX1+PcnHhT5KR+LaWNMrZM2fMemXf92NSL3uzgxRktWvLKj//FREhT2TSmWKUuma6poKR8K95M2p3IhmYAP9ztmrrVF4mI/YYciXQaa5Dp12DFzv3EJ8+xyNTNrxDKXb80Kul9eEzRg12hX44kgmc+7UbS5lHOGamqi+7gV+N3lUaTb59cb1XckF/3qxUAcO0LF8gu5NyX/CAGk2iZTnY2DRZdMymLVUzdObjgxejfhK37+CTlp1p14L1IHUZpUXiLn6wPRa6flSQGDhSKnJ00SJ0QRMFn7sBVtLwhuZhrWgkWLyX/j/3PmaP4xrDQk6ddtObiMQMwKaA6eTuAuRVkqPhCwLwRnlus/uvxrtWwyU3tZc2LbvlJ0IsnaHLOUh2P/EuF97oJIQrLaVj9TuWmGo5RTjV3G8wrxaTp9NTl9e1R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oSTByq6I0jKzbdw+0HuGxPUDlhNJZ7xfCZIk5LMj4umgAk3U3/Cya8xB7wdVAtKATE2CFA== 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 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. We can mitigate the impact of core dump truncation by dumping smaller VMAs first, which may be more likely to contain memory for stacks and shared library information, thus allowing a usable backtrace to be formed. We implement this by sorting the VMAs by dump size and dumping in that order. Signed-off-by: Brian Mak --- Hi all, My initial testing with a program that spawns several threads and allocates heap memory shows that this patch does indeed prioritize information such as stacks, which is crucial to forming a backtrace and debugging core dumps. Requesting for comments on the following: Are there cases where this might not necessarily prioritize dumping VMAs needed to obtain a usable backtrace? Thanks, Brian Mak fs/binfmt_elf.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) base-commit: 94ede2a3e9135764736221c080ac7c0ad993dc2d diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 19fa49cd9907..d45240b0748d 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1990,6 +1992,22 @@ 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; +} + +static bool sort_elf_core_vmas = true; + /* * Actual dumper * @@ -2008,6 +2026,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,11 +2090,27 @@ 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 if needed. */ + if (sort_elf_core_vmas) + sorted_vmas = kvmalloc_array(cprm->vma_count, sizeof(*sorted_vmas), GFP_KERNEL); + + if (!ZERO_OR_NULL_PTR(sorted_vmas)) { + 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; struct elf_phdr phdr; + if (ZERO_OR_NULL_PTR(sorted_vmas)) + meta = cprm->vma_meta + i; + else + meta = sorted_vmas[i]; + phdr.p_type = PT_LOAD; phdr.p_offset = offset; phdr.p_vaddr = meta->start; @@ -2111,7 +2146,12 @@ 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; + + if (ZERO_OR_NULL_PTR(sorted_vmas)) + meta = cprm->vma_meta + i; + else + meta = sorted_vmas[i]; if (!dump_user_range(cprm, meta->start, meta->dump_size)) goto end_coredump; @@ -2128,10 +2168,26 @@ static int elf_core_dump(struct coredump_params *cprm) end_coredump: free_note_info(&info); kfree(shdr4extnum); + kvfree(sorted_vmas); kfree(phdr4note); return has_dumped; } +#ifdef CONFIG_DEBUG_FS + +static struct dentry *elf_core_debugfs; + +static int __init init_elf_core_debugfs(void) +{ + elf_core_debugfs = debugfs_create_dir("elf_core", NULL); + debugfs_create_bool("sort_elf_core_vmas", 0644, elf_core_debugfs, &sort_elf_core_vmas); + return 0; +} + +fs_initcall(init_elf_core_debugfs); + +#endif /* CONFIG_DEBUG_FS */ + #endif /* CONFIG_ELF_CORE */ static int __init init_elf_binfmt(void) @@ -2144,6 +2200,10 @@ static void __exit exit_elf_binfmt(void) { /* Remove the COFF and ELF loaders. */ unregister_binfmt(&elf_format); + +#if defined(CONFIG_ELF_CORE) && defined(CONFIG_DEBUG_FS) + debugfs_remove(elf_core_debugfs); +#endif } core_initcall(init_elf_binfmt);