From patchwork Fri Nov 27 13:20:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11936321 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=-11.7 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_GIT autolearn=ham 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 C7504C2D0E4 for ; Fri, 27 Nov 2020 13:22:04 +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 4260A22242 for ; Fri, 27 Nov 2020 13:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V9KGZQ78"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="taFM8hUg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="taFM8hUg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4260A22242 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:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TLdz6s9rguoKiMvaWrIY9zp5GQ4abSnBnBIzzzGXVq8=; b=V9KGZQ78X0n6ZRfY2Laq9Pl6E xD0B4kdHH238ZowcUOWtxg9VvZ9CZKJFAC2KPA7C1ZnrD9fLy/gOsFE4PF+VSxY/c3VjCi6UXhGfu jXTelbjDrBP55sFQOuW2edV2KWGm5V8hk/23cUELKQciv9wsFJS4n6ie0nYkQMYOwdFksXoNFrLtm B/GnNAGaiUfvqKSuVp5YOUTjfO5XU5zLG/RzNnvNbPYU82VYOxUbSTV8NQDyRWWV8GudL/F845y87 l6sC1lNAvH2cFidXUh0P0ImQ0XnelWTW2Jk0MoEi5eC3GkvQbCpHOqa9ucNG9rS+P9qmhqp8NJNI3 BMzWDvgyg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kidft-0001Lb-HH; Fri, 27 Nov 2020 13:20:33 +0000 Received: from mail-eopbgr70051.outbound.protection.outlook.com ([40.107.7.51] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kidfq-0001KH-KU for linux-arm-kernel@lists.infradead.org; Fri, 27 Nov 2020 13:20:31 +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=slIbyxS48hCYiEWuhWEE/Oa6nVJ/gAblbWHjFFkv6s8=; b=taFM8hUgOnIBKEaVp+Zor4s+41Ip+tHCUhiyztCmtIpD5YeVOJjq9A/pwCFBx0QQXUqMm9ia5ucqRPGYJJmGiEAhY7wxNUfx5mBWX01Uw46fd4KjdsU/OyX5YfYnbOfgdAQJAtQCHU7HeMY3DKk1sZkgabT53BGpQpYouBuYNI4= Received: from AM0PR04CA0032.eurprd04.prod.outlook.com (2603:10a6:208:122::45) by DBBPR08MB4757.eurprd08.prod.outlook.com (2603:10a6:10:f0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.21; Fri, 27 Nov 2020 13:20:25 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:122:cafe::6a) by AM0PR04CA0032.outlook.office365.com (2603:10a6:208:122::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.20 via Frontend Transport; Fri, 27 Nov 2020 13:20:25 +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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.26 via Frontend Transport; Fri, 27 Nov 2020 13:20:25 +0000 Received: ("Tessian outbound 13ed5f5344c0:v71"); Fri, 27 Nov 2020 13:20:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bfa20ae54c0ca7b5 X-CR-MTA-TID: 64aa7808 Received: from f4644680f99d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F327C572-4EB9-4F9D-8108-BC04F72577C4.1; Fri, 27 Nov 2020 13:20:17 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f4644680f99d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Nov 2020 13:20:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uk5XPL8mkiafvct1eaKa4RBqBatDaQwqTzHoEy14pGTxqT7al/UhhKS6DHdkUPQhVebf42At1tIlRFh2Ug3mi5bXQEbq+xa+rn2lVVk5U8AtpbFWwn9zPMoYt2hiaHsship0Eb4OThqYQRZDHrOlWsioGNXXmrY5vJpI9CkAAlL1xiZti42O0reT91jngtyNWujUGrRMrUAGQhpNQ9pgKG+0JrlgWOIb+Dd0KJB+eFbD2Z/sxTPSoyfUmwlqAzf+r3YExhAWB5d8hmgXHudbjz7zIA0M3gJ3KrMkOviSfAwFkexDOBijlhXFizEtjBD/WTLJYHAhMQZnWLZZrA8mWg== 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=slIbyxS48hCYiEWuhWEE/Oa6nVJ/gAblbWHjFFkv6s8=; b=jmLMu9SpaLUbY2sWMul9koJYiQdpwb719i2LbKrOWWk0UR6RgrfLj4diYVpolmSbPiWqkIOwBQSxAvu29+VDdC2Fl/tAOqV3CYYLLR+bQLxy6a4AivgJNIj3ElIs0YrWGncuJwDW+j+WGdbpjKzq16Jy6lnkUaUZL2zcHvX8ZYL3Fogdof8SDu10LTXD7RhSOdxviRcIMZo3gEuoKrK82ztauuzOONsAJXL6gQs9GmqJLBkBDaxCD7Rmr1eucOS3S09UF8OGUdSlt8kaYvrD4QyxZA6vlZTwpuMBh9cICnZmdN9e6wZ2oEMjc8JWWCAqjIYKkTZKtZyQGjIzNskgow== 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=slIbyxS48hCYiEWuhWEE/Oa6nVJ/gAblbWHjFFkv6s8=; b=taFM8hUgOnIBKEaVp+Zor4s+41Ip+tHCUhiyztCmtIpD5YeVOJjq9A/pwCFBx0QQXUqMm9ia5ucqRPGYJJmGiEAhY7wxNUfx5mBWX01Uw46fd4KjdsU/OyX5YfYnbOfgdAQJAtQCHU7HeMY3DKk1sZkgabT53BGpQpYouBuYNI4= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) by PA4PR08MB5982.eurprd08.prod.outlook.com (2603:10a6:102:eb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.23; Fri, 27 Nov 2020 13:20:16 +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.3611.025; Fri, 27 Nov 2020 13:20:16 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v2 2/6] elf: lose is closely tied to _dl_map_object_from_fd Date: Fri, 27 Nov 2020 13:20:10 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0137.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::29) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.54) by LO2P265CA0137.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.20 via Frontend Transport; Fri, 27 Nov 2020 13:20:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8160f1d2-949e-44ef-a814-08d892d733c1 X-MS-TrafficTypeDiagnostic: PA4PR08MB5982:|DBBPR08MB4757: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 169udulgEyFULlkhHnw9txM9ywDvuQI1qogOg8kzYBLTuVIZMNwvjq/5jeZsWfHFgUmZVL+pujYlNsGm4Wwf7qZXYDBAv6bOjgLUYIru1o11Ac9qaGMGDmScQSkTfChPoN4d+sd/xZ5Qe1V9XYPlMdVNsyP25yICtJDuJbzUFRqjc+sUWP6KixQqs7cJVlJwBPUokMPZDtG2oE7OjL0iOQ71Hau7F0VMdZ6+98AqbgQtPpNM9Odf/paRcKEeeCJjwhpd5IA/q3VURKAvtF6P6qHDHVEXTUPkzMI7pDPH/rr1nk0q5TrXoitgHglPXiDuaqSnQBcbpvXAXmPwatEmmGLmsz5DOYLCl9FVbYw+rvmmpk2wkLaq0ZM8zitIFkmh 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)(346002)(396003)(366004)(39860400002)(136003)(376002)(2906002)(6666004)(186003)(5660300002)(83380400001)(52116002)(69590400008)(956004)(2616005)(16526019)(6506007)(26005)(8936002)(6512007)(36756003)(44832011)(86362001)(4326008)(6916009)(6486002)(66946007)(316002)(8676002)(66556008)(66476007)(54906003)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0fhxp9laLub2DCy5zx1lYWE1z6n0cGagE1A9atqcBUIigILKRbT+qcZ5yZbK3u0kVwhpI6ywDbPLue19tomPJowHjJPfTpbQ6H4yIjQf0nyBqRudJr56DWocKSZ7Aw0xIPDEEzZlcUUU2x/FANgJevdCc3IWCQnkHPPAw1cEebcVLV5d7sutQlJLO++nfvUd2aaaobNVkzERaDn/ckxzEIzRD+pPkg1JcQWZ9xwhsa2rNyNw6iLmWCiQzp+KRB6Zt0QnnT22aPA3wYZn/GHKtbGhZNBsWL5UJgudUPGGHyev47oej8moeU2k0FiZQPcqBU+YBxD05U3OxSNPvXAQqt4ZzTZwoHOeKSdZWIS3+BMvMT54Y21vHibjhd1DXU9A50or8spsMPF/FLoeWe7pEkF9Vl/a7yFdqkAWa/u2dcX6sXjRWyw1IejASGgBDVDj7e0QR2LpkyGEF2homKf61G7gXu0AWSswk81p/wlfKb7Ck04ZOonupU4f5/CtukVER2YFXkuttUiNdNCAOEcGrIrsojFsrSPU67/04EhlYo4dXbO4cMUpheGZQeiGysRMsNahwHtUABYCP6DUBlVWAH1Y50AtWUexZBUGfgfvs4jon8ubmdH716K8jX/PEDPDN8+ekhYroxM+VJYXpYfZ2zKAaoC0nHR4Uypt8oeFrC+boi/bzPUgNguAzvxh4wonJX5GeThM7R9AiJRKjpUtzKLfTpvvp9BMXN0CwSr/dAcw3DzYVRy276/UkJZ6IzfO0V1nwpcPg7u7DeN3+fn8lqYsUCEfCxJRUfx6+xcD9BWbrPnyb/3nYbcpm9XlHUrcsQxEsgXCybRA2z1iozjQZYtBPXBgWhTRlexoAgjMFg9rORWAfIAuNuWw4i7+EgIhw4ZeUJo9MAjnxlE3u0r6TpUDhNyUFeaDUjLDyp4NGW6LAef8NjYyWMwRQw1hAu5sDjuAwsZTIientqHx+YegBgJ9q9P1i1pWrgT1maLhP/9Ed3BzrPjTIYZoHNM+i8ZP X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5982 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1cccce31-6dca-4b23-c130-08d892d72e0b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: opkCsHob8LyMJNlkW4dtdiI3sH/egwR14pwaLvJuzNd4+/mX8Biyf2vSMEDgk/rWPUC8P9PmmgQCKXlcGWqjryP53bok3gmxmYlBErjW3IwBAQ+vG570C9O9SClWPjQLUoXkoT74D+qzm1TJ41loFUDtRixon3GfwY4SzJAqNBSQFpuscn7yYtl55w1+buR4R++StcaNOueeXIRuX8H9CA4QkEdWpMbBEEKnUCPloa3p/efVImDiVAd1KTuN9TiHKAm8miDCgUvveD6vT3eOvr1YGbuzU8UMFT+5Uk/MN0ehd24YwNE3wg+vBwgTUvyIwQVFdxU1gZDiXVe/H4eg7aV6ZCbw3P/fgtiJi2JkFWM+m6TojVqsB35Jp/p4ah3rmewyY6YRgRN16gYZXjSG5ezmIBblVADknQFqguiKCHqjJUmn7mPYmKRKq340cHId 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)(376002)(39860400002)(346002)(396003)(136003)(46966005)(83380400001)(54906003)(356005)(34206002)(36906005)(8936002)(478600001)(316002)(6666004)(2906002)(44832011)(8676002)(81166007)(82740400003)(47076004)(4326008)(186003)(6486002)(26005)(70206006)(70586007)(16526019)(5660300002)(82310400003)(336012)(6512007)(69590400008)(956004)(2616005)(36756003)(6506007)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Nov 2020 13:20:25.6258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8160f1d2-949e-44ef-a814-08d892d733c1 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4757 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201127_082030_713380_1EE485BB X-CRM114-Status: GOOD ( 15.92 ) 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 , 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simple refactoring to keep failure handling next to _dl_map_object_from_fd. --- elf/dl-load.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index f3201e7c14..21e55deb19 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -835,30 +835,6 @@ _dl_init_paths (const char *llp, const char *source) } -static void -__attribute__ ((noreturn, noinline)) -lose (int code, int fd, const char *name, char *realname, struct link_map *l, - const char *msg, struct r_debug *r, Lmid_t nsid) -{ - /* The file might already be closed. */ - if (fd != -1) - (void) __close_nocancel (fd); - if (l != NULL && l->l_origin != (char *) -1l) - free ((char *) l->l_origin); - free (l); - free (realname); - - if (r != NULL) - { - r->r_state = RT_CONSISTENT; - _dl_debug_state (); - LIBC_PROBE (map_failed, 2, nsid, r); - } - - _dl_signal_error (code, name, NULL, msg); -} - - /* Process PT_GNU_PROPERTY program header PH in module L after PT_LOAD segments are mapped. Only one NT_GNU_PROPERTY_TYPE_0 note is handled which contains processor specific properties. */ @@ -930,6 +906,30 @@ _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph) } +static void +__attribute__ ((noreturn, noinline)) +lose (int code, int fd, const char *name, char *realname, struct link_map *l, + const char *msg, struct r_debug *r, Lmid_t nsid) +{ + /* The file might already be closed. */ + if (fd != -1) + (void) __close_nocancel (fd); + if (l != NULL && l->l_origin != (char *) -1l) + free ((char *) l->l_origin); + free (l); + free (realname); + + if (r != NULL) + { + r->r_state = RT_CONSISTENT; + _dl_debug_state (); + LIBC_PROBE (map_failed, 2, nsid, r); + } + + _dl_signal_error (code, name, NULL, msg); +} + + /* Map in the shared object NAME, actually located in REALNAME, and already opened on FD. */