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=-10.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 5AA66C4361B for ; Fri, 11 Dec 2020 09:34:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC52423F2B for ; Fri, 11 Dec 2020 09:34:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC52423F2B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=k0e3dbZvnN6w5n2+9EBbm6k0wwPSPK9poECoSjjIkEM=; b=qIIWH1itscbDX+MpHJqm2SBt1 PbgHbSnOOPj5Cn3VZlX9ta3VQ2EbGAv2J2X1XaKgIPYCQFe6V+ui78nk5cZxkmK1LBpYfaePZb7Bt 2waIHnc54mw/F+SSB9frsCPY7D6/mMcHLiAydDXxRgGD6+So8E4XYfA2yHneCUzQ1kF01CB6OGOxT q+0tIDtzcKDJdS3LeR4gJhar0MjsgPNiJknkJoAh4HaOzb9ITALbt7UilHABlkNg42un6uJFXrSSy DgekGabMJqJdWIyNn9SlJ4IzSAhCb5B7Rd5vRbONgRTPPB7OMC6SYWZB6JNqZkgZJo2Z8mokkApAC x8laqQXog==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knenq-00084H-UY; Fri, 11 Dec 2020 09:33:30 +0000 Received: from mail-am6eur05on2052.outbound.protection.outlook.com ([40.107.22.52] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kneno-00083n-5w for linux-arm-kernel@lists.infradead.org; Fri, 11 Dec 2020 09:33:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B0NGlFtaX9S6HQB1ttjEbafzd+6rL5R7qxOmL92n3Uc=; b=fbhUDn2YCRFwiLJCSfwD74zcmx3LsbOah2lM0E6erSk74mNLEntA5FePyiFQGLoRwk9fIHJR5L8Qlcw44gn0HJNPOLxCh5vW7FXnlClRTzurQmJuYUAkKnt/ixvkIJjRstY9QhReM7E/9GPuoVcQ6TP5enM+QBLcpN6jICYAfLI= Received: from DB9PR02CA0030.eurprd02.prod.outlook.com (2603:10a6:10:1d9::35) by AM6PR08MB3175.eurprd08.prod.outlook.com (2603:10a6:209:3f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.20; Fri, 11 Dec 2020 09:33:22 +0000 Received: from DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::a5) by DB9PR02CA0030.outlook.office365.com (2603:10a6:10:1d9::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 09:33:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.infradead.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.infradead.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT024.mail.protection.outlook.com (10.152.20.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 09:33:22 +0000 Received: ("Tessian outbound 6ec21dac9dd3:v71"); Fri, 11 Dec 2020 09:33:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4666d5f4ef21b8db X-CR-MTA-TID: 64aa7808 Received: from 6e6afcd7e5ce.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B7A61146-A6F6-462D-A27C-16BF00E4AE1D.1; Fri, 11 Dec 2020 09:33:07 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6e6afcd7e5ce.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 11 Dec 2020 09:33:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLs95G+KjJxrAMh5WpzNdDHLjBsUHy2+SqF+clw8PbOZQr+u/YXBtkDfkBr8fa021xmNscSwJ1yEo01zJ9Hebupexmw0PDjENXJ81u4O7yNx/jU6oT3zKwN+rK7WDF8ipHRvbZdmRv8rPJCWFsIUefNThfuBqRoQD11d4H502GLXeoEetKGVp4JEOsOAwm8Kfm56sQu8RCBEkTIsVQEytwpK634EdiYRFIe4mNaxTZpGcfXIjbA6GnBwhp7icle/XPs4mNxIZL1yD1cvxACTXI9nKx7lQ6fzG1J/Ps5QeD5/53GHwRCR3uouwQzUcsHTyQgnaBlSS5F7a8Fb8NJ9Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B0NGlFtaX9S6HQB1ttjEbafzd+6rL5R7qxOmL92n3Uc=; b=A4T/s0trw9rJagmRxHeOh56VvT4miv1wwTezQH5OcZYS+hKQsqPvMU/zXyV54wqKNhuHbfCvMkjf6bn5pKTE0LzdSwLyVNdqkWsP60uGakAiu+6u/TGM/DXDI19ALEuiWsNTjGr1USc1Fe2dCH7Pz22jap1IS1XPxKyE0vVz21tlkCstNVvDmxqFv4mzsjdMN+2GoAqmDQVbYUG49juEShZFM3r9NGmEXwGDaesmSXqIkZrICEYxljc27ErhB1BcC8hLN2Zkk2+s15lZ7im4UIUt3hWcHW2Xfl3oaClLLJgZZUb91BjscR7vxaL2Q1vaf+SxjEhUo+Qdk7/jTXwtMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B0NGlFtaX9S6HQB1ttjEbafzd+6rL5R7qxOmL92n3Uc=; b=fbhUDn2YCRFwiLJCSfwD74zcmx3LsbOah2lM0E6erSk74mNLEntA5FePyiFQGLoRwk9fIHJR5L8Qlcw44gn0HJNPOLxCh5vW7FXnlClRTzurQmJuYUAkKnt/ixvkIJjRstY9QhReM7E/9GPuoVcQ6TP5enM+QBLcpN6jICYAfLI= Authentication-Results-Original: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; Received: from PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) by PR3PR08MB5851.eurprd08.prod.outlook.com (2603:10a6:102:85::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Fri, 11 Dec 2020 09:33:06 +0000 Received: from PR3PR08MB5564.eurprd08.prod.outlook.com ([fe80::ac13:db5:ef4:2dd2]) by PR3PR08MB5564.eurprd08.prod.outlook.com ([fe80::ac13:db5:ef4:2dd2%4]) with mapi id 15.20.3654.013; Fri, 11 Dec 2020 09:33:06 +0000 Date: Fri, 11 Dec 2020 09:32:56 +0000 From: Szabolcs Nagy To: Adhemerval Zanella Subject: Re: [PATCH v2 3/6] elf: Fix failure handling in _dl_map_object_from_fd Message-ID: <20201211093255.GD24625@arm.com> References: <8ebf571196dd499c61983dbf53c94c68ebd458cc.1606319495.git.szabolcs.nagy@arm.com> <1525639f-560f-2677-b1cb-f904b3552c71@linaro.org> Content-Disposition: inline In-Reply-To: <1525639f-560f-2677-b1cb-f904b3552c71@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: DM6PR11CA0013.namprd11.prod.outlook.com (2603:10b6:5:190::26) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.54) by DM6PR11CA0013.namprd11.prod.outlook.com (2603:10b6:5:190::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 09:33:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b2a47ee5-1c39-437e-380b-08d89db7cda0 X-MS-TrafficTypeDiagnostic: PR3PR08MB5851:|AM6PR08MB3175: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: SJELLdooa0Sa6urSNkHQ6cEYJuYQ9FmWUm8q8lq/BIRFWmqjP5BgNwRMbRMEbF57RNTH7tdc8Qg7kDKmvLyv782SdEhyEnVoCWgAuW5BrCxTfvIDkWmo+uFzKmx6uBoxNxLcOAAfqmU85qfyePKPq5wjw0T1ZjHalYMIlIuhMidt27yqQkpTmxKrFSql4WsWNk4DqCrNo1H/KP2SILczDPPnTmkhbqDEIrmCBDSk3U9FpkaAMmbRA39Bkedz3IDiHqfG86hFHsS6iZ3fM+DVUm7GMU7Yi3KB3AHlxixQ/BSH1KGJJyu3WoRlR042NQrG X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PR3PR08MB5564.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(396003)(376002)(346002)(39850400004)(366004)(2906002)(186003)(4326008)(36756003)(33656002)(7696005)(956004)(8676002)(26005)(52116002)(66946007)(53546011)(66476007)(86362001)(8886007)(66556008)(8936002)(55016002)(2616005)(6916009)(16526019)(478600001)(6666004)(316002)(1076003)(44832011)(5660300002)(83380400001)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?RmJCU1FqUUthVlhGWjBJZ29rRzcwNlluRm5oemtXVjRpYko1NWRESTFnenV6?= =?utf-8?B?V0lnNi94eENrdzZjN2xza0l1RVNwZ3I4NmYySkpYNnlCWGltbWNVYnBGeWtC?= =?utf-8?B?Mld0ZlJpNjBESVJVR3RScGFLaTVWVkNQb0lTWFhNR0NDMm9McjdFZ0tzaXg0?= =?utf-8?B?dmpEOHp4WnNQV2o2L2RmMkRUMnM5RFp1ZGlUUHlmOU1UYkdTSUwxNXR4a1Y1?= =?utf-8?B?TS9LKzVrbkl0WWEzMm9YUTVPNHZYV0pZa1AxbVdsOFphL1NKZnhDc0FtUWNl?= =?utf-8?B?U21nMUd5YzFRTGJVNHJlb3lFMkZ4SXN0RWl3VlpkUzdZdWQ0UElvaWNTRitH?= =?utf-8?B?YnR0TlowQ1U0UXhZOU9pM2JWRy9ubDhNYjk5elRYQ3VOeGUzWTBnODltWDZO?= =?utf-8?B?SG5peG5iSWhZTDlpK1AwWjJEUEkyYUFJQnZWYjd1UFJhaTJXbWNoc2Z2RFZn?= =?utf-8?B?QTNpM2syTHhyQ0ZyU0NFQU4xZFF2VkQrdlJjZ1FzUXlBR1NpS0txMklZL1pG?= =?utf-8?B?eTIwQWZWbVJVY1VwdTJTSDZpckxLNW5LY25SeG9LRWtyMjVES2krdnZZTmhI?= =?utf-8?B?b1BiZmJxejU0NVNzdnpNTlFNdk0xL2FxVk9jNEExdEQ1dkZ4NWhtOC8yRWtM?= =?utf-8?B?V1FNcGhMMnR1RGdKZDhUUnlxM2NPT2taRkMzZGp5ajQ0bDdUL3JiWDBVbVla?= =?utf-8?B?MmtsWk9MNTFmNlJ6aDJVUHJiZ2VpZ2tta3lWQ3crVFlvQVNvTnR6MEEzNGpF?= =?utf-8?B?N21oWUpibDdPbS90RzNFZnpRWU5oM2tGOXMza1oxL0dTWlIycHdEUEIxaUdp?= =?utf-8?B?MHhGVHJzWlQrbXhnZGZLTkFDWnBhekFpQ0xMSld2T28wc2xSbUFvS1pKUzRE?= =?utf-8?B?N3VKbEh5a250UTRZOGJWVnpzOEZCZ1F3dXdqVHB4dzJJeWViUlI0emY2ZXFT?= =?utf-8?B?RU5ybDcvOHBJOEFObzB3cXdobG9rMDRmZ0g0Ni9taGtyT3I5L3RmM3Y2U0RZ?= =?utf-8?B?eGdjdXc3VEZlV1Z3S3VQdnVjejNhMnhXcGpERFJDSzZFZC9QYjBtaW1JYitT?= =?utf-8?B?ZnFMbXduUWdrazBGd25qcG8zb0dwaXBtQ2ZGbmRHNXRkcFh1MmVFREhLMDhJ?= =?utf-8?B?Zjh5d0NFU2l2ZVNCMTd5aWowNGdYbW94bUVxQmFFaXlqYWVkcVBvaldQdk92?= =?utf-8?B?d2tGZGx1QjA0Q2xBYmVKZjFtT2ZiNEFZdzhWeGRRR01WVjJnL2FxWStxVk5U?= =?utf-8?B?VnVmS0xNN0hONVV5VlBEek5ic3VwMG0yRitPU0ZKMFNxTU81cmtsTlpSTVo0?= =?utf-8?Q?AeI91gr6Brg18YwqAH+IPZi7krKzlgmL/a?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5851 Original-Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8f637007-6c6a-4eb5-6bc6-08d89db7c3b4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UvgStOMzOkInR+btF+GOoQt3ZE55u61D8XrQk+DBrjOa1Vh5OqnYntsFIiZ0H+Wp82SeE1UAj1bRAX5b83zaXP2YUjMIgQDdNzZHu9htbxJUjcv4BADKKn9ZhOrYKDwu8ThHwaUuW4xCpaNhNpJanUAqt4AT1GSgAUCx8rlWIkyGD5yolHPCPv3XVomNBMEu3XO9RGLAMJ/PyPlMu84pYnYeKuPJweS4hNFfzhLd5gZSSAXtpgAw2Ly1cZHc2L+aWkhtUcd27rgwe9CJyjRdAQy/gyyX/gSoX/BNhvDD0PxHAPNOt59ZA/2n7c4WOHddmAtSCNsSpNajxm16sEbMFVvS4GPoFxw/T+rFXfXGUGFaEf7xQTrWPjEQjNakn+Uqc6oOuCw6Utsj+lk0NaLP3w== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(346002)(39850400004)(136003)(396003)(376002)(46966005)(1076003)(70586007)(5660300002)(478600001)(86362001)(7696005)(55016002)(54906003)(2906002)(53546011)(336012)(82740400003)(26005)(70206006)(33656002)(82310400003)(6862004)(2616005)(16526019)(8936002)(44832011)(956004)(83380400001)(47076004)(6666004)(36756003)(186003)(8676002)(8886007)(316002)(356005)(81166007)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 09:33:22.7270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2a47ee5-1c39-437e-380b-08d89db7cda0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3175 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201211_043328_472742_BC037381 X-CRM114-Status: GOOD ( 24.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , libc-alpha@sourceware.org, kernel-hardening@lists.openwall.com, Catalin Marinas , linux-kernel@vger.kernel.org, Jeremy Linton , Mark Brown , Topi Miettinen , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The 12/10/2020 15:25, Adhemerval Zanella wrote: > On 27/11/2020 10:20, Szabolcs Nagy via Libc-alpha wrote: > > There are many failure paths that call lose to do local cleanups > > in _dl_map_object_from_fd, but it did not clean everything. > > > > Handle l_phdr, l_libname and mapped segments in the common failure > > handling code. > > > > There are various bits that may not be cleaned properly on failure > > (e.g. executable stack, tlsid, incomplete dl_map_segments). > > --- > > elf/dl-load.c | 24 +++++++++++++++--------- > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > diff --git a/elf/dl-load.c b/elf/dl-load.c > > index 21e55deb19..9c71b7562c 100644 > > --- a/elf/dl-load.c > > +++ b/elf/dl-load.c > > @@ -914,8 +914,15 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l, > > /* The file might already be closed. */ > > if (fd != -1) > > (void) __close_nocancel (fd); > > + if (l != NULL && l->l_map_start != 0) > > + _dl_unmap_segments (l); > > if (l != NULL && l->l_origin != (char *) -1l) > > free ((char *) l->l_origin); > > + if (l != NULL && !l->l_libname->dont_free) > > + free (l->l_libname); > > + if (l != NULL && l->l_phdr_allocated) > > + free ((void *) l->l_phdr); > > + > > free (l); > > free (realname); > > > > @@ -1256,7 +1263,11 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, > > errstring = _dl_map_segments (l, fd, header, type, loadcmds, nloadcmds, > > maplength, has_holes, loader); > > if (__glibc_unlikely (errstring != NULL)) > > - goto call_lose; > > + { > > + /* Mappings can be in an inconsistent state: avoid unmap. */ > > + l->l_map_start = l->l_map_end = 0; > > + goto call_lose; > > + } > > > > /* Process program headers again after load segments are mapped in > > case processing requires accessing those segments. Scan program > > In this case I am failing to see who would be responsible to unmap > l_map_start int the type == ET_DYN where first mmap succeeds but > with a later mmap failure in any load command. failures are either cleaned up locally in this function via lose or after a clean return via dlclose. failures that are not cleaned up will leak resources. _dl_map_segments failure is not cleaned up (the mappings are in an unknown state). however after a successful _dl_map_segments later failures can clean the mappings and that's what i fixed here. i did not try to fix transitive design bugs (such as leaks in _dl_map_segments) that would require interface change or local cleanups in those other functions. > > @@ -1294,14 +1305,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, > > || (__glibc_unlikely (l->l_flags_1 & DF_1_PIE) > > && __glibc_unlikely ((mode & __RTLD_OPENEXEC) == 0))) > > { > > - /* We are not supposed to load this object. Free all resources. */ > > - _dl_unmap_segments (l); > > - > > - if (!l->l_libname->dont_free) > > - free (l->l_libname); > > - > > - if (l->l_phdr_allocated) > > - free ((void *) l->l_phdr); > > > > if (l->l_flags_1 & DF_1_PIE) > > errstring > > @@ -1392,6 +1395,9 @@ cannot enable executable stack as shared object requires"); > > /* Signal that we closed the file. */ > > fd = -1; > > > > + /* Failures before this point are handled locally via lose. > > + No more failures are allowed in this function until return. */ > > + > > /* If this is ET_EXEC, we should have loaded it as lt_executable. */ > > assert (type != ET_EXEC || l->l_type == lt_executable); > > > > > > Ok. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel