From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30072.outbound.protection.outlook.com [40.107.3.72]) by sourceware.org (Postfix) with ESMTPS id 19C173850418 for ; Thu, 21 Jan 2021 10:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 19C173850418 Received: from AM6P194CA0108.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::49) by AM6PR08MB4471.eurprd08.prod.outlook.com (2603:10a6:20b:b9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.13; Thu, 21 Jan 2021 10:45:12 +0000 Received: from VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::76) by AM6P194CA0108.outlook.office365.com (2603:10a6:209:8f::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Thu, 21 Jan 2021 10:45:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.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 VE1EUR03FT024.mail.protection.outlook.com (10.152.18.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Thu, 21 Jan 2021 10:45:11 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Thu, 21 Jan 2021 10:45:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 348ea39e1064af4a X-CR-MTA-TID: 64aa7808 Received: from f0169be92345.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D32238C5-0E3B-4623-AD95-8C05C05CEA2C.1; Thu, 21 Jan 2021 10:45:05 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f0169be92345.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 Jan 2021 10:45:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5WeVP7nwKVO3JbgbKwOFlZEUO5Iu2l/9F4mUGsDyqlSCdBeGfZjUM6PdIjtg1nvP44dCVTsZ8b2PFWTqJ4YduZtr7w16849OyozpwGpsMAz5atZqr5xp4IHYmMhwFapbh2mIwGGxPChl4SUO1z0tAbvW+Gw4VPIDASmtU54rwixGjeh5/5zq6NyXj3F4RhY0D+nP6EdGa4oh0mGg3ylcGhtizdzYWupa4DMpyqUehtlSIOfod39H2F+quW4J12PEPvmw76OsQMMrstAkA7+JbAUEdxGvDCZT5INqUxU3jFspviKRnCkyQh/KmWBnNMGyt7aqsPyll79s1zbDpTthg== 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=MkB9qYiHcqMAjHt+EmyJ4HiV9FeIzPmKEm68uStAGXE=; b=h09E20eoFD1yl7mf6w00JF4C6RkAssTDrkYDKir4bcTDqTbFCa5123qa7f0AlufvXLtftpwsC/lpMUD8OEXtqSIrKI+tY85CU7SejSTrz59OVfWUuJUPCS0F8BhSP7XXRgLxn4Q43z2pbavOhXVLhkcd+MmnsVYOYGBS0RYXadFJbTDdYAgaIjLs6RBxXSbxFrIg0sYXRMOFP2weyHYj1TixhiD7XMwZiMs5lbnvLIc0o3YCJKo9+tHXQFHUlZf9ghfmycTDaVKKk0z6Gkjyj1Wup/McRfxpP2do2QpzwtLRxZO2+oeqHtXvq9qQtUd1cug/AaL3MMtfkUbEwh1mQw== 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 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 PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Thu, 21 Jan 2021 10:45:04 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%7]) with mapi id 15.20.3763.014; Thu, 21 Jan 2021 10:45:04 +0000 From: Szabolcs Nagy To: libc-stable@sourceware.org Subject: [2.32 COMMITTED 3/5] elf: Move note processing after l_phdr is updated Date: Thu, 21 Jan 2021 10:44:58 +0000 Message-Id: <20210121104458.21303-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P265CA0339.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::15) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by LO2P265CA0339.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Thu, 21 Jan 2021 10:45:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 004a09ee-e91c-4e13-708e-08d8bdf9a11c X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|AM6PR08MB4471: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2089;OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: OaGn/o6WijznneVTQxiwO7lDxOGjYbwRCNNKT52F/GopD8qLCpD2CnM2TID8++iCbdIRbFjJWMhXoHymgZ19ZHwib7qc8i938LnqngeFAtIE/j2TpN+LGbCP0w/8Ld+oLCrdLf0Nvh5UWJ3a6XUqC7zf1fFYiSbUrKKRAd7HwiEi9wNDnwteZN3eoD/puV+Nzoz0bNovrNMxgMKdvex+X/qGw5depv61VEXXi6G50c6gcZxIOx9KsP7gTONXfdGguEjYS6LIfpxwGRugkJEz/ZW5E6E65U6QWLQa52zBTwo1W6ydxYQxFKZIONrozCqlaYla8lQSb7VnMc5WXS1yUGVzONsXk7P8R0Scu3NYzMKwBzRiMuCCMxTGm1Pm49tiQw0okMGAIC0LrFPyPXgD1OqgsD9zTLUB1P7yJtGJDXa2N3aiaaSFXQsqalcjacBSpaDe5GiXTgqyi/6gL5KL8WnzcX4uLV+hF1rLnHWWZZEG7lX9+QkrrTofSW/SncV12ijs4O/Vn3xR7HRpKPxoLuwyKSU1D6C2tksUMBCHwXMp/x855D+9ErddXoZcgxdkpyj5iUL3ChZKCYvp83BKrA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(39860400002)(366004)(376002)(346002)(136003)(69590400011)(1076003)(5660300002)(6506007)(44832011)(478600001)(6512007)(66946007)(36756003)(26005)(6916009)(66476007)(86362001)(956004)(186003)(52116002)(316002)(16526019)(2616005)(6666004)(8936002)(2906002)(8676002)(83380400001)(66556008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+8be+KzegSeEQMDxihuDk3rQpdsqMv8+WUk8O+UlTFjEvcbSfodnJd6vl76f?= =?us-ascii?Q?X4eZ8OABZNkIBvhmHrHdsbYXH5JUe0gp21lKTNner73sazUlGADuctjUBy1V?= =?us-ascii?Q?i+yoOb9kli49svVbP0koLsW2cDO3EL/ow4h9onCYFdWlMRp9MrXwYQ1N1joI?= =?us-ascii?Q?HQzo2oqd7n0hdgBvkNu+0t0r06PGDDmRLl6vZgSOR3sCCNMtZQZnhtVQQgWq?= =?us-ascii?Q?WdkxpwFudOfR9VClsDogzxYQOEn5co4QthSA9LtOONlCImW78L01tAUPN8XP?= =?us-ascii?Q?GcmhZdRCPThxanjJDKM0mWSES/r0bCFB8N8BpciLo9ltBQtj3dbH3zHO5VYE?= =?us-ascii?Q?Q8if9tNfgdKOmja51jaNnNFBihfl7CLQioIv45Mfx60dCtZd5abOX2fQcvmJ?= =?us-ascii?Q?0XWPE9W/tcTBikNvAvtzkPpX4QEyX/tYPt3uNc4wLjjX1Fzw9N73NStcNxdp?= =?us-ascii?Q?WXqNxO13tSEw03HPquAkpI1/ltVGNOuor8kaq35i2KOgJpnAQXvzaEAlxlzR?= =?us-ascii?Q?ixcNk11mSWsjm7W8VznqpGkvVKrzGVxgzYjvFKZbPnpvICt1FeO/5kfnQA5K?= =?us-ascii?Q?rDRMFA3vpa2T825qsVSRwrTL1CKyob4RT87sAb3cyhjzxlKpz76P9kjh4b+u?= =?us-ascii?Q?7RecEyCDgRnb+sFUpV3kx9dK5KyfKHDohBg752KyjLF6M1Ls9PyWNstghkml?= =?us-ascii?Q?26Uhx6ePc7bRZgxy6eiz+jjKSg6gVmzii4qpMlAVP4QXEow1z3myFAXQF3Qw?= =?us-ascii?Q?oSDV28fT25t8+2VbhfyZQZ39AOicfN5zf/lpqftq4jnchD3VKZQXT3Vt16u/?= =?us-ascii?Q?EDL9b7QRv8+Hz/a+emb9EKaa+IJtQvt+8OmQVrfbLblVrXtWtj+Rwdj8WhDW?= =?us-ascii?Q?+NC6siJvSsD+yvVCrdRTVhDMz3EH65pOa+/4Z2DDBeItKDiAWnG7c1IxtT7T?= =?us-ascii?Q?6PenkvBTMWucd9iaMsNRJoBvEUFwKtZTLcYBZniFx4nsPgO1TiNFoBhf8KXI?= =?us-ascii?Q?hQZA?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 62e0b5e1-0ad1-4d07-b7a6-08d8bdf99c72 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1X06X6MQ/ClAN4Nt8ttteSiBVsY6zTNSgsEQI9ZBcv5HBSIgSUF4lTObPp0UeeMZ6Jlmmfx7vU4l8DuIp7TzF3RRS19swAAbZ1ckElSiok6iPN43sbbgFpCFQGLsOsxUW3KFd/IU6H8B1XV0ogXE/EgDTos/xfaLVna4RxM8+kud9IIsGEmmmaq+rqZqAYnF4hCbOcP9XUtV9dAnPmAjaOzvMMgw0m/t5tSkp4w7y2YW78SSTeQWhhB+cKljOOZRerxSp3iT0IGoUGmVBtAVQz+MrcUmvKNm910VRpMzSh1GrVN7ytifQMz0OkUw4cA8qe0SHWw2zuta06+mDqu0DLVvhovO0GVOUyEtNWVWXyeRRsOhBVcQ4fVwvfjCydj+Sm5PsFK+mrN4baQGL9cTYjrr1odoRUt9TDF+RdE6SOOw5fA/2gEkVNCyUlbFGdnDd0VMJ5mMFDUzBlyNDBPtZJoUIONbk19ZZHu7ASwFRveyzUzNIyDCMsNeiaZLf86eG7Wd/TBghgw1YZoJC9mAxlmevtKfEwUdLt0OH/svpiUWD5X1bO5CdwgwrOYCcBMeIr1mlDBHqDso4OTaC+GASNjBTejhl14R1i21QipOSb8tDdkcWAhSKLRPePU7z/Bc 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)(136003)(376002)(396003)(39860400002)(46966006)(356005)(6512007)(70586007)(478600001)(336012)(6666004)(83380400001)(6916009)(81166007)(70206006)(86362001)(8936002)(44832011)(82310400003)(5660300002)(2616005)(36756003)(956004)(2906002)(6506007)(6486002)(47076005)(69590400011)(82740400003)(8676002)(16526019)(186003)(316002)(26005)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2021 10:45:11.9097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 004a09ee-e91c-4e13-708e-08d8bdf9a11c 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: VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4471 X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2021 10:45:16 -0000 Program headers are processed in two pass: after the first pass load segments are mmapped so in the second pass target specific note processing logic can access the notes. The second pass is moved later so various link_map fields are set up that may be useful for note processing such as l_phdr. The second pass should be before the fd is closed so that is available. Reviewed-by: Adhemerval Zanella (cherry picked from commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2) elf: Fix dl-load.c Rebasing broke commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2 it was supposed to move code. (cherry picked from commit 751acde7ec335506b54e94ed6f2c998f6c0a22c6) --- elf/dl-load.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index e39980fb19..9ef1cc3203 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1251,21 +1251,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, maplength, has_holes, loader); if (__glibc_unlikely (errstring != NULL)) goto call_lose; - - /* Process program headers again after load segments are mapped in - case processing requires accessing those segments. Scan program - headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY - exits. */ - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph) - switch (ph[-1].p_type) - { - case PT_NOTE: - _dl_process_pt_note (l, &ph[-1]); - break; - case PT_GNU_PROPERTY: - _dl_process_pt_gnu_property (l, &ph[-1]); - break; - } } if (l->l_ld == 0) @@ -1377,6 +1362,21 @@ cannot enable executable stack as shared object requires"); if (l->l_tls_initimage != NULL) l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr; + /* Process program headers again after load segments are mapped in + case processing requires accessing those segments. Scan program + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY + exits. */ + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph) + switch (ph[-1].p_type) + { + case PT_NOTE: + _dl_process_pt_note (l, &ph[-1]); + break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (l, &ph[-1]); + break; + } + /* We are done mapping in the file. We no longer need the descriptor. */ if (__glibc_unlikely (__close_nocancel (fd) != 0)) { -- 2.17.1