From patchwork Mon Feb 15 11:56:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42030 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D7AF3950428; Mon, 15 Feb 2021 11:56:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D7AF3950428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390211; bh=8/dDhL1LQGgb0rkFzjutSFNml3hgMv2hymhQKmnJHuU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FhpID4inhMWVriHWjFMVa5UfRLnqk45YN09kBQdvwiw7K+QQ99yXtad/fcAz7T59C opKq6gr7lmaNSKka1G105gG/d7zjLY+9X3zVgtTFOnQkfdzE8NBqUFC/YAx62Q/3YV A/oQwSYteJjeSe7GKG05zZ9f5XiPs/hmJv/johi4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140041.outbound.protection.outlook.com [40.107.14.41]) by sourceware.org (Postfix) with ESMTPS id 7C9743950422 for ; Mon, 15 Feb 2021 11:56:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C9743950422 Received: from AM6P195CA0099.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::40) by AS8PR08MB6102.eurprd08.prod.outlook.com (2603:10a6:20b:23d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.29; Mon, 15 Feb 2021 11:56:46 +0000 Received: from AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::f6) by AM6P195CA0099.outlook.office365.com (2603:10a6:209:86::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:56:46 +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 AM5EUR03FT016.mail.protection.outlook.com (10.152.16.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:56:46 +0000 Received: ("Tessian outbound 2b57fdd78668:v71"); Mon, 15 Feb 2021 11:56:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c2a4cd72de4c038b X-CR-MTA-TID: 64aa7808 Received: from 35dba45f63d2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CB94D38D-D028-4D84-AE8B-CAC209079A87.1; Mon, 15 Feb 2021 11:56:40 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 35dba45f63d2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 11:56:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SE5TNaXu7XhuPN+IWUPdf0cCwsqqmin+mMMICV4Si0mDXE2IWfsXohnzLIsT18owKatm+WBN2XMRrCnd2xaJPCSWZqGljoUhZVq+4BkawsYrA4n9eUm2GVoCDJyoEvEtd9HwgvFyfVZRorQvA2/eG7eCgyJKNvgJX2mF8/9NrsAHjt6UAa2Wjn6nelZJbTSdml3jXziCqvRVuNDNYDqZlVV3tpJvJ+i5aI0E+k14diqTw5O8CBKVrpPzPUwrbbej0t3Puj/9v0P//Lhejh6n7CkLKvZ3Hh+qMyb3eK/7OZZXAUdZRQkPTKHlUuOTk8AOhy7cDWMOt37sKR5BiN52zQ== 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=8/dDhL1LQGgb0rkFzjutSFNml3hgMv2hymhQKmnJHuU=; b=KgXJNJXBIWQPPpSb0RdUonzFD9yJmaVGy9Xy1AYZLPQ5QGiB6tQyrCTyMqxe33tJUDRElftTRP1WUt8+ZimwmkeZiPAJvcTmZ+mvtK/kqXST4rDXPeUkxkQzG0fLFASzIgcgHndvbiyG19A+6/BUI17isWCot/hb5O2S5PCPQTMwCkYzfyFwrOmoTUpy3rNAGC9SqQjRRV+hO8ft/0Wtpc5wLnomHUFCzHXY2+6GUu1f7vpqT5Vqr3OHb9szEW+TOhAsPnuXwlnTUHT57921vu39NNKsVph1zq77OZzynt90d6dZ0rpWs7Kn2TEB12M9hzcyMaGg8+z/+riSviFg5w== 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 PAXPR08MB6432.eurprd08.prod.outlook.com (2603:10a6:102:154::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 11:56:39 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 11:56:39 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 01/15] aarch64: free tlsdesc data on dlclose [BZ #27403] Date: Mon, 15 Feb 2021 11:56:28 +0000 Message-Id: <90458da8b7b46e806f756c2715c87fc9d2c1be95.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SA0PR11CA0166.namprd11.prod.outlook.com (2603:10b6:806:1bb::21) 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.49) by SA0PR11CA0166.namprd11.prod.outlook.com (2603:10b6:806:1bb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:56:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 78b57189-5506-451c-7faf-08d8d1a8c506 X-MS-TrafficTypeDiagnostic: PAXPR08MB6432:|AS8PR08MB6102: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4941;OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: hrTCO79b4SruR4dJXh3Bdd/SHpXdbvE6J6DfVqMNKf2wPW327FpM28vTFLISeT09Yf2h0kXDMFFtHZvTluoyIFRJdvIUY6NKPjcW10oLEJnr8SfOYP6SbP8hGR0rA6tTf52ql3pVX0B4GTKTZxY/24ZBQijwN+yXqvqNet7dfA0rGl+uz3vAu+Xcg15uwGiHmB6f74YKNPo2u49lPaODnduuPLpDCFlPy9NkBfvASSYHKTyJtfQLVL85E4UbOAzYbaOVTWBFS2KCFk0z0vJ5rFHpvBIH8eJd+gfPeQNQH+lsrHxeG/781pgK5uHxs40uBQCaTqdecXmGurhdYLd192gT6YOqimLtxfFIGAXYRsLmtbiTyhwIy7X4FPVFHMfq/j6oiX9e7pAgbb1zfJPFjgeSuu1Gxj8+28aCUpBC0hwONx7z45svM1Wze/KXCgoeDmTaMAh5YqoNJ/3aiCt0Ld7dptQ80u2GaEzZh1VWSLE8y3Pjqv8G4z2hojR+d1tJqPddsZTVU1Y6UkKtnwhQRNe9xEhY/QSQebpa9nlXkUJ1hmdzlk1XWl1EmLfegFp8nqCUkE9bNoc5fsL54u+XOi7YplyjYGcdxsYpfvDlh6W2mKxap7/81rAvdmEFI9hGWMZEE2m7vbiN0mI2u5YnwtDZtO6+6JMe6NBT0PbEEJaJqgrAtBSjdEgXqrylMUML 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)(376002)(136003)(346002)(366004)(39850400004)(69590400012)(6512007)(6916009)(66946007)(66476007)(316002)(66556008)(186003)(52116002)(86362001)(8936002)(36756003)(6486002)(5660300002)(478600001)(26005)(6506007)(956004)(6666004)(16526019)(2616005)(8676002)(2906002)(44832011)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FqUFe398dEe4xHi1ezTqUySXGrh3W75+CotPgOqD/YiRzaLo6iUkxlrq35fNAp5rpCCrWZLR8chUDHMz6xFFaK0BNux0bqdpnkUzb8YeSK7oCcORWOz6N+I3S/90LQkwXrsTVT+SCdu4YCoXMd46hzslME0RzzZM2lb0sb4OZSVprQx+LBNRESnw7gq2EI+cE32AEpYRCGb9INLBdGK/O60F6QLdiae9HKK07bp8t1FXKx9mPCUC2as45tt8wPBGEij7dlaRW70FhvVxEGVHyppVszraWkSmdNDL9dQdKMnv/6sD7NWqX8scfUmKQhK0JhYk9hAXdWMbBPyIu4nndUV0mbKrieNQ4m4WVNDL5m3c8+Z+7y0WdwzIh1NrUWpfoKuOvQjQxsoRu/OJzlysWT1oBU3pWYiys36VicBr1uHkFf72zL309wigHIjTYyqr6omxNo+p4sofvHCixpqEO7RlQ50nJfB2X0e0mIHh3m5OcylUHFaBx4zVLL8xogzb+Rzi3JkLmLgust4PCMmkFwFKBPWATKyY2n4qBqHRIN9GQKYQr6ceUBnYr9nks445IaRhV58WdeIsS1ol/GcTKVO/chQwtTjpfF3BdYR4Wfgez3hvcZdfAzwuL8i26pdsIiFj8PsFQ5DAXc0cJafbohiHgKj9btuVcF7FCLXh2SRVoFaNXUt2yIOoAKaatwfmHa/qQRA8f39NTEQdCrmkKjEtYmodkriFwLEPmtdfUuoa/eYEfALhzHGDD9UveaLyx2IPW8v0Q8u2VLo7dPq+rw57n6+1w56e9fV7Snexr4LYKwM3qBBb3U4ZVuokxLwFJ9de9U1E7C4R7sKbxgpr/0SNCALhQIdmz8OkDQxiMW3iE9qBTqcCncXfB/MqFAVwV0T9Wa0qry4nm448Bois1ZKKuc7IhvrWKWVgwEkeekmJ3KTotAuz+vL1AsIam+7CZF3O6vLtbx/imSj1/9bYbTCjYbrFDrB8r2DDfq0kZiCpwJvirYE/V42jo3xPLimu7xssJ8uEbhyNpRaoyhQ8WZ0bcUE+Sth1jFLGzfD6FftDTqQ5xe63W3gKAoLSVO32CSJr+lXJ2+PnZ3SrMM8fo3ELkcXlW1rgL9iDcFJ1onUbnbgwV3QY1mukZyyf9KY17NnkpCAVhg4Bs3tKY3Lt/bYz2juSwPJnhb6flG3cPRGsCUNyJmtmc/1H2MMd7n7up0MfCY2/ZzrBPWQRiJkvD9qkDp67m2/uiAu/mzhWQyGn+0A70HxQchOtHMTR64Nl+lpHGLv2LLIWNLVqdpcMBgfSOEkuaHiFK6useNQSafIqoH96fEWJbwWAh23JW2AR X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6432 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: AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8977f21e-9d5e-4530-2fb6-08d8d1a8c0c2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +g/+yzw/tJ6RkBfQyM4uhjeRCunBxlIlotxd5ogPfoFSxY2LKZv8DUpWoB9JRo/9qcZ+E4Rr+fdJrB+QtFTqH8U3+ahm09bFDrijeszZnYzLXqOqTa9XyOpwwecFwBfA4L7zbcS3Wp803mGgFY/44R09PBK8wEP9aAKeGuYOTKM58Lr4IfoQp6s9AbW4hJymm4/PdnilL3yJZEC9Rdo8FttjyttFwLYv0H5mXklI1HB6U2j38Y6X7HRPuONFL6G5iR9wpOcSGQPBURXV/RgdxoSIP7TLM9Gaqzb3pRyjGmlX5UF73o4Nc3hTynE5I6NLON8UC7q7CkITdryNhtacxLFNLv5DmyvswHTAI+i83KYmczCp1Ot9nF9ArseZwBf707VR05uwtVKOkhV/qHDr9DkQsdJzzRTe7QnhMZlyApYDLKqLmsdEsRxdDSg1mAI32kBSy4o5OC1QTYDoaFg0AJhEYXAr712E4/u3JByO2ULyh6Egs3Moyu704ko66seOg3POLVA16tUxt5U2P7HZ2K05+Iqg8VLWyteiK8SosX7U9TZduoaz7al8w6HIREqamowPAxkxzLSC4Ijbf3sf5PmW8a5sHFujVPHBKtA0PR8FI0RTsMJW8iWwS26+6rsXlpkaCyE7c2Aj4xGYrX4ZehUosI9mPD3S0EBDIvlITyqojgTDnru015glt2ZuXSpFnFmsCF3y7YYacak0W4TPdBMId53WGN5Qsh5PCSb9VbEQextopA/s5H3DLsW45MRDcVWvUgZN6KCg7RdLiiEZQeNrJHRpC+5oJUiUO69yvHg= 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)(396003)(346002)(136003)(39850400004)(376002)(46966006)(36840700001)(2616005)(26005)(336012)(69590400012)(6666004)(86362001)(956004)(44832011)(8676002)(16526019)(186003)(47076005)(5660300002)(36860700001)(8936002)(2906002)(6486002)(6512007)(81166007)(356005)(316002)(478600001)(36756003)(6916009)(82310400003)(6506007)(70586007)(70206006)(82740400003)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 11:56:46.2543 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78b57189-5506-451c-7faf-08d8d1a8c506 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: AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6102 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" DL_UNMAP_IS_SPECIAL and DL_UNMAP were not defined. The definitions are now copied from arm, since the same is needed on aarch64. The cleanup of tlsdesc data is handled by the custom _dl_unmap. Fixes bug 27403. --- sysdeps/aarch64/dl-lookupcfg.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sysdeps/aarch64/dl-lookupcfg.h diff --git a/sysdeps/aarch64/dl-lookupcfg.h b/sysdeps/aarch64/dl-lookupcfg.h new file mode 100644 index 0000000000..c1ae676ae1 --- /dev/null +++ b/sysdeps/aarch64/dl-lookupcfg.h @@ -0,0 +1,27 @@ +/* Configuration of lookup functions. + Copyright (C) 2006-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#define DL_UNMAP_IS_SPECIAL + +#include_next + +struct link_map; + +extern void _dl_unmap (struct link_map *map); + +#define DL_UNMAP(map) _dl_unmap (map) From patchwork Mon Feb 15 11:56:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42031 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA6AD3950434; Mon, 15 Feb 2021 11:57:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA6AD3950434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390243; bh=fkOptyq0c0zGzDDr27CPVdNZc0LNIa2hJXpVTfn1kDk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fvUV6VW9y+tPS73NhUpUXIxNmx80bZvENLwDEUQ83Iog9qMlHvlX3dX8J0652qoQ2 AyRJrVL0nxCEE+QYClFKP972xr0CWpJklkSe9t2qpwYQuMnGt52GLSDJZL2DpdyD9u wHeobFrQygtTVY7QVKJ8yB0TLmIt9ZfUF4tuLVIQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) by sourceware.org (Postfix) with ESMTPS id CFE3C395042D for ; Mon, 15 Feb 2021 11:57:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CFE3C395042D Received: from AM5PR1001CA0021.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::34) by AM6PR08MB3685.eurprd08.prod.outlook.com (2603:10a6:20b:6f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.29; Mon, 15 Feb 2021 11:57:19 +0000 Received: from AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::c7) by AM5PR1001CA0021.outlook.office365.com (2603:10a6:206:2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 11:57:19 +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 AM5EUR03FT020.mail.protection.outlook.com (10.152.16.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:57:18 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 15 Feb 2021 11:57:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7c62917f4cfb6cef X-CR-MTA-TID: 64aa7808 Received: from 83b055a61693.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 21E8600C-EC28-4216-A38A-1D3AA2BD8EDB.1; Mon, 15 Feb 2021 11:57:04 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 83b055a61693.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 11:57:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m94dbisz21nXzCEc1G5ylcI2PDd5h3fgVhXyvFQj3YmNup+/KWPLcHvoM1ZvusWEpRS0uZ6FwqQg8PG4Kwc4MIx/7GO1bmYdr7z4Dq8vGG9qq4nlIo2Uq3ZMPj1qEMWQG/5AVpyBuL7XC8TLAFjcM2nyDwUmDQnDEhLZ+41/x8SmSy3ePdFRlP5udSeEb0tHBSl44r5MesXWuTzr4ga3pH0u5gjUbwI4P+nK9l7CQ6rXxmn87JBiT/EVxPD7ZD7BFR/RCAtq7mxr0BWbraTdGiGUb0oCqjdUKDLHL4w1vDVPoVxn5UJPf9LdhQzS0+OxuEfzgBWDSgG58hv2LLaZdw== 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=fkOptyq0c0zGzDDr27CPVdNZc0LNIa2hJXpVTfn1kDk=; b=cTxEIyx6foepav/oHHERQUZN3j8G0YGNxHEm27k3vu7gf5zKC1NSaF8teOOmdnXRDFkFyaA08B/uhhW+QwAQLBjKWrlo4oNDHTrg0tqJahwoZxvub7wBfp7CO+Y4vhIqi8srik/miX78ar1UQFJf/YDd1s1qsZp8y22PtYMuPRZC0c2XW8+p2K7iEq80R26vJceb4WfzSFWsWs0gDx8Av+hUdGvbDDVo0FctJlOi3gwe8hN7FgCKREhQXid0MBNd+y9ZV0+NQC/xxEgeG3DxlQ2AvkIqHgmA0Ypic/ElxQQHrWzGCxB9z6mpI3qeU4ek3avBQspvbxtmKpdYlxZhTQ== 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 PAXPR08MB6432.eurprd08.prod.outlook.com (2603:10a6:102:154::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 11:57:03 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 11:57:03 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 02/15] elf: Fix data race in _dl_name_match_p [BZ #21349] Date: Mon, 15 Feb 2021 11:56:51 +0000 Message-Id: <3721784a79c9d2040297304b2a7216d7072ea838.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SN4PR0501CA0124.namprd05.prod.outlook.com (2603:10b6:803:42::41) 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.49) by SN4PR0501CA0124.namprd05.prod.outlook.com (2603:10b6:803:42::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.11 via Frontend Transport; Mon, 15 Feb 2021 11:57:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1b3d50d0-a810-49b4-7696-08d8d1a8d806 X-MS-TrafficTypeDiagnostic: PAXPR08MB6432:|AM6PR08MB3685: 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: wMnF/vLfZaAECM0mmbLDN8HHqeUqhG9dljuDe46QaF7Og46KLjIXnYUusid1T+fl+P9xT156SVaaY7vvsjPgkMqSsQStq+YqVywNgW62O/XCXhLJbQ6KGwY4BtefAHt214SCYaHw+Zz3czCAnZwJB+OW7FUSqjd36VE+aJ5G3odIQPrN+RyIwIWMPblsNbPqt/DTaI6S95WdKw+95MYNP5hxqECzJYGG2PBqA4La10s4lyZmlgVr9N49x59TuoDymiTY5I5zXhokaJC7a1BcqXF1sgWKYlJF1dYFqLNeJpe8oN8rLTb0MeArsYtS6OynPs+jRIpH7pgV7oDAgrFM85gLlib4KsIlzTJzArIPLqNyoI+FCxufByfcz6MXXfTyvaG4VW6F6PCgYw9QsxdcfuDS5TjYBSmXcWYZ8+swpYwJtawYRsyh6pwriqMRvfRqQwqU5koxWqr2xQ23EhzgJ3jqo7itY0cGQvfQ9wIG9fOvXqI8Rx9s00U9lX8eigHll4q+3Il1zVPy1Fm9OztaTyJ9Xcqi66/WzXniqXbMd2yfxaxqLcfggGAxQmN63Sy2AZZ53mrJHDaq93gRCpxipw== 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)(376002)(136003)(346002)(366004)(39850400004)(69590400012)(83380400001)(6512007)(6916009)(66946007)(66476007)(316002)(66556008)(186003)(52116002)(86362001)(8936002)(36756003)(6486002)(5660300002)(478600001)(26005)(6506007)(4326008)(956004)(6666004)(16526019)(2616005)(8676002)(2906002)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JFcGDqHf/uGUxoaPW83OK3sq0ExZYJQFRShgWKuXqwfLyrR+ope//EV9LCVbAUwY7HtQG9JKYr0EpjDXdOHTJ+WOzWOXeeTyaQrd06Ic4VQ+1p3KtDO/tImtU04z8u78WtTCcCZRHPanR2Mv6DXY10NKBrB/5+mMIBqVzkihm68e3TWoDkcytb0hcX8b0so8BubYQZq0KGuAvxTEJJMc6ShYIwwslHn19J7wORGnn96dta5lujb+tg27qx+INPGbwZzsEJWhMQhEip6pi6c6PENHuHyTQp/e5UXXWQtJGzGBN0SaRNE/KkJaFTfm1C78kcXG7BbPrmXjGZE/hxcxg1zDhcOMjfdJiE3Cyk+GUmxrqQeA6z70Yth2jYN2XPbRZzu6NBM6WF82qpmKR1PQI/Y+1+YCCXWHx9q2eNnC7c2FDUSPlF32y+DTgjBGKFcTaEJ9LY/QskU/hVMYLCYmRyxDZqIdTbYn8Gy7+fSoEE/F21BTW8KkCCR3/PjXWu97pdhYG+6zYrLK3fI5LQnLngG1/BmILNvN1TxiQLAJlVAEK6zmUdNPWeykW7LjujuMR7IU5Xtzg4Yr0q2tBhII7E+fc+44WjdnUOxR8bO8dkgQ+ztWcqzZrucF1J/Fec2oX4fQeuQZxK1JBb/WVGxm/D0jxxfkFG+ENDZ+mtq3yBtvnw31vlYFUTV7bqhM8u69eAP0gN6nXdh0eBFrTZtX20HdrtzaaqgJGYuRrpP+FqqxbFC7jfKE6ZTDcBDzacITBVzWmm55tDQ7eIXMyYwWNaiDGxySKaNxXX/0trbVbDfWw8IbpIcXSOA8nyq9UJ3vtuYveS3j7hDHXRFbhM0bfBLSew428vz/N57BWW6X102E6dpNoteUXgzKsps5OEMUb/lgbPYzZ8i5gMpAP83wYnyYrqUwNi7TvhvgnaanXo8ynWcroBnboyWwvdcC9vQtw4PCYhFA6dSbqNd6reYQgHXG9bXf3v11+7RwJIdnLzn0Im4i4r8G9KP4vPWlfa9x/4p8J3RW24Yjn7NbW8j6nxfh+ovR+BdF0x3I5cwcM3KNNe9iLw+AVd0UoQIO0WDvPLfGbs83LGsLswGqHAhpCgp01u3Anj48iA0GVetH/fN2C8ZSV6DN4hpK5PXwPH1lGS3hTAUswePBTPStggRKboMIuXo0R3wc/toRQHDVYBu/iUJ0MbMazM/CItRrxuIx4792xgguzLvLDifL1LY2miQ5P0Ono4LcB6Ks6D6Um9vMlPU4yLy5JBzpE43vU8fOo3JiP2f1aTJp+XOAFSOvG1r8trkxdZYQJxNNBeeFNT5LNJ9tQIn4S7OCkVHiMuhX X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6432 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: AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1566bf33-91e4-4d11-d337-08d8d1a8cf40 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gv4ESyYs2FgAbqZw+RZ90XPUp2RchxPgRNWbbpDQPZge4jPFImXdtKejMZ1cGoFanqZak1q7GngQP2xzp2sL5zIlqixko7reFOT8Rh8s30cU9FbTa8UjKqVDz7qL88a1QwiN7m5yTrlW8rpu2aoNjFHHxOUDSw5pvR64FuuSFZbZlrWM043FETN+9MLB2vCdagc3+XXgpXg7oEgPMj1fTmC/8KXmqBuYE98vEGpL9tOZzsVkxd8O1k6RjSF4nPNJ6N7Rh7KMcBbrwhbinnDQL+L4MPYPfNuRxkxtS39wLy1QnuHPdu4Sqxw9v/OmbJJbhhwjn8CJHqGx0nE9sbKWS+hwFLMXoFRkAGjNWIXdlQCduTHXlW4aAlQ5CJDtF9PE983LozfU60ZJHV5fEV7hNRaV2MzKgOK9uv8VCtVl3QBiXAiHmDv31fEN3Mv7WJY9MkxfFPCN+NTwx89LhL4RvfJkJ/bk2MVw4WiGmZJsmnZZA8nMcd32jfTVI6SdtGWMu1TiJ/Oxy4qq1kZ5uw9/wBMuw2FAJP5UXNy5b0OKMkXyuwXdSp2vb898bpwsis+Cg6xXt08p5WmjOrnxGBgs4B+dPyPxSLA+6zMy/SC0f+ZDzDTTzjm2R2O9rV6OHvYD7BMbrbCWhXDtA+8CrYkR9uJbWf1Y+wxENlK9NYGKxnZkGlh6KeNaNfjCQqYmJamR 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)(396003)(376002)(39850400004)(46966006)(36840700001)(478600001)(69590400012)(316002)(6666004)(956004)(6486002)(36756003)(6916009)(8936002)(4326008)(8676002)(86362001)(83380400001)(36860700001)(47076005)(2906002)(6512007)(44832011)(70586007)(107886003)(26005)(6506007)(81166007)(2616005)(186003)(82310400003)(16526019)(5660300002)(356005)(336012)(70206006)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 11:57:18.1318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b3d50d0-a810-49b4-7696-08d8d1a8d806 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: AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3685 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Cc: Maninder Singh Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Maninder Singh dlopen updates libname_list by writing to lastp->next, but concurrent reads in _dl_name_match_p were not synchronized when it was called without holding GL(dl_load_lock), which can happen during lazy symbol resolution. This patch fixes the race between _dl_name_match_p reading lastp->next and add_name_to_object writing to it. This could cause segfault on targets with weak memory order when lastp->next->name is read, which was observed on an arm system. Fixes bug 21349. (Code is from Maninder Singh, comments and description is from Szabolcs Nagy.) Co-authored-by: Szabolcs Nagy --- elf/dl-load.c | 18 +++++++++++++++++- elf/dl-misc.c | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 9e2089cfaa..be54bafad5 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -438,7 +438,23 @@ add_name_to_object (struct link_map *l, const char *name) newname->name = memcpy (newname + 1, name, name_len); newname->next = NULL; newname->dont_free = 0; - lastp->next = newname; + /* CONCURRENCY NOTES: + + Make sure the initialization of newname happens before its address is + read from the lastp->next store below. + + GL(dl_load_lock) is held here (and by other writers, e.g. dlclose), so + readers of libname_list->next (e.g. _dl_check_caller or the reads above) + can use that for synchronization, however the read in _dl_name_match_p + may be executed without holding the lock during _dl_runtime_resolve + (i.e. lazy symbol resolution when a function of library l is called). + + The release MO store below synchronizes with the acquire MO load in + _dl_name_match_p. Other writes need to synchronize with that load too, + however those happen either early when the process is single threaded + (dl_main) or when the library is unloaded (dlclose) and the user has to + synchronize library calls with unloading. */ + atomic_store_release (&lastp->next, newname); } /* Standard search directories. */ diff --git a/elf/dl-misc.c b/elf/dl-misc.c index 082f75f459..d4803bba4e 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -347,7 +347,9 @@ _dl_name_match_p (const char *name, const struct link_map *map) if (strcmp (name, runp->name) == 0) return 1; else - runp = runp->next; + /* Synchronize with the release MO store in add_name_to_object. + See CONCURRENCY NOTES in add_name_to_object in dl-load.c. */ + runp = atomic_load_acquire (&runp->next); return 0; } From patchwork Mon Feb 15 11:57:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42032 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92BA13950401; Mon, 15 Feb 2021 11:59:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92BA13950401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390364; bh=yhpNuyDfEq/hpCR5gx+N6PW8zaPs/M3A7FJChbBZEKU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KDUunjbUkQ2hh7NMPcDTckWIJMWkeEoFwkrL0NPZTbYyPqEOpePx6inG+FZG+Jkl2 ESUB3+DmHNHRHWcpI0aJ/qa7v50TINbPLahc0LUWHW+pnpfnFVYdp5F2nySmFJt/aw DbOf66bkiA/OoSjHcpyYYCW9Xp/7XSo41WfJ3On8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60086.outbound.protection.outlook.com [40.107.6.86]) by sourceware.org (Postfix) with ESMTPS id 78776394EC1E for ; Mon, 15 Feb 2021 11:59:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78776394EC1E Received: from AM5PR0301CA0019.eurprd03.prod.outlook.com (2603:10a6:206:14::32) by AM0PR08MB3331.eurprd08.prod.outlook.com (2603:10a6:208:5b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 11:59:20 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::1) by AM5PR0301CA0019.outlook.office365.com (2603:10a6:206:14::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26 via Frontend Transport; Mon, 15 Feb 2021 11:59:20 +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 VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:59:19 +0000 Received: ("Tessian outbound 587c3d093005:v71"); Mon, 15 Feb 2021 11:59:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4e136577a6ed6d01 X-CR-MTA-TID: 64aa7808 Received: from 117db31586e5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 21755682-B04C-4015-B3A3-52C9731EEC0E.1; Mon, 15 Feb 2021 11:59:13 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 117db31586e5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 11:59:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hWZZVnAK/TXqdamMPJ2dkn9YZYHoizpb9bzF5GlEvpscuKkt6UKX7HJXbw4QCKhphFzheCQ8JBH6U80nrPEFoHxPIulNcdGGz2N+yYWfEmNuvwOTqApL8Nfu9iJvpMKhmlyqCZhxnclnTjeekRI8AQBmJui6mYBsr5oO6DHQx7P2wjud3vM0EtldBFdXYrLR2xKDYakWLZ5kgV8c4fzxhPUaFtVhBL6OLYp1DEX9mH7ogQyrU7jGMvqLe/eoLY4IJTTjq+nhiravEQPKnYgjGF8Tabd6aVtMp3myVxo8LekuhPvl1QNREcw2xCzgRgnYc4htAo5FQasdWGZUPQZFvw== 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=yhpNuyDfEq/hpCR5gx+N6PW8zaPs/M3A7FJChbBZEKU=; b=VPh0z3AjcpvyfwRac60Hdi7oLphnmaKZyF6EMRZHGMDvuSfbyoh5CfEKiTZ9IkWoFlfM335D+C812n2qf/1vl7PBMf4r1SHo/MDSKI2QF+RdoX4jGXEzFrI/401D3nMDB3pClDHnnJV+XhvKoX2SQxqbhYW7fO6xuql8zdnvlsWcfazjMwOGMsjn2gr1OLEtDxWcRU3gj65b1vxQRyXAKJJo1OPsAC+c714wn1kQn/wos1/hHNtNVBeYcmaLQ1S3Kt6iJbXLg634ptaaplUUcqSm1dLwVmP/H4o18E45LyrtaowxV9w+WYLLRVAsjp0KGbGEnFKMbdVrxDcvYR0Jgg== 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 PAXPR08MB6558.eurprd08.prod.outlook.com (2603:10a6:102:151::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 11:59:04 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 11:59:02 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 03/15] Add test case for [BZ #19329] Date: Mon, 15 Feb 2021 11:57:15 +0000 Message-Id: <34be48a80b03bed2fe8f3aff020f8b6b77858e97.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P265CA0498.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13a::23) 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.49) by LO2P265CA0498.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.36 via Frontend Transport; Mon, 15 Feb 2021 11:59:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 697061f8-1e7d-49cd-b4dd-08d8d1a92063 X-MS-TrafficTypeDiagnostic: PAXPR08MB6558:|AM0PR08MB3331: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: yi3dVsUrxSN/FGy4pz7pXXeX+dlQTLPbm4jcaRgBvygeMPPzei1Kaz6aOA+cYdgUo27L0BqKvhCOoMc5v5jJbCjUkOI2uqVM8Hp246UaGGcbxhVSqGEjqHiOmR/jUAyWmRoc/RLdpjQZz1/DHhCZYRgj/jIT0saib2TXEmb6xhN11Him7ZBpZAGZEEzxJyZRJDHysXeb2QuqycZ42I6vyDKNVkkMY3YQjC4ECggTe0fDOaHXGfA+zZ2qfKAEq8AjwD3/ajlm3Ey0k14J+tF4u4qPnEQHSsWLN0EfB5zpxehsOgNt1oH5ja2lZJOejjpN/8ULi4Z8L9YG3dBcMKXmXjsN5wz9avcPbUp/it3i5LUrJ4F8RV213CwP6QHPagiZiol9Ikr4moaO5yS1MCxCBhjdokSGYg7vXIvgCpzelstrXpxfL546KH4sxs8W6G4eNcF1trK2VEE02f4YXhquaS231brcXHcv44+jJkpxoqYkBYeWvFcXOumYrDy3xgWJKjpBNOzgoFvPmJLWiB3/HusrqsLHLaNrXG5LkwTXsQEwZICluaTm3BjNW+s+AwfYF/0yCZRy6+9zsoEaMftfQlLHTfpwLSXvBmkKlC0BInq/pYA5gqJN80P+1gt4pQu77JgSysCkc2lxTqd7aEt1Wu6yRJEmhIg0noehIv8POSE= 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)(136003)(376002)(39850400004)(396003)(346002)(366004)(956004)(2616005)(66556008)(44832011)(6916009)(66476007)(6486002)(16526019)(66946007)(478600001)(36756003)(186003)(2906002)(5660300002)(26005)(6666004)(86362001)(6506007)(6512007)(69590400012)(83380400001)(8676002)(52116002)(316002)(8936002)(4001150100001)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Z3y2h9uD4Dulj7vVsjDmm9WF0ibwxpYJEzj5LX4hG9d7sa3lGwEJRISHxjVFa4d0zSwpRN7DZlH/wy/17PBOBdDiCsq7bQuzD1hR8J6bJQsz409PlY89KGwsdfh1BqW2xAs0My4jDbKFLh94QeCyj/oUHM+zFQmBvIgtFzZMgE7PCnjUUrKGBNybk4bLPT5NXU3+1mOTXkICfY7kpWkiffooHtPlnEX/W1qYZnNOFJU2u52Ae4dGPWvWYbSEwkIDfhn6jBRtEjm0g8qS4Dj5HiIyw1HmffEJKHMi/+yuqOpUoilfJxrlGAlRvCMR7wOt6TqCmRV9n3iwzA/qV6rMrWvZgvwroHfAV2937IP9g/MeuQvYpcwFztCRYasqqcUW2Nvlk+1OI5CuHM68UUu2PjR2CQOFbcVbQIoWQazKvxfBu9uQp48zzslhXsPzuVtXZLzE7cOJUFglf3ThEpjQjoNXpLa4HsYCyvxzXVVQAZuz48C8vbqJeDRzLCbGt3keud5QHLUOzgHq3ZLxUyzx0/aTCxYP49WUqPNv6SmyyNqcm4Mgf7AOyOZZpOa9E3DLak/aSOZGD+pf5UZ4iWmUHKqJ8vxHv/HyRARlUlSaDNB+xeoJalg0v2rn7bJtD1QRtKkjaECrnRhyF6umT1neglXke8ueTmM8F5DDJYeu7r5kP9fL4k/61MUqiqo1PwmWEdV7ouZ2MFh2nZed4t6T4laPY2nlJmPdZjsXzVWGsPPPCBSoxRJZI6ChLI+xYdQwUbYECnvHu46/eWWhSNohkSlU+jhtCMC+EPZ7ZcVE/K0HLg/6qzTNdqMLZA+JfeegNb4F2jsKB7HpQyLQ4R7Jww1hOJ9un/NhpoISJkGccmHU/C/5k3pmJbG4E/sXqOWdP4SA2VKwCwJw+ILQasHsldBXiwmjhSUmffy5FSPYJYgg9kY8DcXmxwhOSwCeb8+NNBo+ys0eToZggItLsDvf1fEq64kTEaOnLYCgwskeHAlgBjRfZ6EoKXGI6veBISueHDOqC+xSQTSfI8Ezj1QxitvCsy9OakLIh9KT/VTr4LD74VlrX5Aw3ygAVq4o9iuEY1Zcm9H/DCoupU9CIvmLI9vXXZSDRObhntlc4dMfHqi5lLKrZhNsciYW0OEdQMAiaHc+bgVqPFq0zpSBREzmjSddXVcknzLU093b+wCuPPljRkCkOX7V4wwTk+bGihB7L8aejf8tL98WPJk5r26ChsCTnEht8sFZm0rNqblcFt8boXKFgrwDXflaQaJPBpcc/IiwJgP+cYNHKIJmEyIcHPHJbRW5jqKj7q2QWRTQWCzFK5j0VtIfYET4lwxmxWv1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6558 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: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 564da7e4-7413-432d-9fa2-08d8d1a915db X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yVImaEyvN+xzDNsFXWEOK5Xifgf9OFIhX9rO54Oiik3xNjG5OmqT5yqNgzx6HVHRP94bLfhkvI3K6EaRURSvqRLpAUb89fuW59JqJ9qTWthGP+mhw3aEa/b8wEkHexZhJrV7vPgM9Mmym7K79jz3JOA5oLmEZ0BrKhHjU71JaRgZZ+HP4D9uDZZUHuv9Er9PUUNYuA6SB4w3Y7B/C1KnYTwvnkkmmzctDgDCgzLKpxZsXU/9JmzdgGGtXdX082QoqhgF18gyX/VEoWrJmmgrY+gz1h0ifBrYIrlV3HlXshzQC63xgRKKi7Mz2XV30yb3s8E5lFL9ziUT13pxGz8n/rCVC7i2XjaZD2h0E/gtTCghO8/KIAAPVd4QSc8LB0Hk7v+ERStenEaq0Cu2mssDR7VZjkhDdYv8aG4IoA4V0mtG7hwnWyPA6ns7kvnapTkNXisj01vd6V7woO1ucLjKwekSrVoqZsek3JEJBxPSzFld+V/1S+hoxpdt6FX80rRbmCeB5XvSYSyoNKDcte38+VBAk4MGGTrcqJ1Qh7R2ZoJZbwvoNlPS2QSsFyk73dPKLcuc+A35FqN7jxlRoHZG7ln0Y6EBOm5WjFZ/Ni49MiUiwR3OrzEYPN8B5LeFQSTitXk7W/uVP10/eguIkS00Ta25UU++lr2S5i1zzbToqfgyGyp+8JdhvWcHgvxOFe7sebGtGQa3SojtxQ9khk+tJfR/tdquSatU6M2HP/N0m+Fle//2DZsEGNDQUDzFiYs9KejFR+9LvggdDSfGZkMsG8BV7XWqpdioJk0vSRiwgGk= 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)(396003)(39850400004)(136003)(346002)(376002)(36840700001)(46966006)(86362001)(82310400003)(36756003)(4001150100001)(478600001)(47076005)(70206006)(5660300002)(316002)(44832011)(70586007)(6486002)(69590400012)(356005)(8676002)(81166007)(336012)(956004)(2616005)(6506007)(6512007)(8936002)(6916009)(36860700001)(83380400001)(82740400003)(2906002)(26005)(6666004)(186003)(16526019)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 11:59:19.4719 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 697061f8-1e7d-49cd-b4dd-08d8d1a92063 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: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3331 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Szabolcs Nagy Test concurrent dlopen and pthread_create when the loaded modules have TLS. This triggers dl-tls assertion failures more reliably than the tst-stack4 test. The dlopened module has 100 DT_NEEDED dependencies, the number of concurrent threads created during dlopen depends on filesystem speed and hardware. At most 3 threads exist at a time to limit resource usage. Doing the test in a fork loop can make it more reliable. --- v4: - rebased, updated copyright year. - moved to tests-internal because of v3: - use the new test support code. - better Makefile usage so modules are cleaned properly. v2: - undef NDEBUG. - join nop threads so at most 3 threads exist at a time. - remove stack size setting (resource usage is no longer a concern). - stop creating threads after dlopen observably finished. - print the number of threads created for debugging. 2016-12-13 Szabolcs Nagy * nptl/Makefile (tests): Add tst-tls7. (modules-names): Add tst-tls7mod, tst-tls7mod-dep. * nptl/tst-tls7.c: New file. * nptl/tst-tls7mod-dep.c: New file. * nptl/tst-tls7mod.c: New file. --- nptl/Makefile | 17 +++++++++-- nptl/tst-tls7.c | 69 ++++++++++++++++++++++++++++++++++++++++++ nptl/tst-tls7mod-dep.c | 1 + nptl/tst-tls7mod.c | 1 + 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 nptl/tst-tls7.c create mode 100644 nptl/tst-tls7mod-dep.c create mode 100644 nptl/tst-tls7mod.c diff --git a/nptl/Makefile b/nptl/Makefile index 8fb7fee6db..208629876d 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -355,20 +355,25 @@ tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4 ifeq ($(build-shared),yes) tests += tst-compat-forwarder tst-audit-threads -tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1 +tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1 tst-tls7 ifeq ($(have-z-execstack),yes) tests += tst-execstack endif endif +one-hundred = $(foreach x,0 1 2 3 4 5 6 7 8 9, \ + 0$x 1$x 2$x 3$x 4$x 5$x 6$x 7$x 8$x 9$x) +tst-tls7mod-deps = $(one-hundred:%=tst-tls7mod-dep-%.so) + modules-names = tst-tls3mod \ tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \ tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \ tst-execstack-mod \ tst-compat-forwarder-mod tst-audit-threads-mod1 \ - tst-audit-threads-mod2 + tst-audit-threads-mod2 \ + tst-tls7mod tst-tls7mod-dep extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \ - tst-cleanup4aux.o tst-cleanupx4aux.o + tst-cleanup4aux.o tst-cleanupx4aux.o $(tst-tls7mod-deps) test-extras += tst-cleanup4aux tst-cleanupx4aux tst-tls3mod.so-no-z-defs = yes @@ -517,6 +522,12 @@ $(objpfx)tst-tls6.out: tst-tls6.sh $(objpfx)tst-tls5 \ $(evaluate-test) endif +$(objpfx)tst-tls7: $(libdl) $(shared-thread-library) +$(objpfx)tst-tls7.out: $(objpfx)tst-tls7mod.so +$(objpfx)tst-tls7mod.so: $(tst-tls7mod-deps:%=$(objpfx)%) +$(tst-tls7mod-deps:%=$(objpfx)%): $(objpfx)tst-tls7mod-dep.so + cp -f $< $@ + $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library) ifeq (yes,$(build-shared)) diff --git a/nptl/tst-tls7.c b/nptl/tst-tls7.c new file mode 100644 index 0000000000..4b3f9005fe --- /dev/null +++ b/nptl/tst-tls7.c @@ -0,0 +1,69 @@ +/* Test concurrent dlopen and pthread_create: BZ 19329. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#define THREADS 10000 + +static volatile int done; + +static void * +start (void *a) +{ + if (dlopen ("tst-tls7mod.so", RTLD_LAZY) == NULL) + { + printf ("dlopen failed: %s\n", dlerror ()); + exit (1); + } + atomic_store_relaxed (&done, 1); + return 0; +} + +static void * +nop (void *a) +{ + return 0; +} + +static int +do_test (void) +{ + pthread_t t1, t2; + int i; + + /* Load a module with lots of dependencies and TLS. */ + t1 = xpthread_create (0, start, 0); + + /* Concurrently create lots of threads until dlopen is observably done. */ + for (i = 0; i < THREADS && !atomic_load_relaxed (&done); i++) + { + t2 = xpthread_create (0, nop, 0); + xpthread_join (t2); + } + + xpthread_join (t1); + printf ("threads created during dlopen: %d\n", i); + return 0; +} + +#include diff --git a/nptl/tst-tls7mod-dep.c b/nptl/tst-tls7mod-dep.c new file mode 100644 index 0000000000..206ece4fb3 --- /dev/null +++ b/nptl/tst-tls7mod-dep.c @@ -0,0 +1 @@ +int __thread x; diff --git a/nptl/tst-tls7mod.c b/nptl/tst-tls7mod.c new file mode 100644 index 0000000000..206ece4fb3 --- /dev/null +++ b/nptl/tst-tls7mod.c @@ -0,0 +1 @@ +int __thread x; From patchwork Mon Feb 15 11:59:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42033 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90DFF395041B; Mon, 15 Feb 2021 11:59:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90DFF395041B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390376; bh=ZWD4OytWn/RvcGUGbrq4HHkHKaB8vQdFBNEIlxfdmSw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=j2zCeIhnWQgViF239FGIyPJjFGHHgaXEH9uuGG4QHwuha96KVFNQ9aQAfsCkvg5an h+xSBTN6ZY11k7jGElOoDm4K7h+mx1nw0jGk/60OZu2+ymD8oX9uu6GMaCZSrhzTGU DdDIY+gVRo1zf3MyCcaP+F4WobSr9+akcjF1WbGk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2040.outbound.protection.outlook.com [40.107.21.40]) by sourceware.org (Postfix) with ESMTPS id 7B805386EC5D for ; Mon, 15 Feb 2021 11:59:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B805386EC5D Received: from DB8PR09CA0016.eurprd09.prod.outlook.com (2603:10a6:10:a0::29) by DB8PR08MB5050.eurprd08.prod.outlook.com (2603:10a6:10:e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 11:59:31 +0000 Received: from DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:a0:cafe::b9) by DB8PR09CA0016.outlook.office365.com (2603:10a6:10:a0::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 11:59:31 +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 DB5EUR03FT018.mail.protection.outlook.com (10.152.20.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:59:30 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Mon, 15 Feb 2021 11:59:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a8992fe480e0b19f X-CR-MTA-TID: 64aa7808 Received: from 5f175ec9ff45.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6A859025-1E0A-4566-B295-FD1DAA0B7699.1; Mon, 15 Feb 2021 11:59:20 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5f175ec9ff45.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 11:59:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ald6vPpDx+kMBWwElMHVo3CklwXZ5C6gGmMyKYW3k2yuSJXX2pRmjN4ONf4m2GeD2YAWSwZ8oNwY7/OSpCYmTmdt/bJfzLeH6JCUWIyhfBc5ZmraUx8MFuUuNBMjue0t7tCVGdnd+LasrrCoLvZZKTaHxLy8FzAgkeNZdPQOZ4qGR8QpKW5pbn1TV7+NSM1g35R03k59ZOq1WBfGaVE7O2MqHhwcfO/pe9jTnynSLaT4lDyrnXG9K0Gjr6S8QjKVLHa1uAUPPL4eeK2+lQn6zxYtPQsnhKMa35U0ubjF1I09OvVFs0Zn0dIcSdg8j9fxqc5VytYETsCvjLbmg2/Odg== 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=ZWD4OytWn/RvcGUGbrq4HHkHKaB8vQdFBNEIlxfdmSw=; b=C3asvDfeK5X3g5nS9RJuJwZqtFYXoSc6d8rxiyG5BdukRI322yY2mT3aA9OMOluDqB1ZK84GZYTEkf8LK+BJiU+E9gdhgdl9Jw/0jZKApmIoC6AfMDSmK1E1OvUMUJqr096nkrpjRxLa7RNtJekNhZGuQ6ul+8500syDMJwEIcX8IlF0PbPejFyLVYskmFo6yvcoxq5eO82p4IZzgwqX9RA8OcOV1ulEwTJWkaaCFuU9hGEIsCOjdIywg0s8mgudNDm0rIeLesH/Ynd9MgbjxRQQIdxPSYt5KPaqT+CrkxyC1B+d6LpTBkF/t/Z/el2jsdQfNdei3ffse05AasUPjw== 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 PAXPR08MB6558.eurprd08.prod.outlook.com (2603:10a6:102:151::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 11:59:18 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 11:59:18 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 04/15] Add a DTV setup test [BZ #27136] Date: Mon, 15 Feb 2021 11:59:12 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO4P123CA0284.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::19) 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.49) by LO4P123CA0284.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.39 via Frontend Transport; Mon, 15 Feb 2021 11:59:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e2dcffde-797f-4f9d-ed86-08d8d1a9272c X-MS-TrafficTypeDiagnostic: PAXPR08MB6558:|DB8PR08MB5050: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 8ynQLcQMcZl890NQPrGrszu4Yo3n2RMTf5NpD3qh3FRxfATRu48n62qer4meG2g+KhnrXmSgB925cCCfW3y3zios/Q9mkS8kY51sW1JpWUC75I0QlStuAWHpInTtdOcwpOg2se3MTCJ5DerirfbzGpDIqRsz45F6xEeFpOENLIhHjjtJKe5ifYfrIH9mCOrIs4U/lDt7yhugbnujJJ7AbeZv/BKgNPvV5RCM9Bpe9qH96wgkI8e4aCDiprX5VWigAaZAyCgcRS/ZxFpVVKQyK25nAR0O8LnznegXy5RIblUy2oIvLU9hKkGrfBH+h4+AyUZvPhpec9O2KkY7lifQf4Ovt+jqd8yUjm170DBPmdDCzdI4VB6pkuFE4NGL8M9jlO9whbEqHB7zDJBHMuE7QQSSjnEYW86UGb864QZhtiojZUg97v66f2frA2x7IoRAGF7tE/E+TY9gw2H7mfnnq41VgzUUCxWYx4GaKUxnvwOzBLZkLTk5wOKK0IRJsG6RBXE+Apcbg9OoPu9yRfqrmMR929yoUrxKdIZ++tuI/+wJdUCqH0mVs6xltT0jR6sEqaXR55/MSBQPrFEo49Qbj02ZDwivP7Ng+gIQHZZRzNdO7eQzmQXLoMB7M8HBzbU4SP2vS5xQrjjywNzso8myVt+XKCNbsB2jfPntMEQ3aOpQzyJocz8If+E043r80uc5 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)(136003)(376002)(39850400004)(396003)(346002)(366004)(956004)(2616005)(66556008)(44832011)(6916009)(66476007)(6486002)(16526019)(66946007)(478600001)(36756003)(186003)(2906002)(5660300002)(26005)(6666004)(86362001)(6506007)(6512007)(69590400012)(83380400001)(8676002)(52116002)(316002)(8936002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Nc1aCMhdzJhihr3UKl1V1u9KETlHmzedSvreO+ED1+P45fQTgxcXFkw147jvG+NxduBZ55LPzNzVrtZmD+qa6+KX+jyml3IZRBBv8rn7Nj+YZ9OcBWJmLLQT2+24xT2iLcTcUqKThj4rLBMQ41bsiQylYnjMIVrHIEwK7LH7UU//zzVSleAdPczuzCenpbKpOdBwODaJaT5P0wPDZ7/sJFTwwZRYw1DAy0HrxhJnuxdyc/h2HcGeMF5PZFeZUnkoXrq9qtiQ2/KwO8waqEZfoI1TSO3lkXCbM78Z2YkpM+xosEcNeCFwSAiH42wldrExs33wYthEM1D1/vVEbRm/15BrW+gNxQ/ADNvSvvT5afhaTY8YhhT9S8BL5SpRbNK9d9RZ2dkEatcx/OOi44cmQmXQkVLRMoB5DoCwWF9BSUfVA4oBDhE1xfgrBECJJXDZyZdNQ3T2mSpQ4QAUA0jN4/xI0NuxknmdMtK0lgOVsWsDmZIqZIP2gTCY4D67CRA7u82rr0askog+lQV26lrM2FoyQzxP2tHN0Py4Oqdxkjc8iw2q6pSjMP+QFDqqcjE4Rov3ZfOAM6NSAmHfcfHWCxkDFc9dSoyeIUm/13LuG8qLd5aT0K+huqjOWGQDel+TKm4iLGEJpRCb/jxPBZSTi3U5m+srw/bpfFaMc4SabZ0WByGhAu2SmVVm8om50kusE5c/u/GdAow9ZS9lyZWP6H2N37LzH69UkjdN199QrFVnzztSpzoGMnZ2wlQqsISUTVYzw63P+7JmSDuZDIhIVu+D136cpx4jvaasn38QrmPilPhgcdA4Q+HtqeCZxN6REctP0jbbC1QFFzQO0DC1UQbjc4uPc7qJUvl1RaQwSVeBAB4Qpml8EOY4Hd3TBHdD92OxClx7x0OZzAE08cI0hjyGCSTbvCvPqdaqJ9M5jvXt5WMqsMVUI3/GxrQbi214s9FCFPvVsaKt8TS1ACTAZRobr4xSPNt8eQ3e+XSqjirI0EzIJ8UeX6od9uy18+Ignx+qp0Qn8Dg20q79lwOmZu3//W1glQTWIR+GjuJdMl4e7FaZs0kabVu6wLCR5mnp6wheLpnQLbTFliNAWBd3mtmEgoxlm2jZl6wjRKr4JDbddhj6rG70jU1VEyAC2q897fL671YGzOUH0tPt/m6h2tY6tR/njkMq9EChB1v47oZv7MFEb/JSsD2CUwxDJklX/TLK7sfBhxS9jiQ3Cx+xeUY8t/eJ24W0aevVRTqYSvCUn+uHkbeRHYJUTTl4n+exqTWMMdlYyeWc7Ym85NBNhFUwQS4yPyysWIMLwgzYIvXNKK5ECfM8vr2yos7i5d79 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6558 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: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 504a2157-872e-407b-1b53-08d8d1a91fda X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+2bQRvmhDQabgDAgcEkVddrcoAv6d+jhft9JM21d8hJHRapJshFcSg8pyJXr9yuNzjmtWUfAAP+Gy3IkQvioDcbLROzDs+wvV6DfcHkqWEjrTeUV5KyzEJ5OwFnj3BW6LDFdmWSBaDlqpRPSoOh88ott4ou5PRiqhyTnJIsXT8Kv6Rg4VrW/+7Wj8i7VfZb3D0R47lpCp/ypiBHgZxKfiJJO1pdSVDejTEqp24eOe7LIyFmRzuyXgmdpkjZTNh5JON0rbHPCLIDX3DfXEhHj2JyV9PMqNDpZas9XxBidzYDIEzax0FQX6zgqe+VgkKOj/xiJenOwEFh7kZV/TSQANUhfV4LEf0ZHMburdyCqI5IU1nLEkRqI3REu0Y33aLTdHvCGesZgB2MMvNZLgIljT1aFKsk2rAr2kWyz9QB8zO7F4ORx2rLEtJvFeHDSBVIPCm20ZgJo9LQ/jZE1erwDUVqABJ7D8QhhxMGv6Gip/vWB4CsWUKgsNd70Swhkskh4vO/O1SV6CdUJ8JY8fVsGa0KnsgWBlZZ6kTa7P4gMCxJrW0LXR5Zq5JWxVBKi9vL2o6vwHm6jBYU8OC+WjA3kJttmlScpUMZMYgVXZXbedAtDZLGxLHgFboaXoDssicXhEi3j7qG8YG7+6+yZy+lB0YFz40C0/IcoHv2S/yhbpOZ40kZB1ScKB7hzREZjLfY1+rxBuekJoHZ0njaCFOMrz3kw7lYSAlUG1UOWqD7IBe+3BpsbevJ1s+we+zY7YiclSuujB3QFgh0z7iJ/Q6WJOUjf3lP48S2rUekoahPlOg= 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)(39850400004)(346002)(396003)(136003)(376002)(36840700001)(46966006)(70206006)(956004)(2616005)(70586007)(478600001)(6666004)(36756003)(47076005)(2906002)(8676002)(44832011)(83380400001)(186003)(6916009)(16526019)(36860700001)(26005)(6506007)(8936002)(336012)(356005)(82310400003)(82740400003)(69590400012)(6512007)(6486002)(5660300002)(316002)(81166007)(86362001)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 11:59:30.9789 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2dcffde-797f-4f9d-ed86-08d8d1a9272c 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: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5050 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The test relies on reusing slotinfo entries after dlclose which can result in non-monotonic increasing generation counters in the slotinfo list. It can trigger bug 27136. The test requires large number of modules with TLS so the modules of tst-tls7 are used instead of duplicating them. --- nptl/Makefile | 10 ++++- nptl/tst-tls8.c | 96 ++++++++++++++++++++++++++++++++++++++++++ nptl/tst-tls8mod-bad.c | 2 + 3 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 nptl/tst-tls8.c create mode 100644 nptl/tst-tls8mod-bad.c diff --git a/nptl/Makefile b/nptl/Makefile index 208629876d..a11b598efd 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -354,7 +354,7 @@ LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4 ifeq ($(build-shared),yes) -tests += tst-compat-forwarder tst-audit-threads +tests += tst-compat-forwarder tst-audit-threads tst-tls8 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1 tst-tls7 ifeq ($(have-z-execstack),yes) tests += tst-execstack @@ -371,7 +371,7 @@ modules-names = tst-tls3mod \ tst-execstack-mod \ tst-compat-forwarder-mod tst-audit-threads-mod1 \ tst-audit-threads-mod2 \ - tst-tls7mod tst-tls7mod-dep + tst-tls7mod tst-tls7mod-dep tst-tls8mod-bad extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \ tst-cleanup4aux.o tst-cleanupx4aux.o $(tst-tls7mod-deps) test-extras += tst-cleanup4aux tst-cleanupx4aux @@ -528,6 +528,12 @@ $(objpfx)tst-tls7mod.so: $(tst-tls7mod-deps:%=$(objpfx)%) $(tst-tls7mod-deps:%=$(objpfx)%): $(objpfx)tst-tls7mod-dep.so cp -f $< $@ +# Reuse tst-tls7mod-dep*.so. +tst-tls8mod-bad.so-no-z-defs = yes +$(objpfx)tst-tls8: $(libdl) $(shared-thread-library) +$(objpfx)tst-tls8.out: $(objpfx)tst-tls8mod-bad.so \ + $(tst-tls7mod-deps:%=$(objpfx)%) + $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library) ifeq (yes,$(build-shared)) diff --git a/nptl/tst-tls8.c b/nptl/tst-tls8.c new file mode 100644 index 0000000000..be7b64c9be --- /dev/null +++ b/nptl/tst-tls8.c @@ -0,0 +1,96 @@ +/* Test dtv setup if entries don't have monoton increasing generation. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include + +#define NMOD 100 +static void *mod[NMOD]; + +static void +load_fail (void) +{ + /* Expected to fail because of a missing symbol. */ + void *m = dlopen ("tst-tls8mod-bad.so", RTLD_NOW); + if (m != NULL) + FAIL_EXIT1 ("dlopen of tst-tls8mod-bad.so succeeded\n"); +} + +static void +load_mod (int i) +{ + char buf[100]; + sprintf (buf, "tst-tls7mod-dep-%02d.so", i); + mod[i] = xdlopen (buf, RTLD_LAZY); +} + +static void +unload_mod (int i) +{ + if (mod[i]) + xdlclose (mod[i]); + mod[i] = 0; +} + +static void +access (int i) +{ + dlerror (); + int *p = dlsym (mod[i], "x"); + printf ("mod[%d]: &x = %p\n", i, p); + if (p == NULL) + FAIL_EXIT1 ("dlsym failed: %s\n", dlerror ()); + ++*p; +} + +static void * +start (void *a) +{ + for (int i = 0; i < NMOD; i++) + if (mod[i]) + access (i); + return 0; +} + +static int +do_test (void) +{ + int i; + + for (i = 0; i < NMOD; i++) + { + load_mod (i); + /* Bump the generation of mod[0] without using new dtv slot. */ + unload_mod (0); + load_fail (); /* Ensure GL(dl_tls_dtv_gaps) is true: see bug 27135. */ + load_mod (0); + /* Access TLS in all loaded modules. */ + pthread_t t = xpthread_create (0, start, 0); + xpthread_join (t); + } + for (i = 0; i < NMOD; i++) + unload_mod (i); + return 0; +} + +#include diff --git a/nptl/tst-tls8mod-bad.c b/nptl/tst-tls8mod-bad.c new file mode 100644 index 0000000000..c1aed8ea7d --- /dev/null +++ b/nptl/tst-tls8mod-bad.c @@ -0,0 +1,2 @@ +void missing_symbol (void); +void f (void) {missing_symbol ();} From patchwork Mon Feb 15 11:59:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42034 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CAC93950412; Mon, 15 Feb 2021 11:59:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CAC93950412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390388; bh=8cySlGeUogmQgceeYzLVaau8ovUXBGHCb7IiR18gIb4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=UiT6npP/K2BlJGYOii3RPBBHQWelieekIqGCVkYePKaezLs4iNsEj/Z3i8yM4vkNQ p8SkRbXx16n1SFxSUIqDzD+g/mEBS9gYZbQXzTiLs9HkA1lx8a/SfuTM4tiZZ5pdc+ OQZPq6zJ9+4/F65jSVvgaCmWK5uM17ZzYli4jYM0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id EF753394EC1E for ; Mon, 15 Feb 2021 11:59:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EF753394EC1E Received: from AM6PR08CA0015.eurprd08.prod.outlook.com (2603:10a6:20b:b2::27) by PAXPR08MB6525.eurprd08.prod.outlook.com (2603:10a6:102:154::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 11:59:43 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::a6) by AM6PR08CA0015.outlook.office365.com (2603:10a6:20b:b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 11:59:43 +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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 11:59:43 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Mon, 15 Feb 2021 11:59:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: da235128422942ee X-CR-MTA-TID: 64aa7808 Received: from 74eede90ae10.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A4FA2DF3-A293-4685-B19D-5320AA80AFD5.1; Mon, 15 Feb 2021 11:59:37 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 74eede90ae10.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 11:59:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oWT5K7BQ+ZNN6rX7pmCfwxPtnbGD3ofWLU9RsnKHRAREQwvpK1lJIiPB7d3aUIw4NIefnWjT7JXos5DmvpYIG/2HZe+SmxVoE8ODuBhvyAToVKNkG85ysR2bqPAv0/cqKuDBInM0lozeQXOw/+lke+qx6MJbAFqoHAJ5HNfDbLCMeWLBhdqxBrMPweYFQRVjsJ55v7uKqye+g8HOUJK18FT2ykNzKbFljJZd5G4Q7wP6ke3At+O58Y6f88ehKZ0/8PmQHsHXL/rmKwT2SXQEBrVfITc7azvwFpTnF0gR/Grrnzq+bBnJERiQqUNyqiAQCUUY0bbYNYntPgDt3qTKuA== 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=8cySlGeUogmQgceeYzLVaau8ovUXBGHCb7IiR18gIb4=; b=NcN5w2AQjIC2kWjUoU7OMoi2y4WcrdQoU8DnlQxSheXj2A0IaLrVqqEIrNYJWhiccjVc5cLHcA/brBgQJ46RODxFFLTppJcRYVm6J9nHbikZ/AfQ4MAV1IwVqMJgUhTljxLwiMuTJ5Yh4PP2uTUwPoR+3X3W7hlikjMPmb10Yb5gN1Ms/j2BcOtkse4prEM+/bSrmib/Ac950weIkO1ZPkGsC7KUfM0K+v0DfWF9FhwlWNG4JU+K7+Gc0ghkaDlnGtG8RT6a0gR71+JQOh0X3tltcDEVNSpgglhl4oPWWFOeVhUxuBiaqcM3lxRFwvnHhLF3Qkv6FipD6cHqc8Nt7g== 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 PAXPR08MB6558.eurprd08.prod.outlook.com (2603:10a6:102:151::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 11:59:36 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 11:59:36 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 05/15] elf: Fix a DTV setup issue [BZ #27136] Date: Mon, 15 Feb 2021 11:59:29 +0000 Message-Id: <49bb4560b2afb4174c7086e24b0fb7be9d73ab5d.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P123CA0106.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::21) 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.49) by LO2P123CA0106.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 11:59:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 784363bb-c512-404f-1cc3-08d8d1a92e89 X-MS-TrafficTypeDiagnostic: PAXPR08MB6558:|PAXPR08MB6525: 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: YjgbTX/w7/fczt/YxT87ApF7TFY7fGgt69pCmsq4JkMyiwllH3FUEnoVvga3tEi4GFQ94YUk1r8MESu3QCZ+FlPjdUQBmlDu+4iYsfGXZqiQIgbbhSA7q8ufgC3pv1Tho14cnwu792Qp/pBq1eY/Fn/qeHJE/zTtQl5TBsg7Y7alUcLfxYJOTVEcdTND3DoWPhXtO9lFZppaQfCCHUa+1nIZg1o8h+R7g6+3cPATc6e2NKrWIObmxN8KzBtx9W4xlNNOmkFrNBElcRKATOgDHbyWmJq86+NEnwLMkruBdOwc/ww+I60K834g0erLnrSikFvSIY/L5YqtokMfeCLXERLgYRx0mmiKmP0Lk9U1OQ5+GqoJa+ECAsPVwt8jBQGadh4Vw2yyE25QsStKal7cyP8JdOGeKF4R5tvmocO3mVGN30282szpqTXRQrHEeAGb9peBgtXryJIZcHyof6oYf+Qidwc9fT5UN/y/oVgyMoHW8BskzS2pHOrF8c4pbOCJNTg/fpQyQiI/p1pMI/aVo5cueUkJ+ASVb8cVU9H5KKaSkvP/dFC/CnzpyprH7D3KpZIAVv6R5X4G4QlO1U1aIA== 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)(136003)(376002)(39850400004)(396003)(346002)(366004)(956004)(2616005)(66556008)(44832011)(6916009)(66476007)(6486002)(16526019)(66946007)(478600001)(36756003)(186003)(2906002)(4744005)(5660300002)(26005)(6666004)(86362001)(6506007)(6512007)(69590400012)(83380400001)(8676002)(52116002)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: w4fpcXmKFtIhFn6jZHS73OKpeicrfglcVmSJhzxMqNvYPPgC/gQT+2fPq+NhZI3MtggX/uE/mqxmh6TGy1rbpROhrnw6xV/6dc6VAWAo+JUWpJPuqcgqkrUR5ABEK5mRFSrqySKNqyCu/zRBkZw8ELHaRVUuA2pQWQMG/sT/lcn0Y7Z5i4uIWf3phdiZ0tEv+rJohM05Cs0K3TP6RKrmkO76BjvU8uxokbBoGsg8xh28OzvL6sEvRPZB3AJYfcbxCIEkyllPV9g7Bf7NILDemfBjU4kpfKoi+DfuA5JcoRHFyze35P7oxBuW73F46elpGLaqNfoy1SlXlpyms6fPYUyVqNzlIs0kN5Qbg9AFYDXG+ANymJJ/joApXqkAXswK+RctX4I9qlxpIIsa/i6anB+OAx5fmrwQxuSFX4xw1QJCeF7TSvTsMZimyzXq7xcIUvq5xEbTrmavhGdZeb9ZmCHuy7dG0RbNyiDhnZxxOsyYY0LYgImSQsKIuv6GE8h2X+n3JnICZ/TeikexTt/h4HzKxpVKqD5HRbGec+Lxt5x+R/JtSAjqz3aZQp1XYC+sAN6bYMtzT7rr0u964nDKFSNffF1krjQhgQr60Lv5W0i4XReJTd+wiIU+FX520vIPZw35koIbnH7zpteW4yzSsKVwBzFVYc8cVzzEbXECqiMMljpPylpLaxStfVb3sGpkmL9TDDzFSbQvcCePUmHy5+32vSl0Uvs9S3FjIN7BN5t+4Y/guB5YfRIP8g1yoE5SMyzujlIHrcijxz6BP6bNKhNbKFrvG6vcUTziMvJVrdl5P9hBx8z41CxTAoi1ZzkG4m7t7ZvmksYgzlwNjRj/3/PVuMYfmYdJQImoDUlQNKfA3qNRqCissqUaOaW2BKk3iARo9KNM7YxUO0c8ESb2G8mWg/E8soaA/HbZuh7CeSE/AOq0Gw1+hW/zy7aTly61gNlMczL4Nx6XMprbfvksILuwZgmPl2HyJjbu7l3nZnVt+QtTo7iJ7n04W8HRflMPJ37NDaknqANt8sNKW3sWQjFbsWn7RhgkH55+XHpzVqbNEx8SZdfc1mLn0eaIKg+9zkJBt5W8wYwDGGznGESbc+iMht1SjyAW1m2muV8sGkyCz4rZ/YP8HMaTqiNYR3bp335wkNZoj4Drc125VEhlVVZC6XA4LBflzGodEDqy8Er/S+LuNbfM+JGU821qlBQ/okD7CbFMSmoMMZ55lNjChwyZueZaCCryHtZxacVODdwlhzJB7irdeGcpcgmxDH54dE8W5GAy0fhfEZK4AM5BFbc/JTpIxM8oTsOfcnrnGoHi1gi3IoWQtkzBRA4HYmMz X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6558 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bf6d1d75-c175-43f5-b866-08d8d1a92a0a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qkef7qjX3K8mB1ICUbfZQnRWdBqeaGCP1mf9ZeF1XRUoMRTQAw99l6SsbspFWP2BP3v9oTPxCoZXTfcutZQAovoJvZRDOjnDhgk91Zrw/cueXVYfm86/3HtrPzGS+381wKSM5G6l/PBSE3Mr0MJ/bWD6CtHw8BWNJaZ1SOBd6QWnxeF/k6YPH3tolPeqBrXyXun4dVS4hTcc23vebILRqWLsYze04jueG2bI7fpi9aR9JPmBZsTAA4sn0IOacR1mb3Zb/VfzqeOytb+bw3efswc0MONJqp6gZ/HXT2g5QS9I7CDDvCRXWfXsAPMnYw1KsE1MhJMhyoF/eBeHwBi6Dv4AowRRvHtgVQJxInfGhd1VY0tsLZQhtlQfUCgCp7urhOQDXTAtYrghXpVmpS4CoSIAEh4yOeh2rlUkSwlMTjLd59XaY3ExsOUWm/7zN8XN7oqofl9ERF8mUuYGd28xaOe0colCMsugAkrUp63LBBdWj3QYfoy2KFkwnjp/utlNbvaKxIp+7MPX7Me6ub3APox+b4PlCuNNntn+30gSaItESWo4bXIxVmdnKoRaG9ugV4Eyik3qvMa+EPVH37JOP8QRD/nY5g3C4AT5tw6i10lZqaqrltFfIgEm9EEkxAEYyYwseZZQFnhjr56yvHsQnAiuL3umI/vWvkYQAPZI92w9jWSSjLdK9JbzmxgyDvF2 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)(136003)(376002)(396003)(346002)(39850400004)(46966006)(36840700001)(70586007)(69590400012)(70206006)(81166007)(356005)(8936002)(336012)(83380400001)(186003)(36860700001)(478600001)(956004)(26005)(8676002)(2616005)(36756003)(2906002)(6506007)(82740400003)(16526019)(6512007)(82310400003)(44832011)(47076005)(6666004)(86362001)(4744005)(5660300002)(6916009)(6486002)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 11:59:43.2071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 784363bb-c512-404f-1cc3-08d8d1a92e89 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6525 X-Spam-Status: No, score=-14.2 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The max modid is a valid index in the dtv, it should not be skipped. The bug is observable if the last module has modid == 64 and its generation is same or less than the max generation of the previous modules. Then dtv[0].counter implies dtv[64] is initialized but it isn't. Fixes bug 27136. Reviewed-by: Adhemerval Zanella --- elf/dl-tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/dl-tls.c b/elf/dl-tls.c index dd76829e74..79b93ad91b 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -590,7 +590,7 @@ _dl_allocate_tls_init (void *result) } total += cnt; - if (total >= GL(dl_tls_max_dtv_idx)) + if (total > GL(dl_tls_max_dtv_idx)) break; listp = listp->next; From patchwork Mon Feb 15 11:59:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42035 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 035FA395043D; Mon, 15 Feb 2021 12:00:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 035FA395043D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390458; bh=wEMIeGlH1BROBxLoYkYFFMRujAl6eUUp+uFYrvgpUB4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=S6PpKBQVd2MnAqQfvDcE+I30eLkvPwWf/gYPSTVzPFaHhosgt6SyfO/q+0eLRLXFq 9jvPHm20TrzCPHtCENmY+lVVa97SYYHtmZoHTAjN+Et0nDaUUxt4WmqAoo6B3xV6ZG yW9RtigfvN7GXBTgW6N1JHkMwdUt7O28W3o3qmzI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2041.outbound.protection.outlook.com [40.107.20.41]) by sourceware.org (Postfix) with ESMTPS id 895DF3950433 for ; Mon, 15 Feb 2021 12:00:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 895DF3950433 Received: from AM6PR10CA0094.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::35) by DBBPR08MB4902.eurprd08.prod.outlook.com (2603:10a6:10:db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 12:00:53 +0000 Received: from AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::20) by AM6PR10CA0094.outlook.office365.com (2603:10a6:209:8c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:00:53 +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 AM5EUR03FT052.mail.protection.outlook.com (10.152.17.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:00:53 +0000 Received: ("Tessian outbound 587c3d093005:v71"); Mon, 15 Feb 2021 12:00:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e14dd9e20223431d X-CR-MTA-TID: 64aa7808 Received: from d5675ee776da.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3AC2B46D-3BE6-4A49-B585-4262EBC33871.1; Mon, 15 Feb 2021 12:00:37 +0000 Received: from FRA01-PR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d5675ee776da.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:00:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CCDkXF3fDxtlIZuBov2hlpMNPNYiSRMyHn+mT16HMjCIWrU5P86qgISR4koMrwjv77nKFrhgBflGTrnK8dELPC1AWmr1sX+WXzcD38RjT3Yjf7iSlMSeC1UKBm8I+jKCzqR/HQZduTCqa84WQBDPeEDhxWhuK8QUPet0jFcP+6qa4lB0IYNg4R1PlgNgp5Ksri1J0yHomXLoZo6B2cj70bM8jhT1rp5r2xm5f5Srnftv6ou3iWcD+7me3SH+5qaFbh93Xdwx88EO+ArJwQmGh0QrbDpHrkyEUJiOVN3OhG/Sw1j0ky9X7wnWiLo7VizrNrh7+X5DNOB6URlkWhZHQw== 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=wEMIeGlH1BROBxLoYkYFFMRujAl6eUUp+uFYrvgpUB4=; b=dsHR3wnWU1X1GWKK7DQr87EFSSe8Emdaa0IyaauPvFL8kJwtiVCjuOL5/pdGUZFwt9tMVIiH94J95dkmf6cRQLpbytRj0BRKa+/HQN5bWTIU9Ctm7vMrJg7E3DWGvOuJc7kvrmcrrXZgYtxUIW72+rtaJGT4J2xX7/qprH7KMWGh6mwAYg57F6xkLf5lx6Ov45M1huic3cJMa61THsNeFcJ4GN9Gei7WceEtlBxRFZYtGg+THfZ4sO5mehuVucq83dtuZbaM+Xq18dKKnbwAVysin9eAauIKDUs77oYBVOpwXOXd2WFW4kdV6bV1jc44O1rtYz8pyMWQpL+mXxMUEA== 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 PR2PR08MB4874.eurprd08.prod.outlook.com (2603:10a6:101:1d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38; Mon, 15 Feb 2021 12:00:35 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:00:35 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 06/15] elf: Fix comments and logic in _dl_add_to_slotinfo Date: Mon, 15 Feb 2021 11:59:46 +0000 Message-Id: <068770faf123b7c227f5f1e130812f7976e74cef.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P265CA0333.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::33) 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.49) by LO2P265CA0333.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.36 via Frontend Transport; Mon, 15 Feb 2021 12:00:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 44a70f57-1dcc-463e-070e-08d8d1a95847 X-MS-TrafficTypeDiagnostic: PR2PR08MB4874:|DBBPR08MB4902: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3513;OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: UormEK6iwnCV3njYW41SDmLQS0cwI+k+xBX34gWg35kOlL6s0y7geyNWumfUSuW2eeMd+awCYKhgIJIPTydvCHNynIF36pqDPHFP7wWuJWyT7/3rA6KW3C7oud4JEh3UvLCoPsA611mSnZqpWxmefyS7UcrsHxZgZ7x0CpjoKQqnCIS4S+WZvcTba29NFITtWOYNJFFhUPk6NiZln4KO7/0ne1/SVWU11p+G2Zjh1HMeUjAnms/wS+2stY0H/WSqFGAh7qXV3KpZIyfSEqVvON2ss3TwxpKsI1bGZX4dPdt9L6johTI4HbbFOMNtHJQP3p7dQemdrfTWTOTPI9dq9Dcj7meuBNqSPTYn5ayu5/VS9eyz3SsaYDgfw7ccuhTNiKPjNiqWztsfZXxnC14jK/kohT1LSJraB87j+z0Rz9mcPN6L7g/D3qvGd90bMa9eUDLvE/kX5pdRgooWDpetZPzg58dIm8WKDE7HXCjIY7ipy60uscf4Bc+bCTIfxCf+1DqL8PCnIdUNSWIv7aY6QQZairwY8XPblUTWvPXCKRO4rucpYa88svQOHIBdqeoWlmgfcZhXyLGPVi+CK3Vg8g== 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)(136003)(346002)(366004)(39850400004)(376002)(2616005)(16526019)(6506007)(6486002)(83380400001)(956004)(66946007)(2906002)(26005)(186003)(44832011)(69590400012)(8676002)(6512007)(66476007)(478600001)(5660300002)(52116002)(36756003)(66556008)(6666004)(316002)(6916009)(8936002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uMjrinCyv7le9O5dENz1K9hk87jwHN1thEhoNUoHCcHfDukyNa6u8slxiQKKeH0sQ9mGgIjHrdaZUoG/uP25L3PM/JmfmZZ3V2XP11Gip7PaxENdoqDWwgNHuDYtzJoFptNbeeRhOgh3EW3FPJMftckyu/kHhnS0CN2AqBvgRSwFE65GuzTjagNo+UB+uoNLUMI1jJioQgV27YlLE+zgjXFCZg5k44QZQ13eELvprSl446k3HEAh222nujZzl9yMpWUoYh7IywbHyCgR7iRK+i2bAJQ8NdRCw5QOPcVj+n9stNlo6TkksM+WPev9rzCeeaqVAUd68R65e82m2wBYt3SVWTZwA5xTj27Zv37G1eAtbMHiXVhzqO8IZZ2AxxD09Ph5vNT8ufyTd8NLaIpT1B4CucnWM4byLLJI011B46gQa2zXy+tqVdCiZPy3HSgaouVirbegv4/oItDeRdWbNwkurci7imE6tEHZzmox/ThoayK6ZPZ2SDbOuUC+/h8rJwe2a+TfaHpttR/yAZFQEDdzjW0YfPmgoDtlAyKQj4uhgo2SSi6Cmf4sfwPk0cOUhergowBFTqZlYQNnWvLGfu3/2pq8KIwhqJFrzXThKAvlm2hHr0iJ5Pn3xEDi48HdxZ2drlIz15GdARCV9KVvhcSdcBt1LNPYFogjXOTLvRkSwt+1ROOwrCb4GHT9E+0d4XuQwwpKNOGDMoEz/642EVS4K/a0M77q3H3W5RjohUzRqoh45P8fRbY0OiFdwz9W4nQ7auyu+LGId9FyU2nFfliSyrBfIgy0YKF3UX94VoIxIlRdSWf3tSSwRAzdt2cLSAL6wvQ+NmEz44AaL8WsQAsjnoyXjt2FrzVneHY2Z7V+MRFGTwqmytzWeFc9Ju+X2oUFVSG6euMh2MuZc3bHnlOa7vzphIlPrYiNfNCj944uH+Ku4uXmKGCuhDH7Ni4QwMXXVaqKlyfP5TbB8KB0UBYYR1n/9ZiF6Ty1u2zGF6pTvJyynlVR9jek7vBrs8Zfsrjl7J7rmETwFIfWJSTAMt9A5VU+2e0Ct3zppTk4ktCBVlsSq9E2Vuhs7xXA+OSB1o+HSJMfQrOpejaCBtpWIyVy8doRrDIPOhln5IMhF4m3b+XzwwkbmBlXYHcriP630cX+qEWBF09YNC2JHrdB7ogmmSg9ixzk4q8/AOJ3C/GPsS5MHxjouZABKniLoH8zI35s8s3QUNAMv6yXwyiMxlOv/ieVeKig518hrU3H1G1zt7n90mlQR2q9r4UEdNO8+mfSRyUJ4Z9IvIb6Ut71eEmSjpXDncJFGtxvLYgclAqYXWV5zaaCfrEVY68DLnSB X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4874 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: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4966c90c-7ec2-4c2b-152b-08d8d1a94dbc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K/pkn/of14htd3ApfHwhfqbMEZ80Nt8TyhAn8jX/vRK8Ov3Tm5YXvK4Uuo0R54K1cEmmsCwFmMlmxr1hOdWMfBlEdfA+8MINlrobBqeSai0M14Hc4XjfOShI8rnSgemOsYei3pcb5zXUhJFDzrRkc//QgOSpQgV8W4EC0cyaMDfANuYlsTo1qAJmtoAOec3paZjwm9uYq2OFNvTl9GVJ/sv9IN+amsyrydgovLUVp7iObHa3hCYOo5Kv4P9I9VTGAZxzlTDbWYNdUB5bA8ynH1/Y2Vcc0UCpomuLUdvBzECSXm0pc4A/1XRH7O8rOGr4IUphHJ7yJ1WaoazND5lv0PtyjCkaA4I1afzr3jXF1ZOyTmM5Dwc5crp/+gpkq41Hk9y582MZ8dF0kfyiH0sPOokKKM45aiPzWPStwv1hvFDJ0LnI9qADzD+Jro3I6dCUZT/WYC+hz2OFxjgD1C5vne/f6GCGorCHtFmeesd2oStIZiMDNSodwjbgJEXiH1jWr3VB9/c7ZLXlXRoKx9Mxdh3NVHrIjGV8q+6fA16pT4oqb94IYsrdcIjiSIB52uxKgP7qGpD4o/TwOldbsljJSIRrI0sUu6OVrsmMC/qZe9glHkt2s9ytp1jL9XIfGqP5F0T8GqpJVmHB5VPFFAHXsGDpyop5XcayvL9Gkxn0s9xlpqEvgDaYfrEmg2ekhfGD 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)(136003)(346002)(376002)(396003)(39850400004)(46966006)(36840700001)(336012)(83380400001)(82310400003)(2616005)(2906002)(186003)(8936002)(6506007)(956004)(6916009)(16526019)(26005)(8676002)(86362001)(5660300002)(70586007)(36860700001)(70206006)(36756003)(478600001)(44832011)(6486002)(6666004)(6512007)(316002)(356005)(81166007)(69590400012)(47076005)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:00:53.2923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44a70f57-1dcc-463e-070e-08d8d1a95847 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: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4902 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Szabolcs Nagy Since commit a509eb117fac1d764b15eba64993f4bdb63d7f3c Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112] the generation counter update is not needed in the failure path. --- elf/dl-tls.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 79b93ad91b..24d00c14ef 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -998,16 +998,7 @@ _dl_add_to_slotinfo (struct link_map *l, bool do_add) + TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo)); if (listp == NULL) { - /* We ran out of memory. We will simply fail this - call but don't undo anything we did so far. The - application will crash or be terminated anyway very - soon. */ - - /* We have to do this since some entries in the dtv - slotinfo array might already point to this - generation. */ - ++GL(dl_tls_generation); - + /* We ran out of memory while resizing the dtv slotinfo list. */ _dl_signal_error (ENOMEM, "dlopen", NULL, N_("\ cannot create TLS data structures")); } From patchwork Mon Feb 15 12:00:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42036 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9208D3950439; Mon, 15 Feb 2021 12:01:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9208D3950439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390473; bh=dSbZNESyxN5bmz3Eefvw1+7y07M7zOdH4Heke5QVGhk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Q4js7vTFi5DJnv3tP+tadmDFSC6IUmYAetEXfKBjZH4tG+VO1oOLXI8Kq86AW7JtY b/eb41O+wEvSaCLDUIxGew3B1bMM0nLqeALXaTGE7IjDuNSluWtGJ3bULHD8cPCGV4 +NUe9hbPO6w4ebIdLw/wXzDSgnd7G9uoAk5iJQ6I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2046.outbound.protection.outlook.com [40.107.20.46]) by sourceware.org (Postfix) with ESMTPS id 654773950433 for ; Mon, 15 Feb 2021 12:01:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 654773950433 Received: from AM6P191CA0066.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::43) by AM8PR08MB5731.eurprd08.prod.outlook.com (2603:10a6:20b:1c7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25; Mon, 15 Feb 2021 12:01:06 +0000 Received: from VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::10) by AM6P191CA0066.outlook.office365.com (2603:10a6:209:7f::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 12:01:04 +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 VE1EUR03FT019.mail.protection.outlook.com (10.152.18.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:01:04 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 15 Feb 2021 12:01:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b8dfb3aebd67b90c X-CR-MTA-TID: 64aa7808 Received: from ec21e88e4633.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B43AEA49-180F-47D9-BF52-F5DC653A8B5F.1; Mon, 15 Feb 2021 12:00:54 +0000 Received: from FRA01-PR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ec21e88e4633.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:00:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IB8N0bqPVeH+qVtmjpZfwOg1n0XqCtdOTLnr1bpDrNVl7V20zXSgMXG72BHISbPBpNjGeNPdddF65rfji0sJ2goua74HTI5PITd5yi2RuNeK7kXgIlcSo0hY8kJHaJ9ZVbqri4QIfyZbQUtGbW+orlZ0Tl7ILD6yQPR7TAtZOGbW86szZeK5LCPFxx4r+trqFYQ8Oqz7dG0oMdgabGMn9Z/YF6A7lAlCqUDAsKCzpxepy4N4P0BkcFJq1lML2+8w4LaBQv/JqCWIFVKOkvUTDOILZsI7KgROPC5yoauUa6FctxO5bAVTbrsuJb5X0cAbg0qHU85HmE2z2ymqc740VQ== 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=dSbZNESyxN5bmz3Eefvw1+7y07M7zOdH4Heke5QVGhk=; b=L6oLkjZgvZVaoFgct9M/WhbRm9Z6em+oPk4/KJ/53n3CSy54Hl13uYYOR9C+9+IkZLqNSmvan2khqC9JWS70s0DOYjoIrJdz2SmCk1uGnWoXVO+nsGXTNcNrv9FDaYaM1ojy3eSlLaDm78glZWDXhWDNNq7ZnsUwBlFhUZNrHl9rLJdk3fIBpSzdVloeypzFecjno/vaJlODA88ee3wBrVH3stCkgefBRfDWX8CW/HEyoIskzyM4VZOyodMT5EtAjn209ollmW5Ei+luVDwBHWDKjoAVDhyIm2//yDuI2d+6TQ9az6UIgpTj/1ruj4q0UzCmnwXm/Nao1d/ONPLNjA== 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 PR2PR08MB4874.eurprd08.prod.outlook.com (2603:10a6:101:1d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38; Mon, 15 Feb 2021 12:00:53 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:00:53 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 07/15] elf: Refactor _dl_update_slotinfo to avoid use after free Date: Mon, 15 Feb 2021 12:00:47 +0000 Message-Id: <3ecdb956cbf6d1b46e36311ffe7f491ce186cdbc.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P265CA0296.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::20) 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.49) by LO2P265CA0296.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 12:00:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1eb54b86-9043-4829-1620-08d8d1a95f1c X-MS-TrafficTypeDiagnostic: PR2PR08MB4874:|AM8PR08MB5731: 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: VgYv8Cf0DZt28LCZZJtOWh0MKNdi68dpwCyQ8Kvqaa9c1ikgE32zqyX9iZgHdTUXeMdyB8S2STzdNYCdtgc+RKRfaAwBSzRokEoG1+CaANqUVBTtt46y8M71tstzOIOCCS/ODh9lFf6fTk+U1UXeX8CYGF2gYSlohXO1sU6LQ0W5aluIyzQtPX3P5aOS5RfD4eomjEnWOnDWpKMvVVupAPuopL3OnZUAbAvt58RySkUPD2PgHEllvfClOminQgY20lOK8H7E0c3eMBIqpjs1g9lTAPZ5FIgu79kT3kgL5pHxyRugK8pYKU2ete9GFZe9pDgx6nzxUVgjSSwie4XDaOGSzIWcrJSVAQh/saawXWBfp3Dg7zyE0gtdJBWQlaIfpgbyScbtLnCMzui+KA8uGsV0EwjuaqKssPK/ixsaUv/uNVvFSk5V19nizvBSqoPPG1g9gUrrWOGFnNkeLVaPfKypJ4vLVBFrsbHVhDUQw1zIoE9pYXmyL5I5SLhf2+qlnZ5Xv5XJ3uMPvvunhZzs+SzAFDiTNkGrRXbVS0987QcaX6sqJdyHNFD9/1hyeEw50aqeeIr63R9mNspS58czjg== 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)(136003)(346002)(366004)(39850400004)(376002)(2616005)(16526019)(6506007)(6486002)(83380400001)(956004)(66946007)(2906002)(26005)(186003)(44832011)(69590400012)(8676002)(6512007)(66476007)(478600001)(5660300002)(52116002)(36756003)(66556008)(6666004)(316002)(6916009)(8936002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WJopnhshQa7Nk+xQ8UVURrLdsl2xe21N2RI4Vtybf+10seALKehJncA6I0u/488iTNd1hxM0uN24x09MMtHa4dxmbzqUdkeOiKtCcSoIzwUMez134zyVrrRdHATYhhL7EDfFmEbNCkI/AeSATpnHWTxy+NSK+rE71Mg04rI1jH8xN1cWYvrT+VEiBQPQQxz6TFpBHPFIXt2QkEFMGkUtUeD+xn2+0YBURgQU/2uIIe2TyKEPxTA7gp/GcIhNLYS5ldTcQQA2XxgKuBoDiHIe1sbW/uTzGT9gF/bhVBS8UeQPxKyJgfgm+c8gVCxF+QfHopTR9vjd3/4DXOyDSTeapE9mLkjnc/RmPa0rhmfqYfTF6DJZyZB5qLrnLNq4BEdNYHNySFf5iFV4B7JOuIGRA4EFWqoFnpn2ydtbwE3rp1ODAkC3NqMqNvJA66eH5dhObmlW4Yosaef3/ONUKQ7Y8MyczJuSORg4X+hPn+nZ0K+Pq+5BMNODsGCiEIWWQDXw3KhK4ebBDQQ75CCj/TmJTO9puGn2Vay25AfKGbRX5al+Gc59JhggZ0Qa5ZX7Cy2T7AATWy5aWG5/JYNg+8VY9PgYDMvcvLc+ErvUzAEbdR5GxsU5zecZnjh5aHbkn5jUf81SwDFgkXSWOVqYmfy/Ivt7n7TWNM8IAf189lljGs2DMSpJaOrQUgVraw2oLTLcBn5OkOtOQjnisJ998VsdOxbA28u58QX+jLO72xwjHiKF3sOuZN+9t7z+gGUDnIdu6lFMUCyQZYjczymm7k1ZjdGX5vVrENmFfhHqQyIKpfUbawYODeMd1eywZIdCbK74ANwypUkyHiiWzeSQy34CJQYOiTTUAMlDJ31Qk0sgSWOuOuFUNLjsdayFLgi9Wa5IS/SYng2g8Q9u5yPFAWYaJBQmPohAvZJm1iFiwcfm5KEf4vLbCQfGT67I5lSNBGpQFg8lCzPKbw+IoNXK4czdfPpP6zv4L2mj3M4V8tjvbSKpyN/yEozBZSRdkpPMdhf7pOvRbdqxBLQT1YUGTB7dlEUgndZmhaDGEXeGJ6ZvYunOcg+wMhE5jqetyGDG/BKVYdRHJ4NwbXMrqWPNE6fp9VpJdPDvXvYoGhrqlIB1/CJDoG8ovL5G0vkg2ELGl9m3bvrWFE0IOYO23B/PA3jEDb1yEomT+/yYi287fRGL8vpYMPL7qeHu8i5p6uKv7ZuRQesoA6N0O+tRXw46gvnWAK2rKgsdU351k15lUWK20ISvegysnpHR5co5FVFpRGtxZ5z4nY92CD+sLA6xDdGXW986jYLmjkvVp8joCjShq4GDV/YLuJt3+ubI6aEUNnEs X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4874 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: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7fb693e2-e384-440e-97eb-08d8d1a95813 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mb8qCo92pbPAZVFhiVjx1WMBniVS73l3O0OsRd3rkHzyddjBMR1kgHmKmg5C81eI2cIveWOLzomR0rzZ+bb57Ts1TYmOGkvas95ebFeXfwfEbG0wjpmEXejUiiBJ8xBwJ0CrlxyNSQg2bUehgiZSNzo4f64HHNa7MgEl5MjhFF/BsA+lFs5uVhqKCBChY6iJXiNkGiLj+or7/c/7mvBkCXoiWVOLK5NECm6RvSkFZpfoXK5/DlCDeI2VXnrv0CfWHeo/CoX7vQ8K2gWmx2udNUfRN0HV6mX8F9Xbp2kxyB/D4WhvaCpVWqG0S9MWWVHisK+OfTU06mohobf/GQ+2zwxl+H00rCFVA6F16NGmp6CeCa02+rM6sicEZLPESWtFQiP9C9E496cYe6tCKE3hmT+Gm6RxQmRCyUClToGif8X3+rAfGTMqEjH4JvMp8MjJrAsTcgNwcqw+rl9+9stNJDgSB4+uAyDfrohSbGeOFocGKc2g5waotgNzWrvgqFr1JsjXXXfTvnxotRElzc2uUb6WBaMxryC3siHcrJmU4LgV7gh6Ulfd6ZxZZ1rRwt6Qf+g4sy6P4fAPm/e8W2H1ixi4wM1auSh4bmZssJ87BdIjD0tZZnNaWjJcQTjdz1OaxJD3ppYHEIRyiKSMzdPb77IuReZXu+7X1fm7elme0+I5HE4yqaCYqw+svLQtn91X 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)(346002)(136003)(39850400004)(396003)(46966006)(36840700001)(2616005)(336012)(186003)(26005)(83380400001)(956004)(6486002)(6506007)(16526019)(44832011)(36756003)(316002)(8936002)(86362001)(6666004)(36860700001)(82310400003)(69590400012)(8676002)(356005)(5660300002)(82740400003)(81166007)(2906002)(6916009)(47076005)(478600001)(70206006)(6512007)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:01:04.6956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1eb54b86-9043-4829-1620-08d8d1a95f1c 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: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5731 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" map is not valid to access here because it can be freed by a concurrent dlclose, so don't check the modid. The map == 0 and map != 0 code paths can be shared (avoiding the dtv resize in case of map == 0 is just an optimization: larger dtv than necessary would be fine too). Reviewed-by: Adhemerval Zanella --- elf/dl-tls.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 24d00c14ef..f8b32b3ecb 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -743,6 +743,8 @@ _dl_update_slotinfo (unsigned long int req_modid) { for (size_t cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt) { + size_t modid = total + cnt; + size_t gen = listp->slotinfo[cnt].gen; if (gen > new_gen) @@ -758,25 +760,12 @@ _dl_update_slotinfo (unsigned long int req_modid) /* If there is no map this means the entry is empty. */ struct link_map *map = listp->slotinfo[cnt].map; - if (map == NULL) - { - if (dtv[-1].counter >= total + cnt) - { - /* If this modid was used at some point the memory - might still be allocated. */ - free (dtv[total + cnt].pointer.to_free); - dtv[total + cnt].pointer.val = TLS_DTV_UNALLOCATED; - dtv[total + cnt].pointer.to_free = NULL; - } - - continue; - } - /* Check whether the current dtv array is large enough. */ - size_t modid = map->l_tls_modid; - assert (total + cnt == modid); if (dtv[-1].counter < modid) { + if (map == NULL) + continue; + /* Resize the dtv. */ dtv = _dl_resize_dtv (dtv); From patchwork Mon Feb 15 12:01:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42037 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CAB13951847; Mon, 15 Feb 2021 12:01:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CAB13951847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390488; bh=LaKYoWqKLO5NDHPyszwt0zNEKgRV794+tn5Hd1VfQTg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ChlpN6nxT+HEujSmJket/kCAZElfoIfT4iaX1OQzamOzam1sovmWftrrmdkRXdDQS h9QYidDwqkF8cgNo68bNQxU1CH+XC7SX+R8xjQFE7lVsuHXSOPoKT7ZJpKazGhBqU6 5lWoUGpGrzCQ2BdnnVTqJDi6/BEr3bMPhzZZzP8k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60066.outbound.protection.outlook.com [40.107.6.66]) by sourceware.org (Postfix) with ESMTPS id 4AC073951825 for ; Mon, 15 Feb 2021 12:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4AC073951825 Received: from AM5PR04CA0027.eurprd04.prod.outlook.com (2603:10a6:206:1::40) by VI1PR08MB3792.eurprd08.prod.outlook.com (2603:10a6:803:bf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25; Mon, 15 Feb 2021 12:01:23 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::59) by AM5PR04CA0027.outlook.office365.com (2603:10a6:206:1::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:01:23 +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 AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:01:22 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 15 Feb 2021 12:01:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8a7a57cc342bb582 X-CR-MTA-TID: 64aa7808 Received: from e360f0d04376.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9BBDF676-E178-4854-9D83-2D92A5420DA7.1; Mon, 15 Feb 2021 12:01:12 +0000 Received: from FRA01-MR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e360f0d04376.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:01:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GfAeTdmMZIIspcAb6f6TpCZYDbCGLrXY/vw8NPRPT/UFd3F2Bg6kRsJACvDlIShUCs3HsW//75l8n+VKZVRJK7J65/P1F19khsiHxQUI2Edb3c6AWSwanD+7QIXw6TxulLb/WXlbEOD5mpfPYZaJxGnblfseNJVyoTBqM+jn3sTP1ygixi1vRvRetuMseRRLcEt4mmxKLKC1IAGDlGhocUKaNO/owMFAKoi1okC4NZZQF7HGQhFggMZbSgAZ+K8s2vb6lBK3G4ge+S80PBEfemjTTa/IAwCeioAgdUZiQ1+7KZOZzLaU/GfBysD7HiADXbjOmjCylckpa4VefWNYBw== 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=LaKYoWqKLO5NDHPyszwt0zNEKgRV794+tn5Hd1VfQTg=; b=ipUUCYG9frATpJUmCdjX3aKvx/zSqGXmVRCs4ADavxXh4woIX6dG2KWDk7eJ67uF4nLLoqjjXL1GMS7Pk97hcchl5YhaWPA6dc/ld+4kh+i9esiJ4VoA3i8wy1fG3Ozb0HCbvoTiQM1re/X4FKxW9PHhHCCCLkNs8OS3COkm09PY23gZxcjMsRlrhNZkQAQw88+JmylKNgB0B2jLgHhc0r2PFHDRcNu7iKDDajhT0vYHXCGBq9noXTngYq8g/CsB8AqZIs07z4D3gfcsnAjenB+551cJIh6L6hct5W9CCNJeWJdOVojmC5NpXL4DTZKdjSvdkTqfkt0I0U8khZeQ2Q== 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 PR2PR08MB4809.eurprd08.prod.outlook.com (2603:10a6:101:1a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:01:10 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:01:10 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 08/15] elf: Fix data races in pthread_create and TLS access [BZ #19329] Date: Mon, 15 Feb 2021 12:01:03 +0000 Message-Id: <63e1d0eb071f68e74ba10d4532fb486b5aec8fd7.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO4P123CA0500.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::19) 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.49) by LO4P123CA0500.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 12:01:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b365fecf-e324-4633-c680-08d8d1a969d9 X-MS-TrafficTypeDiagnostic: PR2PR08MB4809:|VI1PR08MB3792: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: MW2f2EsIX6ZXCoD4Fge/+IBBhygcplICPeKWwIP1gwr7zL8dU4hpSNHvYh5kiR12TPfRlYoAkxqlPz2GQhLUD80AvaSywiXCebOTS0TlGRC3BpwxByOSBy1ZWb7phHpk4TQatuCn19Vkq6cxm+CBqI0yVrUyR6Bxr+BL0OKoPKVMDS0fCrtQkD3sdwakD+vl7Wec+oAhOmVU4vgWXJ96Lkr6YsniWLwAPOImTHHWRzANrGPbw2g1nVr8wlS/c464tGt0PExtGDqRbwL5uF9USYzKL4Q/ISqwCVm0QeZh/BE1O4ZF5xsBb7yTYdjIBOrm2UyQBsJLMIBRFVtddE0ZIGN6Q5R6QyBdx9x4UwWMMmDgucMml14mFildH91E2dfbKSrfk2I3JIvZS//O4K/ww5BaJ+n5iapq8l4D5dGs9qKJACt+C8ZaufyYqx8s/0uHlN+Qgm7KnlQNVYrx+8NyH2FP0hOnRL0Dc+NRv1kZV/ieRKLJ8nyMehCBr5d76RDaOTs7BEXXvbfj65wcBjwrKeBPPrsmyBRKUT/hERhwNUITHNxKGQu6hCxOirKDEIBMi06eo2Ud3upKGXL8YqKlTg== 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)(366004)(376002)(346002)(136003)(39850400004)(396003)(8676002)(6486002)(6512007)(478600001)(66556008)(6916009)(2616005)(8936002)(66946007)(66476007)(86362001)(2906002)(69590400012)(6666004)(52116002)(26005)(44832011)(6506007)(956004)(36756003)(83380400001)(186003)(16526019)(5660300002)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eLZVHhhCOc9EisQwKdheTcxZtSX0bIVIOFX8lB/iMXTlyGoj3hLRy1ZyfpgZH7zo94+fvzrkR2DMTcoazJ3+DFg77dVVBfhsCBGKrDduntkes6V4/R8YrEeWkIO70scwxzjWF2nUFGTM6BoFeNzv+NpFth53lIYAz8b1oUPUbfP6uP5OlU0i+R7wlbnIJQ2FKvNA7eBIFEFi9u4BrMb774JKCcYGsxm4YIzPv6xhb9j4xIkK3VGXzWVU5YbZ1cWQZ0517ua9lnd6yFpavEf7GnB8Ncr35ckTOW2IoAcHIMyC3YrPE/fN3g9sS86eh+bijv34hh+XBn1IK4/MGfkC0zS1VK1ksaWtYRdmOG+9wTZramB3o5pxMMIYoRW4lXEThCQXDRAQ42BZpjL6m4me6lTXQ4+WnqPxC0CuzlqSWQ4Xy4D9laxkpxwSqT4yx0WRt/sLbVDQqydzw1bkYOSLUHecI5uzs9LX6iDWfMDheHpHza28LKuaNOgI0OG2LMd5F/BOmLVp0EmFDGyEw8bQVLU+jqJpuuDdh+uymnk7U9xbjLkiwXf2xK59E+czh1vJGlefulzan3cQk9MbBnuhnuCDA/UNG4deziecGFEq/SClxjKGggeTWB7LkNVqEdNzPuYv8qeDPb9OTdWYPokoJySJ2mLx/3HY6hzq2BrHkEUk2IU1dI/deqVhk6OFSGZbAlMAvr4A2JiquHw9oX1aKC4Z9B4tb1GsL5fudCT55p/vM5G15kLwqtj8atDBjTwpOUXfjk6cpaHNSfOvrY8gS5hhv6px1C4Mfcsa+1hcjvTWzVhRiAczUkr7Xle5/QIOWoxR7ZBmbKvOANEbzNsUFWmZmp+itoa4tAQp5MpGzvIItrz3YD/rHC9hou6Vx5n0uC7H2tzn0Lp2F3Z22EeuWgVwzsIPY61XCjWPsI6PlJbyjNuL8Z9muRMfJKpH2kJb7lp6CN64l8U8ZShdImEWOcMf/fN1FsJeR6qPhVWZ3LgjV25uG52QGGlCEPTXQQD4HEw6TCJfkcJaHpAGdZV61g+gJWoIYZsKWBKl4BXjEu6pLz/ianmklJNz0ZMZ+Ise363+lDwY5R3UBQOn5hoKAc8qrmc/tEMmGzX/osHpJNWn/58VYEAhUOnqvdO0/io7E9s5AV8CdL+9a74tDyyRefl9dmCGTXH2n+SwIviB5mGsX2ZsahWZxcH3SNIsnxYDiA0l78su02Oig5DOGyanTjlDPZo1Bgq04lOpFOIrEIKVJb6jLfKV8onz2HQFwGXWB39NGZw9zljJKDoGBh83mzj7kv6TJluKK+wKgtqmsaSDplidAkI77Ycb/uvCopRq X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4809 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: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 93e758bd-46d2-44f9-a656-08d8d1a9620f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5GPmBo2iut0bnlURFcdaddtUwLpwuZfBVurxD5nopclXgz+aIZyqE1ULaV4W4JhSXyNM53RIEfdGAKirFFtxmOoiFeY8WTz87hDKvlahE332Jy1mO/P97SYrPZJkSIcw/75wRKZOguN/IrRM1VpROifiCSnNKwFuukHSJyzpnR9iK01xDsiXYvoux9MrPoTNhPXWpCk5gEbRc2LrqgfvSbPCgzC5RkfDRQUyvbj/rVLl2CEveDZIes9PSd8v6rIeabHQjVezjo0NujA6HD7Kzgeeg3WdZ4NN9u9w0CKoFI/w/uB9zWJ3aqayiCP07+S5LedkBL5S1QLdw8b9Y1T0ANzutvV6BL1spNSKtrwmqbSevaQFkJAWTjRdQuCKxDO1oe08qbc5HVgF78YpGVrnb+ZwHhMKOfOdautYtMIUBoiJUhG0AofPJBal7Q/QV5UheTE//hL2kc2lS4QioJ2oiCur6u/1CU6gnupLgojxpCiDCF8VoveRdso/n/P42LY2RJhzkt21eQriKwWDqEb8Gqq/iBo3wjCgaTGv1OW2R855C2a3lwOZsT1gPS7c1NU7fkAT2Ajzka/R53TurPkzen+zUqkqyddNUzlAxKxuUljB02l7zfrV7/hODusyXmmQNKgyQdkRpWo+ZXeshYdF1k1w6eidH5K3CgNXev6iN4lzZzhMATN1f94i3q7DKC5e 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)(376002)(136003)(39850400004)(396003)(46966006)(36840700001)(36756003)(8936002)(6486002)(16526019)(36860700001)(336012)(2616005)(86362001)(26005)(956004)(6666004)(44832011)(8676002)(2906002)(478600001)(82310400003)(5660300002)(6506007)(82740400003)(186003)(70206006)(83380400001)(6512007)(69590400012)(6916009)(47076005)(81166007)(356005)(70586007)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:01:22.7743 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b365fecf-e324-4633-c680-08d8d1a969d9 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: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3792 X-Spam-Status: No, score=-14.2 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" DTV setup at thread creation (_dl_allocate_tls_init) is changed to take the dlopen lock, GL(dl_load_lock). Avoiding data races here without locks would require design changes: the map that is accessed for static TLS initialization here may be concurrently freed by dlclose. That use after free may be solved by only locking around static TLS setup or by ensuring dlclose does not free modules with static TLS, however currently every link map with TLS has to be accessed at least to see if it needs static TLS. And even if that's solved, still a lot of atomics would be needed to synchronize DTV related globals without a lock. So fix both bug 19329 and bug 27111 with a lock that prevents DTV setup running concurrently with dlopen or dlclose. _dl_update_slotinfo at TLS access still does not use any locks so CONCURRENCY NOTES are added to explain the synchronization. The early exit from the slotinfo walk when max_modid is reached is not strictly necessary, but does not hurt either. An incorrect acquire load was removed from _dl_resize_dtv: it did not synchronize with any release store or fence and synchronization is now handled separately at thread creation and TLS access time. There are still a number of racy read accesses to globals that will be changed to relaxed MO atomics in a followup patch. This should not introduce regressions compared to existing behaviour and avoid cluttering the main part of the fix. Not all TLS access related data races got fixed here: there are additional races at lazy tlsdesc relocations see bug 27137. --- elf/dl-tls.c | 63 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/elf/dl-tls.c b/elf/dl-tls.c index f8b32b3ecb..33c06782b1 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -471,14 +471,11 @@ extern dtv_t _dl_static_dtv[]; #endif static dtv_t * -_dl_resize_dtv (dtv_t *dtv) +_dl_resize_dtv (dtv_t *dtv, size_t max_modid) { /* Resize the dtv. */ dtv_t *newp; - /* Load GL(dl_tls_max_dtv_idx) atomically since it may be written to by - other threads concurrently. */ - size_t newsize - = atomic_load_acquire (&GL(dl_tls_max_dtv_idx)) + DTV_SURPLUS; + size_t newsize = max_modid + DTV_SURPLUS; size_t oldsize = dtv[-1].counter; if (dtv == GL(dl_initial_dtv)) @@ -524,11 +521,14 @@ _dl_allocate_tls_init (void *result) size_t total = 0; size_t maxgen = 0; + /* Protects global dynamic TLS related state. */ + __rtld_lock_lock_recursive (GL(dl_load_lock)); + /* Check if the current dtv is big enough. */ if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) { /* Resize the dtv. */ - dtv = _dl_resize_dtv (dtv); + dtv = _dl_resize_dtv (dtv, GL(dl_tls_max_dtv_idx)); /* Install this new dtv in the thread data structures. */ INSTALL_DTV (result, &dtv[-1]); @@ -596,6 +596,7 @@ _dl_allocate_tls_init (void *result) listp = listp->next; assert (listp != NULL); } + __rtld_lock_unlock_recursive (GL(dl_load_lock)); /* The DTV version is up-to-date now. */ dtv[0].counter = maxgen; @@ -730,12 +731,29 @@ _dl_update_slotinfo (unsigned long int req_modid) if (dtv[0].counter < listp->slotinfo[idx].gen) { - /* The generation counter for the slot is higher than what the - current dtv implements. We have to update the whole dtv but - only those entries with a generation counter <= the one for - the entry we need. */ + /* CONCURRENCY NOTES: + + Here the dtv needs to be updated to new_gen generation count. + + This code may be called during TLS access when GL(dl_load_lock) + is not held. In that case the user code has to synchrnize with + dlopen and dlclose calls of relevant modules. A module m is + relevant if the generation of m <= new_gen and dlclose of m is + synchronized: a memory access here happens after the dlopen and + before the dlclose of relevant modules. The dtv entries for + relevant modules need to be updated, other entries can be + arbitrary. + + This e.g. means that the first part of the slotinfo list can be + accessed race free, but the tail may be concurrently extended. + Similarly relevant slotinfo entries can be read race free, but + other entries are racy. However updating a non-relevant dtv + entry does not affect correctness. For a relevant module m, + max_modid >= modid of m. */ size_t new_gen = listp->slotinfo[idx].gen; size_t total = 0; + size_t max_modid = atomic_load_relaxed (&GL(dl_tls_max_dtv_idx)); + assert (max_modid >= req_modid); /* We have to look through the entire dtv slotinfo list. */ listp = GL(dl_tls_dtv_slotinfo_list); @@ -745,12 +763,14 @@ _dl_update_slotinfo (unsigned long int req_modid) { size_t modid = total + cnt; + /* Later entries are not relevant. */ + if (modid > max_modid) + break; + size_t gen = listp->slotinfo[cnt].gen; if (gen > new_gen) - /* This is a slot for a generation younger than the - one we are handling now. It might be incompletely - set up so ignore it. */ + /* Not relevant. */ continue; /* If the entry is older than the current dtv layout we @@ -767,7 +787,7 @@ _dl_update_slotinfo (unsigned long int req_modid) continue; /* Resize the dtv. */ - dtv = _dl_resize_dtv (dtv); + dtv = _dl_resize_dtv (dtv, max_modid); assert (modid <= dtv[-1].counter); @@ -789,8 +809,17 @@ _dl_update_slotinfo (unsigned long int req_modid) } total += listp->len; + if (total > max_modid) + break; + + /* Synchronize with _dl_add_to_slotinfo. Ideally this would + be consume MO since we only need to order the accesses to + the next node after the read of the address and on most + hardware (other than alpha) a normal load would do that + because of the address dependency. */ + listp = atomic_load_acquire (&listp->next); } - while ((listp = listp->next) != NULL); + while (listp != NULL); /* This will be the new maximum generation counter. */ dtv[0].counter = new_gen; @@ -982,7 +1011,7 @@ _dl_add_to_slotinfo (struct link_map *l, bool do_add) the first slot. */ assert (idx == 0); - listp = prevp->next = (struct dtv_slotinfo_list *) + listp = (struct dtv_slotinfo_list *) malloc (sizeof (struct dtv_slotinfo_list) + TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo)); if (listp == NULL) @@ -996,6 +1025,8 @@ cannot create TLS data structures")); listp->next = NULL; memset (listp->slotinfo, '\0', TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo)); + /* Synchronize with _dl_update_slotinfo. */ + atomic_store_release (&prevp->next, listp); } /* Add the information into the slotinfo data structure. */ From patchwork Mon Feb 15 12:01:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42038 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FCE53951863; Mon, 15 Feb 2021 12:01:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FCE53951863 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390512; bh=FCtZAFvh+McMUjGW5VDz18+0p1vLtTuD4PBZpyIQ1gc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=u2Td9rpsYo3mMYz6Q4GtELizGNJ+hrj7pI/45Ko+ElLkQNJRKyuuSNCopjNmCpFjP dhmKNOSmmu1DLL6F6PpWmSsAOZHumOAr8dv/+KV73jaSscGpis/TPWuu9yZr6Cotgo zJP4VYIcyqMXiJrFwxWHQVbKkfXGwHgx3c80hGR4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2072.outbound.protection.outlook.com [40.107.22.72]) by sourceware.org (Postfix) with ESMTPS id 2768C3951825 for ; Mon, 15 Feb 2021 12:01:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2768C3951825 Received: from DB7PR05CA0057.eurprd05.prod.outlook.com (2603:10a6:10:2e::34) by AM6PR08MB4997.eurprd08.prod.outlook.com (2603:10a6:20b:e8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:01:43 +0000 Received: from DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::34) by DB7PR05CA0057.outlook.office365.com (2603:10a6:10:2e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26 via Frontend Transport; Mon, 15 Feb 2021 12:01:43 +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 DB5EUR03FT047.mail.protection.outlook.com (10.152.21.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:01:43 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Mon, 15 Feb 2021 12:01:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 58758d6e978af435 X-CR-MTA-TID: 64aa7808 Received: from b39eb2cf04d3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E2168774-2FBC-4356-93B8-0F990026E2F5.1; Mon, 15 Feb 2021 12:01:34 +0000 Received: from FRA01-MR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b39eb2cf04d3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:01:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ez232BQ8XOLdqI7+RKYW3XACqx+BQiGSjYLpSG6l9dRTilq557fEXF5aSzODEzhA+qMm6ndq/HYbuMZAbtTLsE4FS4OUN6Fj4/1MtAsSmdvbbs634rr3ZuuFaGiqw2MZmLYR9z1rg3142aY9lcq6q/HmcewKqjA33WiXB4z1LqFutej0dkOCiWvt4uUrWqMg3E5sJBQHVipi3PxW6KXeK503ESDBwEM8mrWdM/JmWl/MMuHSL3h/h3xON0HXd8UbDjCuuRmeaX8NnGgKd3yFkmiuyYIMQCpCY7ZyyBbzpCleJeUkOY5t26sYULUXW6Vrf2AmVgOJLsEwUih0h+tKqg== 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=FCtZAFvh+McMUjGW5VDz18+0p1vLtTuD4PBZpyIQ1gc=; b=Scb1XDrPKtkfMfSLjpkeoYaJJL2sfJDQR9YErop1/mGjbw56z9R80jscj193xOLp89G2wBwijj1/eM1lmFzetZk6QpPdvCdpGkBFT4lPxn66UdpitM76ThK+w07ASJxrZbt7LHoRTGUsDb/iacoAi7VzmwEnv90uP93aIqXQI4BEyf5IlOjFAZc/bNn9oiDUMa3XMyu8eTvy41BRcnUrHQRZSXolIAra7UbQ1AEKGVmx1P9xOJyjcC56VNfEgOxyPETmZEhppVbT5mTX53OIjyaaNA1LAddfXimYSUB1cprt3pdRbZb43k/Hjg9u2Q6QSdZezg/+1/xDgIrL6StouQ== 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 PR2PR08MB4809.eurprd08.prod.outlook.com (2603:10a6:101:1a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:01:32 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:01:32 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 09/15] elf: Use relaxed atomics for racy accesses [BZ #19329] Date: Mon, 15 Feb 2021 12:01:21 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SA9PR11CA0023.namprd11.prod.outlook.com (2603:10b6:806:6e::28) 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.49) by SA9PR11CA0023.namprd11.prod.outlook.com (2603:10b6:806:6e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:01:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a49a31b1-f671-454a-d066-08d8d1a97635 X-MS-TrafficTypeDiagnostic: PR2PR08MB4809:|AM6PR08MB4997: 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: chrLEU2/sqNdX6NwzOP/bQhksa+WS9U2VnYNAAvK47z0Dr/zotXcEX084Hy5goeKmiaWrOkLXMQ3stlxyk9ylhqoFg60yEqq7nlNITA7ItFjzd+oWJ6UWXytQS8AkFQ8sjSvxlEsM5AOWeIsFsEoExTDUsnYosGSc+CwjtzpeufTO1apjavv7L8fkwXhoXcoIS7xOkn34yZ3dn5CWb/cEbEK/Q3AtxDx8OfhZW6zRl0LQrxI87b0W6wAXxLdOHl+3Fsw/j8JcqDaOzvR1aIxGSuLpElchf0OPu4/TTA1iC2hl/cHFkgAfPQGfXTwUwae1Fx4ZKQpgDUlmz47DX7OQC44eKfHddULG8zVwfZR1ngQLMDA4ceUGYwjP/8hfymf1Gq6CBbG64uC/56GXHh1fWwGohqions2Gv0Mo+9oYbpEBOzZYqojk6mnVSbDh5JSwyHoB9EYE85SJg1xScU3XG6fMGXY6PARDOBZAMQWdUo0VRN+zIsHrKdG+mYKu5gT/gdky4IOZFubBzTfxaerUJ/WS3/f2xx4rKXkU7RtiSCjYwl9auKQF0KuFS5jAx23K8nmzG22Zq7xa9/3wzoYLw== 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)(39850400004)(136003)(376002)(366004)(346002)(44832011)(52116002)(26005)(186003)(83380400001)(5660300002)(316002)(16526019)(956004)(36756003)(6506007)(6916009)(2616005)(66556008)(8936002)(66946007)(6486002)(6512007)(8676002)(478600001)(66476007)(69590400012)(6666004)(2906002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fnOegUOsXkzIoChtE+NzwgKBnBOmixxoQRPNBk8RDJQQSTHimji+G1R56gqx5HtGDFgH3w/zfO6m8RNiyaFZM3sQ88xPeGB8CjDj46gypdbSZdtR8X+42OtUlNJETEKSyJBLYI1/Yy8S34G1mcUIHomfNfcOjGJ8ksoY/rbXEOKMSvODFfgmikXu12AVGaACrRAhYe+4vYZWtJWen74Y2nSOzXeNRw5do1SLQulaZi05XU6cy5SxEhDShWeWDxaoA3PWFgyPTPjWY+0JKgSlEgCWXEwbHrwtso8kIRXggqR1TeciOFNJFm0NnCe8xD60J/y4Cp/ZpUDm1gAJyTU6n5T+TDmgJ97nKO+qLSLK5Cppxl+vTOtwYlMAALFq8973zLb9PgYww3p4Z8VBNoVk8CwBX/bY4wWoJ3u0+cb95ziTdFl7U1NqcO90l7g9lLP823EpVEo3mlbSz9CjwoI7W1D2z/u9n6Cv8RgUcNHhNhGhVnQQ9I1yVHv1fV07bQkz4S4onTBlV6Ib6kfRlBFP2H4BpmQ5voJ2RIRIr5M7c0fwmMFjSBSAQz2oHr7ljGN8B7UhYM1+5dc1t6mCOqdekK5tUkXVEIofqB8s/+v/OOpiRs+a2Fw5qoqC2dp9AIVavMBEWdwOBp9fync+Jzamr8avp4p6MENecVfqMPMgLqyNr5qkC5kMBLVOEN37TOQM0oAC/8R1gWz86FkMFkM9j4NW2yg78h1ADZBJ4dbOiir6DNCaZhWDySgFfTJvYTXDdwdjYKc61jtrEWWAD1msDKp2tRi6oh/ek3EsYqZqGLQpKg+kCJyqeRVvASSovUIKHuH8G74BdYNTsWJ2wnsnNzEc2Rtrzuj8w17NYTsW5fCMSVuYuuhq+ZaHHqX7CNrbeV0EHBQsMLMNBp7Ypfqpa6iNPLQjf6pUibOkOxKK+u7aMqvWFiZx3y+mPEd1ixJwaTURCF0+QFcCEqOVRoLp1mZaN0KAxbnfmuzZsAPpoJtm98/EEMhr/4Daj4VlDvTwe1FsCB22vmsxM9qR2mvoPQjOnnoKqYGdEr/diVkuAx73NaIOqm/eij2Y0soXPTFdmEDZkt0DNtVK9e9Y1VYgSpAATWBlXX0S7dNR2pGjbwBO/cRgIwMgUN8sVI5nJZo8a0y5vmMqR8VQb7CGOYL7JM6B732UzpNzuUSg5Jz+IPp2oEuYJgk8XH0qH/KyWaieQAb0vuoupqYepztucmGkSqxppQkzy2ors31Tt4jTla8M1RpkUxn/NZS1SqXcCdUoGuTFRzHABDgtZZDsaVtWZOwoWtGWjr7ZFBgrgvrv5bR5YjrLkNfqUfzoXwBAumx1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4809 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: DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 87073d25-2dfe-4ba6-93b6-08d8d1a96f7f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XeqphuACTVzLwvFbJtAqoftjbwIVX8ikh0I9NmtuhaoeZ/3NIKwDwzA46eEUKMclXE7Rlx0C472KGYgcRkCmw7OTdWXckFUE6p6Im0RpOSTklz2Z1ykgsYo6llb4XTXqZt3XWAYJMbvhUa48+tOyILk0pxhisRHCOXU2mWIftzGOcdGsxicQLOLJR07GreAti3GvChWkTGGGNYG1BIGVXEUNsRHkMqGa5PkD/Xzx9vqNQIxrgINlGGCjoAtP3uukriJpTOT1yuCqWmKsZox2bmmX3OEx/agW8zO3DuK+uSdtihg7fFxqTX6eP1v0orxfbubZst+kqn7Z8mh1hMHI3h9dymX+wOnnHEcGeaa32RjJMaSY/FKUvwtbQTMke/gb1mu/Zh3trBUBUv1TrDKmp0T5b6Yq6oFT5TDUdGDrOGVc311DENdRNuxU0ltrsU7oK/2WbbU1Pn6u3AQFd9EU9LY4MtLxWelSYs27vP75x/ULcn/bP45W7iz0qoshSKkdUDZ+jbMF3lvi3EiXDEsQfJ5KLoUPvA8OD263eJeOtx8Uo99desG8p9ZWlH4n6UyDmE4abX9wJXqRsBZutdoPIl3yE0MShR6wVYOsmkNSd9DOUJr4wrztLLZr1nflHf7izzPpM6Rzng4V91UmKpTpnbouI/WHnp+DJ9Okh7EXNYDRjyb303O0Ej+m7r4g8Api 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)(39850400004)(376002)(396003)(136003)(346002)(46966006)(36840700001)(16526019)(6506007)(186003)(6512007)(8936002)(26005)(36756003)(2906002)(47076005)(86362001)(36860700001)(8676002)(478600001)(82310400003)(5660300002)(70206006)(6486002)(81166007)(82740400003)(83380400001)(2616005)(6666004)(336012)(44832011)(70586007)(956004)(6916009)(316002)(69590400012)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:01:43.5761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a49a31b1-f671-454a-d066-08d8d1a97635 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: DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4997 X-Spam-Status: No, score=-14.2 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is a follow up patch to the fix for bug 19329. This adds relaxed MO atomics to accesses that are racy, but relaxed MO is enough. --- elf/dl-close.c | 20 +++++++++++++------- elf/dl-open.c | 5 ++++- elf/dl-tls.c | 31 +++++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/elf/dl-close.c b/elf/dl-close.c index c51becd06b..3720e47dd1 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -79,9 +79,10 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp, { assert (old_map->l_tls_modid == idx); - /* Mark the entry as unused. */ - listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1; - listp->slotinfo[idx - disp].map = NULL; + /* Mark the entry as unused. These can be read concurrently. */ + atomic_store_relaxed (&listp->slotinfo[idx - disp].gen, + GL(dl_tls_generation) + 1); + atomic_store_relaxed (&listp->slotinfo[idx - disp].map, NULL); } /* If this is not the last currently used entry no need to look @@ -96,8 +97,8 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp, if (listp->slotinfo[idx - disp].map != NULL) { - /* Found a new last used index. */ - GL(dl_tls_max_dtv_idx) = idx; + /* Found a new last used index. This can be read concurrently. */ + atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), idx); return true; } } @@ -571,7 +572,9 @@ _dl_close_worker (struct link_map *map, bool force) GL(dl_tls_dtv_slotinfo_list), 0, imap->l_init_called)) /* All dynamically loaded modules with TLS are unloaded. */ - GL(dl_tls_max_dtv_idx) = GL(dl_tls_static_nelem); + /* Can be read concurrently. */ + atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), + GL(dl_tls_static_nelem)); if (imap->l_tls_offset != NO_TLS_OFFSET && imap->l_tls_offset != FORCED_DYNAMIC_TLS_OFFSET) @@ -769,8 +772,11 @@ _dl_close_worker (struct link_map *map, bool force) /* If we removed any object which uses TLS bump the generation counter. */ if (any_tls) { - if (__glibc_unlikely (++GL(dl_tls_generation) == 0)) + size_t newgen = GL(dl_tls_generation) + 1; + if (__glibc_unlikely (newgen == 0)) _dl_fatal_printf ("TLS generation counter wrapped! Please report as described in "REPORT_BUGS_TO".\n"); + /* Can be read concurrently. */ + atomic_store_relaxed (&GL(dl_tls_generation), newgen); if (tls_free_end == GL(dl_tls_static_used)) GL(dl_tls_static_used) = tls_free_start; diff --git a/elf/dl-open.c b/elf/dl-open.c index ab7aaa345e..83b8e96a5c 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -395,9 +395,12 @@ update_tls_slotinfo (struct link_map *new) } } - if (__builtin_expect (++GL(dl_tls_generation) == 0, 0)) + size_t newgen = GL(dl_tls_generation) + 1; + if (__builtin_expect (newgen == 0, 0)) _dl_fatal_printf (N_("\ TLS generation counter wrapped! Please report this.")); + /* Can be read concurrently. */ + atomic_store_relaxed (&GL(dl_tls_generation), newgen); /* We need a second pass for static tls data, because _dl_update_slotinfo must not be run while calls to diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 33c06782b1..c4466bd9fc 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -175,7 +175,9 @@ _dl_next_tls_modid (void) /* No gaps, allocate a new entry. */ nogaps: - result = ++GL(dl_tls_max_dtv_idx); + result = GL(dl_tls_max_dtv_idx) + 1; + /* Can be read concurrently. */ + atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), result); } return result; @@ -359,10 +361,12 @@ allocate_dtv (void *result) dtv_t *dtv; size_t dtv_length; + /* Relaxed MO, because the dtv size is later rechecked, not relied on. */ + size_t max_modid = atomic_load_relaxed (&GL(dl_tls_max_dtv_idx)); /* We allocate a few more elements in the dtv than are needed for the initial set of modules. This should avoid in most cases expansions of the dtv. */ - dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS; + dtv_length = max_modid + DTV_SURPLUS; dtv = calloc (dtv_length + 2, sizeof (dtv_t)); if (dtv != NULL) { @@ -767,7 +771,7 @@ _dl_update_slotinfo (unsigned long int req_modid) if (modid > max_modid) break; - size_t gen = listp->slotinfo[cnt].gen; + size_t gen = atomic_load_relaxed (&listp->slotinfo[cnt].gen); if (gen > new_gen) /* Not relevant. */ @@ -779,7 +783,8 @@ _dl_update_slotinfo (unsigned long int req_modid) continue; /* If there is no map this means the entry is empty. */ - struct link_map *map = listp->slotinfo[cnt].map; + struct link_map *map + = atomic_load_relaxed (&listp->slotinfo[cnt].map); /* Check whether the current dtv array is large enough. */ if (dtv[-1].counter < modid) { @@ -923,7 +928,12 @@ __tls_get_addr (GET_ADDR_ARGS) { dtv_t *dtv = THREAD_DTV (); - if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation))) + /* Update is needed if dtv[0].counter < the generation of the accessed + module. The global generation counter is used here as it is easier + to check. Synchronization for the relaxed MO access is guaranteed + by user code, see CONCURRENCY NOTES in _dl_update_slotinfo. */ + size_t gen = atomic_load_relaxed (&GL(dl_tls_generation)); + if (__glibc_unlikely (dtv[0].counter != gen)) return update_get_addr (GET_ADDR_PARAM); void *p = dtv[GET_ADDR_MODULE].pointer.val; @@ -946,7 +956,10 @@ _dl_tls_get_addr_soft (struct link_map *l) return NULL; dtv_t *dtv = THREAD_DTV (); - if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation))) + /* This may be called without holding the GL(dl_load_lock). Reading + arbitrary gen value is fine since this is best effort code. */ + size_t gen = atomic_load_relaxed (&GL(dl_tls_generation)); + if (__glibc_unlikely (dtv[0].counter != gen)) { /* This thread's DTV is not completely current, but it might already cover this module. */ @@ -1032,7 +1045,9 @@ cannot create TLS data structures")); /* Add the information into the slotinfo data structure. */ if (do_add) { - listp->slotinfo[idx].map = l; - listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1; + /* Can be read concurrently. See _dl_update_slotinfo. */ + atomic_store_relaxed (&listp->slotinfo[idx].map, l); + atomic_store_relaxed (&listp->slotinfo[idx].gen, + GL(dl_tls_generation) + 1); } } From patchwork Mon Feb 15 12:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42039 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2592395188A; Mon, 15 Feb 2021 12:02:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2592395188A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390535; bh=xI4HhTiZQSuBUv2nCDJliLR3jzjqJlrPMoxOoThSUCE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RxJPil1bG4tyBwRt1MxBXviHzSKckjb5KfoK87XWN+zkVHt5kGfrADqz0g7uNVl1U umlaa+HfzFQhXK7BpxgpYoMzYsZpjZWeJyruw9Q/6Clc0O2JpEo7K4pRzGuWOwBXX1 7w7b8p3ckucK1EEMGwihFONnBLgM74Knp0XCJ1rs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by sourceware.org (Postfix) with ESMTPS id 56E0C3951825 for ; Mon, 15 Feb 2021 12:02:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56E0C3951825 Received: from DB6PR07CA0165.eurprd07.prod.outlook.com (2603:10a6:6:43::19) by DB6PR0802MB2216.eurprd08.prod.outlook.com (2603:10a6:4:85::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:02:02 +0000 Received: from DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:43:cafe::8a) by DB6PR07CA0165.outlook.office365.com (2603:10a6:6:43::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.12 via Frontend Transport; Mon, 15 Feb 2021 12:02:02 +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 DB5EUR03FT039.mail.protection.outlook.com (10.152.21.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:02:02 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Mon, 15 Feb 2021 12:02:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 84dbe060c99ba649 X-CR-MTA-TID: 64aa7808 Received: from d58b7ed1890c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 23423B60-87F8-429C-9AD5-12A8D88E0FD8.1; Mon, 15 Feb 2021 12:01:56 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d58b7ed1890c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:01:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YiOKtRucl0L4BJmlP6kF7VxDOhyIOqvmRs68REiWe+TKz0LA9GOwkY2bxWQfNTWrztP3bUP8yOBGLaxOm0y15qhzjRP8Ur2pzbE9+m6C0shsze2EncuQKHreowC2Ez9cZDpdz7uuFzo9UqiRQjsSStazjDYP9lI0iNQNneqEl5iGG4rI505hYKsBhxb5aX44fJB5fvVHaSR31xrk6pEPIbu2MhoLkrdew2qgzGPNCvVBkOQg5eMOMA1ysI9YR1VZP8w+Q+/QDWe/8YUTlYF8Nj9BrtMJx0FBt7g7CNffjKc/4+SMeFwyOe0lP79hUBWfGqGRoeEglkNdRFoNs+gRJA== 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=xI4HhTiZQSuBUv2nCDJliLR3jzjqJlrPMoxOoThSUCE=; b=J74DVwxmfc51Vuvg7ky7O8u6AkewhCgc/vNdSXl6xpXV+YSoLv+UD4iRDEQjDfOGYD6ECSzXSHT/bswaPQ782w4FXwyJ9fYJQtGsnUCYmMxSIYUqg/BZenp+r7QvQ185k/ch6mNQyJAMgP7IJmqBbBJfaceF+/kwoS4PCgosjWkV+9Me/slJF/J5VxG41Lt8QmFdVBsRl/nB3gZawq3ltOfRdg9dWVQRxPEgcB/nq09qy1b8zLSMxgNeqM2yCGX9iAmu6Tr9iY2NDpSlyUUsT/aD9sTD0jFP61iXrayi/QqWzR+GsU4SoafrRP96iweyWhLeLY82F1aOgP8o1nriPg== 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 PA4PR08MB6208.eurprd08.prod.outlook.com (2603:10a6:102:e5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 12:01:54 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:01:54 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 10/15] elf: Fix DTV gap reuse logic [BZ #27135] Date: Mon, 15 Feb 2021 12:01:43 +0000 Message-Id: <9a591c9dc467341d41766ce388fbb500f8c0bb3e.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SN4PR0201CA0046.namprd02.prod.outlook.com (2603:10b6:803:2e::32) 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.49) by SN4PR0201CA0046.namprd02.prod.outlook.com (2603:10b6:803:2e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 12:01:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7ff7cecf-34a6-4877-6ac9-08d8d1a98131 X-MS-TrafficTypeDiagnostic: PA4PR08MB6208:|DB6PR0802MB2216: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: CbC1Z1siapGdZm3U3HlLvbhNMMBrf/OnbNaY0WTulLUdoAAfJh0ak3S8ufaRkbD+lbTkPiDEvpZ5446w/HMok8/6s0QRTsrnDz5EpE/+kqgehI4lll7QZ6dhmNkQNwaiuUevMFijg4/ZbS19TtwXgo/t50A8aMPJtdl7TTdFr1qa6TaytsDF1+zD5o+AD9gRbSRUJWztrFuFSD1MVpHzW5gJ4wgk09CD3p0pez/oc8HBmZ3G/NFWny1rxKZ9vSz/ck8iKbupCSf+wepoRyFOH0bQDu472uyrLfZ6TwztOSlFV2dVTXgtQ2M8Yh5lk/0IiEoTs2N/PYV6tXp2TCVjzp1jLVrMprfQDMRe4v7d57SBs8sN6CXD2x16i5jF2yxxllGTOSiijK8UW4mbFiuCxPupHKDrtQx4xdVBO3c/JjlS4H8HgNlF3XMfqDBSN+uC4PNAKkQ80g6TtuRWKZ6I8Mzljbd0AfNlgt17iXAQ5CskmZSYdt/hUvPFTN9+hKdIQHCXklreghiMh271B8zRK5sGGZrV87IWRdr8ExR8Z2BD135yewlpHEKb5Z5V4NHtTepNlLHRsjUu/Bw4O51RXA== 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)(366004)(396003)(346002)(136003)(376002)(39850400004)(2616005)(956004)(44832011)(66476007)(2906002)(16526019)(66946007)(66556008)(6916009)(186003)(36756003)(6486002)(478600001)(5660300002)(26005)(6666004)(86362001)(6506007)(69590400012)(316002)(83380400001)(8936002)(8676002)(52116002)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: j7K9GNV9FV2em0XniCJng0954vw1ant9/+zQ+mfc7pUq1Jz1BAnROiqR91GKnNASrmnaPmBDnCE7uIYCjN929DxRiYZv2XJrWHrG9aKjcfWZ51N/22NvgQb2nyNK5Av05o1kufEwNFKoKRbPuYWb4lSqlRuUDlZQewvNIj/TKX9voPpL1HFxSZs+acZr1wIqjYX6BNzXd9YvzBT5XPZi36rmLbvsdx6GHKdgTBrdzOIEwJ42v7r2pHJO2kXOXiP2EBJY9nGzv90LJMK/GZyM7ZOSfrKKwEzHivce+GNwbZnWSJ1Y0GEBlCQ/aFYqZTVX35jrGewhYzkPoMMFT9ilGRB7F9+yTs4jV4AqieXJcyNC2UAApKr9TsYRj3vr0ftYk56OavHJFlqe6ty5nqE13Vj9Hjhlr+hWzPSEwkaqfP8Dh5neKt4ignDtxph9T57CgAh8SEu9aotZs9KpZkyrbvvGhV9h6qgtxCxZv2kRpSOG9lEsFUpin8o8U1R7R+H9ablnZxSGt9H0r8+PGpMFedCoujCZNGG4kBuKGTAapq++9Elro9RQY94woeD4A+wJsuW9PZDBW7aJ/0MONt3kQIH6Uurmo2LxKvSEP3ivkh/HnyML3+yZIrFlVTF2yy0vdy/ahweSfHXL7997W74olIsXQYsLne7U+6WkHatMMWae5s9LiTyT/IhOThlBLGKZ1xoXHfAckVq9bEffNlSNcAoPrcIbJtN8HPL+dQ30yTxcWFJAd4juIYQJXI1MPZEOoFJXlPzq2EAKpGurKbYKmGfUvJ9AArqZz53Zoszr8kn3sOlB/eX+XrKE89HyXIe3NmrvkpISctC7ExW/I6c4miqyyXSgyW48E5F/R9V8VjStzzPgZo/vIMJz3t7ArLBKMSZmwrE+JhBk+CEgJpdrvqG1KtHECoDLaCQsnPnMSLZygo/DCf0pz1iTmfLZByka4GU4OZzqIGz4DuC/w73w4mxlfBPk9jxvI0nDmzDQzFNTAxk3oOtPpfnYkWmmGG7oSE4jjV5wLVhRvLmiLJAvYtzCedEQyxBCYcTGBKBbA22gwME4JtuYMcRWCQ00Z3F7OZ9aYXBGUiPLgOJdBys/6RRLQtNUHNrXgPXuL9eTk0BZP4PAVDvXfuoPehWGs3nk8/fCZoPuWaAUJbhUGWPp5SIOqln46mt/+xzj2CsYCQbyzXpDLyqrFgJ2z9FeJFItxJ4+9q5mfy9Xp9Jnt5Ds6D8Lf5BOVFBr6/RGGlU8uSBJ45ZX2BZSqFSSVH4AI2fzhKO/2jVK3qK3vV+AkI8bSTW6U47LEyqF+1Vc6tm/nX1RJ4PpxWMLX5XldOJEXDcJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6208 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: DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: af85961d-1192-4293-6b7b-08d8d1a97cb9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dlh17JmU6lHkcF98ufksKd/UTR71Co2W2LaOFzhRcMJzzu5v0WkoRys7xClMb3gBzvZh103NsFXjupjWjpWj/1JzV+OBat3agJilRTwrVH3+3PjOKBrWPkMLUGgw/8u0+enJRbILXXoH8gZes4qT1qSQPa700GxuPQqwRRjOrYN/PzBaHFGd51Wd3tfI36fzROleLR4coXLYOQNN85sf912qBiEP+kIlRCH3myuLkUsBHmyZ5eVWy3GZFPCWRGX5HCI5Yu2sqGXaxi1fRGe58HY5buiKskcmd89/Ag4RPx86VVE/IqGg/oCaLGU1b91jK04g6gzIBH+8ly+6tUpkQNHATMzkHtg40PNGnfBnqczVk0CANy7WVFza7URAy77pVVsz60COc96rqRTy8dXH0n0K46J9ehjRYZyYe1wmZU8pqZhuxSGn3cvUwQa8A/mJHmrxXCb3cDYB9O6D6qC25OA23DNiN8E6iOW/AayouikAsFbnJ0tpTk+JUZTPbu72iieGzPERrXZuIfoTyI48DAxR1LktZRgoOqa/pNmxKZ0OnXZzd8VED9fZgFIcULJOByI4H753PCRktUKrC8DrSEuyy82BNoxy7jKyI+95N12vRaLFNni2rwBFQkcpc93SnPWYKv9MWaMiPMuEvg2tBxRI+RAnMSEHJeV8NSUQfmjY9WTVgcDwwTey6DAgKVLh 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)(136003)(396003)(346002)(39850400004)(46966006)(36840700001)(186003)(16526019)(356005)(316002)(36756003)(6512007)(6486002)(2906002)(6916009)(26005)(81166007)(6506007)(82740400003)(86362001)(82310400003)(70206006)(69590400012)(47076005)(36860700001)(5660300002)(8676002)(70586007)(336012)(478600001)(83380400001)(8936002)(6666004)(956004)(2616005)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:02:02.0032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ff7cecf-34a6-4877-6ac9-08d8d1a98131 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: DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2216 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" For some reason only dlopen failure caused dtv gaps to be reused. It is possible that the intent was to never reuse modids for a different module, but after dlopen failure all gaps are reused not just the ones caused by the unfinished dlopened. So the code has to handle reused modids already which seems to work, however the data races at thread creation and tls access (see bug 19329 and bug 27111) may be more severe if slots are reused so this is scheduled after those fixes. I think fixing the races are not simpler if reuse is disallowed and reuse has other benefits, so set GL(dl_tls_dtv_gaps) whenever entries are removed from the middle of the slotinfo list. The value does not have to be correct: incorrect true value causes the next modid query to do a slotinfo walk, incorrect false will leave gaps and new entries are added at the end. Fixes bug 27135. --- elf/dl-close.c | 6 +++++- elf/dl-open.c | 10 ---------- elf/dl-tls.c | 5 +---- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/elf/dl-close.c b/elf/dl-close.c index 3720e47dd1..9f31532f41 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -88,7 +88,11 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp, /* If this is not the last currently used entry no need to look further. */ if (idx != GL(dl_tls_max_dtv_idx)) - return true; + { + /* There is an unused dtv entry in the middle. */ + GL(dl_tls_dtv_gaps) = true; + return true; + } } while (idx - disp > (disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0)) diff --git a/elf/dl-open.c b/elf/dl-open.c index 83b8e96a5c..661f26977e 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -890,16 +890,6 @@ no more namespaces available for dlmopen()")); state if relocation failed, for example. */ if (args.map) { - /* Maybe some of the modules which were loaded use TLS. - Since it will be removed in the following _dl_close call - we have to mark the dtv array as having gaps to fill the - holes. This is a pessimistic assumption which won't hurt - if not true. There is no need to do this when we are - loading the auditing DSOs since TLS has not yet been set - up. */ - if ((mode & __RTLD_AUDIT) == 0) - GL(dl_tls_dtv_gaps) = true; - _dl_close_worker (args.map, true); /* All l_nodelete_pending objects should have been deleted diff --git a/elf/dl-tls.c b/elf/dl-tls.c index c4466bd9fc..b0257185e9 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -187,10 +187,7 @@ _dl_next_tls_modid (void) size_t _dl_count_modids (void) { - /* It is rare that we have gaps; see elf/dl-open.c (_dl_open) where - we fail to load a module and unload it leaving a gap. If we don't - have gaps then the number of modids is the current maximum so - return that. */ + /* The count is the max unless dlclose or failed dlopen created gaps. */ if (__glibc_likely (!GL(dl_tls_dtv_gaps))) return GL(dl_tls_max_dtv_idx); From patchwork Mon Feb 15 12:02:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42040 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC1EA3951894; Mon, 15 Feb 2021 12:02:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC1EA3951894 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390550; bh=1SBxDdn5sEz1vzpy6+7YsvHR0QbPIBAAXPBMadvxq70=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vQr7frFvicc+RJI9LNiPgZsNGH8ylsgOZHoRGS6FBQlUAC4LJysck24I9+D0itHjl sp2snizBoVUlN4PdCRgsgi9XSni/bBjRjJOO9NwFoSIiO6pPJvIkHtkjqPAyWYk0U8 R7q0aL+Na87bfrd58fPhUnvHO/4vLcAsIWGL+Kq4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70050.outbound.protection.outlook.com [40.107.7.50]) by sourceware.org (Postfix) with ESMTPS id 23C4839518BE for ; Mon, 15 Feb 2021 12:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 23C4839518BE Received: from AM6P194CA0019.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::32) by DBBPR08MB6267.eurprd08.prod.outlook.com (2603:10a6:10:20d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25; Mon, 15 Feb 2021 12:02:25 +0000 Received: from VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::4b) by AM6P194CA0019.outlook.office365.com (2603:10a6:209:90::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:02:25 +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 VE1EUR03FT006.mail.protection.outlook.com (10.152.18.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:02:24 +0000 Received: ("Tessian outbound f362b81824dc:v71"); Mon, 15 Feb 2021 12:02:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 50d802a96d913f64 X-CR-MTA-TID: 64aa7808 Received: from e1a662b4de8c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F8376CA0-3E12-4FAE-9BF7-9DD7765C1388.1; Mon, 15 Feb 2021 12:02:18 +0000 Received: from FRA01-MR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e1a662b4de8c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:02:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FDH5Fx4juWNSGCTpq9qtXb873pEJ/KI35mAYMnQetPp3VURGTjDJB3XRQJK556gEH+hkqG3MKrz5KvQLpV7L3FRnVJ+YJlgii7v5jbfvgnBF8nY9wY/O51Hxipv1ZbxgEh1zxEbcclXZkb8YrcK7ijCb4PV2kdimDDkmoE4M3aY3MVkIOqqJO2TfgNgi0D224iNDBx8bcUAxZdlsbI3DrDGSYhM2FzbF6BmFZZmWsw/XT5miKmqxnipUu3PGrtcVCkOom9IosenBioak63KAjm48SPy/nriY8K/1Mq27bAhSEavBtC63USRr7bzNeyYFd+XQLHW4+KrjTrgfzsUXXA== 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=1SBxDdn5sEz1vzpy6+7YsvHR0QbPIBAAXPBMadvxq70=; b=nIj0zYp5EVjnRlzfHZA7gorIMB+ZaLUQry3ucrkqYZN/oEULt1JYUiwGB4qsytD7VNtixtJ+veLaydtPpDxQXCKwTXNHoYI4cQR3d8e6+Xrnd+KAbP2FSOCWEdAm02t615mPDD5EoOJQ8EMzymPLKpbFoHrmVnPQkbrAoUQiFBj+yLMPlejh+h3WdGl8qp54Yxbp/laM7ma7PavSx7bEv4ICayFfUbrlhybHLEKj5FvmW3gJwCUDLdZ397gOErLPeumpVuWoeRajS9PPhBEIPFI05V6TeVopd/7J5zxDd21ObyOss44FQA5x3IemGYSIDexSf+ydsRF9XejVAAXWMw== 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 PR2PR08MB4809.eurprd08.prod.outlook.com (2603:10a6:101:1a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:02:17 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:02:17 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 11/15] x86_64: Avoid lazy relocation of tlsdesc [BZ #27137] Date: Mon, 15 Feb 2021 12:02:05 +0000 Message-Id: <8c6dae9ee45f9af51ce70cb8422582096dbf7ffc.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: SN7PR04CA0116.namprd04.prod.outlook.com (2603:10b6:806:122::31) 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.49) by SN7PR04CA0116.namprd04.prod.outlook.com (2603:10b6:806:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 12:02:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1f5c6fc2-f7e7-4a7b-ccff-08d8d1a98e7d X-MS-TrafficTypeDiagnostic: PR2PR08MB4809:|DBBPR08MB6267: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:923;OLM:923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FCC3ZXVRTs7V9XRm2op0RzApLrAtDn1bMDcRRRN7Ja0PE9Ib4535J2oIAd+s3nPSdSDBCQ45VvVmiY781LburRlMpxH/q5jIG5/SI8wBugeSjs2y/DXHleZ6nFzn8egcbisK1ygYUmbOINIk1Q1fD0x65bSws7kmMg4B5GGucxGHHnnYI5wcf00fjA8dMqlEjLfb3Zg2H4+3ekfb05i77j4Bi6QWqoVB1bH+edGHxWaWKGqqFXI1RVInTekBKSXDypJKQ1esVqFb9rogd3dEkuisofJB/o9BPhsB8FeUoE/ihp3ao84ep2/QJyFNkrbrmW3UyMSYMhRirmffrkDqry0nLmf+XuL7dUwGCQPK+A0e3hsyv9mez5X9foyocaUBdPHuLzBRna5OJ/sDJUgu1YChKwx/VhVVCtjvVgZhRfmJ8RokCS1pnCXAnG79eP+YimOt3Wvg83VnNeCPayMcABNul3MVysrmyjrI6ks+ay58mzmjE3rkk0o9n5ndrmpYqy4ZuTFuXYQS92AS0AMTe/Ua8Nf434WVAsJcr9/CcZr6USy7h56ZW2ibKRtWHEHGnxTngZMSo8+k0MtLFOXiMg== 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)(39850400004)(136003)(376002)(366004)(346002)(44832011)(52116002)(26005)(186003)(83380400001)(5660300002)(316002)(16526019)(956004)(36756003)(6506007)(6916009)(2616005)(66556008)(8936002)(66946007)(6486002)(6512007)(8676002)(478600001)(66476007)(69590400012)(6666004)(2906002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Sx44UcabFLH3gpkLAop9UuGh6AnjOI1sAmKcrEG4RySYQVZNIPTN09x6rSHwJJNH5iovdOqpXQUF6j/VgLXMNAw+VCnJpWv+42z2w148Ckgr2Cn8J0AjHSmvHGYfnlbCvPi66M3+2ISts5jz03xtHlim+avOhuD5sXqeT9bwpDe/A3ytsJCrQ7wJcwL6RPIZc/p6xyCAMI2nrFBaDZen8GK8escjOih0bPrvOYEUqTKfWalXgCIejQ2YUVRGKYu/TDLfl6fzR4zYxHRKm5EEb82Jgl/+1p8cTPU1LKeYdILOGG4RFrY/MSJFxcDjTMqrsKb8ouo/h8UQSzfo7i984fpvAH60HxfbrMjeF0E+CbFnYp/c/NTF75k+05CkQWanCASpt33Gx++l6IF5qJ32TwT/bjaWtWkB8DvWpGaKaXwFQ1SygqlW1iT5JqdA13q+Gv0aLNlSbz6qLZnhB5aiQIPExh2wVyYWK+r1glqvMc9Wpj53s3WHOkDqAuChjxcyIkzJZ1iywML+U0q7RN56mMbM04v8S3p84r9KCNTAHKcQcWQdqqS9+RG5p2g3ua4T8ld56+6UmpaetIT/+tA4vuS22100UtYIq2NyaQbqDeD4XbsUQQuF/BDaXUDVbn3I6xtSiMnbo+F7tqCQ+vlTSkoibYA/pqgqWRTcwTdV9e5hXgDkQN28TOMs3HdNd2OLhoBifvRZsEoiE4H5EAR+QPsuG2tnK4i7g99QxelpSeidtu2b78EPh5hpAPwmB0VsDYCpUADdSghUqWv1aAiqDLqWHmXvIP+DTMGsZ/iKZbjNB/dFDSzM5mrxZgZQA//K1aEQNHcDcaLTFeSpaF4AuXuVtIEcwEf9bbgtHqoD+abPhfANhWkkedkapSEtmS4eig5GvsDPle8wSC8oS4Vkrm+RDlxnyTFYhfl7aKdLWQnOaNBLkmT8DnKVJaCaOjNeIuNHKZ3oHHe97ip2l6EyV88Fk5VwyRWH5f/A/8fnYHYfMSrRETxJxapE0kdfgHXmMc/OM3+5izGYXZiiYidmdX0HQlOtnJmtYPCDhPuSAUYXKU89Bjx0NXfTzyqDY5pCEFoHideYCnd0aYW2gzvcqRYYmSdv3oOAg+Mc/zp7Yyv0ZvUCGDFHeUHWWY/ZCeu/IKbr/Go2OQrd2I4QqQ4P9I/pzjaCgBqFsuZRNVfYJGp2gATMaAHnUVADX/U8IRsoX7vMedpd14IQ90TEg79dxbvuD+OE2VkUoj1RIx9S1J1sP/vg7rggO4Bipl9HZWH8Px5zvPRCtAaNX/CV2uyEtI0AQ1tnccO8KG3rjqq32Z82Mm8jVJ5b+CyYKLXtsjlR X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4809 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: VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 61496d51-067b-4730-1ffe-08d8d1a98a04 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nl7nG12ntwVav5VOoN1fxsvRh0VqP71TdKp83GKYeXWfyaxyQ5+YhwIvdT/rE+YtRF/8O5cEAmFbZRYVmzD8kUtf1/6HIQIoJoqKXVDMuFVsj4WVRFIlAJHmT+sbye+PRTajYmhVO5b7SduErCHJEIhP3dGgmjXRZsqv0lS+aW6qRbKswMu8Lz3++YgKEXEZ13bD5Yj+Tr7C9j+V8k2y/PKw20K+4Kc5zZpqvxqh7KGVGwfWDqcjyVhbPTuux4E3IW5cneZqYLm8Fy3bnN2jZm9RuvUCywo7jMInycjXtdTMgXcZCYvOtNuXh6bJL2NrbmJ1KCd2ISugEp93oACm/ny2t014jwoVQYiVGUVcloFT4cecOSqz8gYpjaV+L8luFHBPfFJuu2hQp7xE8yZ1uFnS0UqjJNyU45Kg8OEMN1PQ0Oq8P3RUACUN32omwi6uK0K3Nmbbfd7nKiaacALrtRM8iAJy0e0gFd8f2DtktIIB8AtKgwGQd4yGtSk/jDJNiuQYuy+dAZGXjghOhgTXjFH+NIETeEtRI7vRW/8AtUm0sqfseTKN3+ftpZBQnJBPkx9pDJn9oaHgTitv6y0cFM1QhD4WsOy2xVq6FFKH6NxE35At76SOtLpj31JXkFe5yEdSeBUOdKpfETOibOkLIOn+XWp76FulNy3ydTkAtM1K49ZdbcvcINVkFxaS5BHn 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)(396003)(346002)(39850400004)(136003)(36840700001)(46966006)(69590400012)(478600001)(82740400003)(47076005)(70586007)(6666004)(6512007)(81166007)(36860700001)(70206006)(356005)(36756003)(2616005)(8676002)(86362001)(2906002)(956004)(44832011)(6486002)(83380400001)(186003)(316002)(82310400003)(5660300002)(8936002)(336012)(6916009)(6506007)(26005)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:02:24.1913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f5c6fc2-f7e7-4a7b-ccff-08d8d1a98e7d 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: VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6267 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Lazy tlsdesc relocation is racy because the static tls optimization and tlsdesc management operations are done without holding the dlopen lock. This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67 for aarch64, but it fixes a different race: bug 27137. --- sysdeps/x86_64/dl-machine.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 103eee6c3f..9a876a371e 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -570,12 +570,21 @@ elf_machine_lazy_rel (struct link_map *map, } else if (__glibc_likely (r_type == R_X86_64_TLSDESC)) { - struct tlsdesc volatile * __attribute__((__unused__)) td = - (struct tlsdesc volatile *)reloc_addr; + const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info); + const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]); + const ElfW (Sym) *sym = &symtab[symndx]; + const struct r_found_version *version = NULL; - td->arg = (void*)reloc; - td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)]) - + map->l_addr); + if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL) + { + const ElfW (Half) *vernum = + (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); + version = &map->l_versions[vernum[symndx] & 0x7fff]; + } + + /* Always initialize TLS descriptors completely at load time, in + case static TLS is allocated for it that requires locking. */ + elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc); } else if (__glibc_unlikely (r_type == R_X86_64_IRELATIVE)) { From patchwork Mon Feb 15 12:02:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42041 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7080039518A8; Mon, 15 Feb 2021 12:02:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7080039518A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390569; bh=eI1o7CQWu6VbCUXjEL9eC6+LIz+Gs9bGdp06wUTT0qU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vqfzbrJrIkcdlaHWB2dsSIgz7y14E8yi/HEjEi+sx38TVoW11fupij677OdtMB0XP QZw8OjE44Lg/VyIZN88Zp4Uo0ptiLVlVkW/w4cRh1gtjkdvCCMaQYpkHz8XNw9TZPj B0/Sdzw80SPJ9VJ39e+8WUHTD8EQYx2FTskKDpn4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2059.outbound.protection.outlook.com [40.107.21.59]) by sourceware.org (Postfix) with ESMTPS id 488AF3951015 for ; Mon, 15 Feb 2021 12:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 488AF3951015 Received: from AM6P192CA0067.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::44) by VI1PR08MB3615.eurprd08.prod.outlook.com (2603:10a6:803:79::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 12:02:43 +0000 Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::1a) by AM6P192CA0067.outlook.office365.com (2603:10a6:209:82::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26 via Frontend Transport; Mon, 15 Feb 2021 12:02:43 +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 VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:02:43 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Mon, 15 Feb 2021 12:02:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 93817aef04d991a0 X-CR-MTA-TID: 64aa7808 Received: from 03357268e1f5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E852608F-0F14-465F-8679-BB62297DFFBF.1; Mon, 15 Feb 2021 12:02:36 +0000 Received: from FRA01-MR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 03357268e1f5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:02:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lq5objhU8VbVz/vXOWSgNCF0Ln12iXyHmmPJYLA5acB9oUU4rZYwh/1auYKKB1wG08rKOSfLvRYFgnrRKjQHZDLzminqaMHRQvc5W388A+TyKe02qfSLNuYRke2y3U5pkZ2UYZK9bEn8kAQMtCpVGGIKPKX88u8hPfnv35aSLFxDf56KjW/NVEsBQ4+Kxsm12NQLogVEQa1+XaDR5433tpDiby5zVft+Bb0V0SuXb8CnUXWkUgFARYNYjtbcjbSIMfvZYOR0t2PPdQP6IFN3wCXzKf6ZqaxTfKregvDhKl17Sczg2TAJWbvGlW4vwwqKIpq+/1XWctOwFAO9w7JgEg== 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=eI1o7CQWu6VbCUXjEL9eC6+LIz+Gs9bGdp06wUTT0qU=; b=Hr7iM2MJ/HptpdI35XPL8Hko7iMnhY+ueIHBcYbkJj8mear1MNpwo2jlKcxJYvlup2w3ZwAwIjalsY0Jav3IH3P8LVNwLfT9nEkqwUJImc8XskBkmHmm8WnXI2IS334nIyj5K56NuBJOJZeeQbSPK77T7aQXN4M0+BxFBIMH1dDtQKbu8kEVQaYMxSvJRY/tutSUTP27CohiIjCiDBzLkdAcZGuaBvbcwheuMVakIS63bCmNHkF8iy1iQ+5i6cSOSsIibv/UtQniVCIDvQlidK8mH34xTpdUVk9+m2RgChe+l59AsqojSJiN5moYkIHOWxpFEpjs7ZUNBdgRD/sp6w== 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 PR2PR08MB4809.eurprd08.prod.outlook.com (2603:10a6:101:1a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:02:34 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:02:34 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 12/15] i386: Avoid lazy relocation of tlsdesc [BZ #27137] Date: Mon, 15 Feb 2021 12:02:28 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO4P123CA0472.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::9) 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.49) by LO4P123CA0472.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 12:02:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e246aa04-051a-45ce-8644-08d8d1a999e1 X-MS-TrafficTypeDiagnostic: PR2PR08MB4809:|VI1PR08MB3615: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4714;OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7AeCRcgrfa/FXvSVXAWZYy3HyG8LC2jCpYjVssuf6jF2BpOZT9vPJQ6LeS9ViTlNx1+cnVdxEBHiGS6UUyeTZ1nZZnYDMgHvWXn+XoMKdL6u1TOP4DEwnd8Gg/Y8cQjpX5QDG46WpGjdE3TfLCVFNA55dgIGc6L5fu27ozmeaZfWF5cDcMZzKMB8ErSBKOiT5fDARmYcu0Zy5k/uO8IRY5lKO7JnE+jhYwjYP/DGtJVOku/DFDLqfY3oSi6yHV/orz74Wknzttczi6Y6se3LfyYgPPLKFSqB0FURFl0oCiTA5PEyjGeVj8zD0VsWN3oeEuLjl85xqFW/ZKVM4EFq2FxGvHAfX4hIYyI2cvxxxWpnlfHNgDP8AgUCd/eST/0ld219oty9X/xFoZfpFPxR/E5527oJRLStpRxklTb5DGUsf6hrVrivk2Pc/95cDCNjb8/sxszXO4E8KlJ7iwvEARNcxYWVrm1lEUMQnXM+1e5Kod78mb84TVI9TFcd3Kdx5AZPDD2NR8q0hvIYKTtJgv4YMAxHz6KzVW9Kyuap9V06VXXPA+ArsaY5T1KwaeNjwvuCyfgf+1EEwnBPnxBHfw== 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)(39850400004)(136003)(376002)(366004)(346002)(44832011)(52116002)(26005)(186003)(83380400001)(5660300002)(316002)(16526019)(956004)(36756003)(6506007)(6916009)(2616005)(66556008)(8936002)(66946007)(6486002)(6512007)(8676002)(478600001)(66476007)(69590400012)(6666004)(2906002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rIFwAA8Vrq3xHzm+hisbDd/xErUypd/egl4af/Pd7jbpG+A+4R78mhvGTBiKd5MN8mq7gsryvqiRWSRK7n6QTefEWIxwSQnWhRjZEfckRy8EdOQyyRwWt1W20WQQRTvW8zdMDH71WsEsVx0G2C8R6AVzYRAFlIWVyeevTAVys2+FzsIcq1w9mRrPGkid5duPD9ylluENlVOcb99qLEvrJzq3df6yCLxzxjBecH90Pq7zjJgmxiGgGy335KQ8IOC0qH4zjMTE41hdqv1IfgXm7st733PfTgBvsNgCZKnc/qLnzmC7kyUgwQscRzW1WafMVrWX8fzCaRJoiUWHM8nQ7l1M6JitFHYGUPX4OZWvqmJjcOS7XKAurLmus5TMlUhamnfPlzHFUU0NZXKeyBLMC8eCwVGrV7TEKR43EegXxDdlaZF31i4/yOGFP7NodS5ZWiqX/SaPiglGFDgklm0Ejn6GF0pns7HiVMI0momA2GQr0Jc3pLebLaAyFwbM1ZPmpcK9tmwm49p9wbkOWCBXuRjnU60BQ7ukJEusj0qqBxRpm/H+LbsfswBtefSO9jIKrfUWwhU7guQPaUx9fCQT0hbGdc/LcHTilXu47nwSbXX5DAbssVIxL95RErqplrX90sJGuvrOX+P5+MVzO4G7o+Nyi0rxcKOLwo2ScH3el3+WoKLNyGB5zgm0qlMQhnhXWwh9Xyncndy3KpLQXOQJoAmy2r+fb4v5EcGhEM8bG4vSiuAzsbTrwipe5Lsj3EmUtVUI6lkbYhafAG60KhCmTpmOsO9auNiDVy2sa90vQsIbDBpfWn9KdTZXC3CHzsuuxGXxK4JN8psE/ZsLkzZ9AaSW60R9Z5/g5uAgEC8TBktYUypFwue3XbS2v0jIWTWhA8nQVa/cu1FnBVnRgzD7o3Puj0EWRmC2sC1vef54U+QasyBxkxqyZRcPO1ltvpG9S46HBe8hktnsMNWyGf/F/uGCtbzt+QQT4tpKAg04YnSRipuiGakzX6DvmlUq1mWlxKB5HgONHdYHP1PdkDwky3MmX3co7/GoavRmzLKQM4FAiWI3hG1wFTXf3DXhy8rWn/AtepKlWDztPxjyrufjYt9Cq19hHXQHhHG8gbRWF8MgicHgSU3zgWohbi+adokD70I8clJZqEQI1J1oULL4XkrZsmRYWtNTXroT4sYVFlbcfIMHyVvmmCyUvI4iktLi1+go4n7lMDZ8TYdpRZAXOVELDXmFcBSNXcO35fagIunOOMTcK7UD2nRqnqaRdQjGqqmAFjSQ0fO6yyZ4vOWdVlVSybkr1LITpVjfIadJqMKizz3A/YflKbtgK3lbh21Y X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4809 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: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3ab9a3f1-f717-496b-7d6a-08d8d1a9948b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N4wm+/BP/2ls1BsuubYOmPzjph0Uz4FyNH++VNYgWNqkV/Yd6MgDHQPd5NCaRQoGlUM3Rtrmrb5Ewuj/cxwreQqe30BxsFgXP2ULN3MKrQMF0/6Y1da8ZWd1+LKhv9GmflMhexR/R+9kmRdT/DM3nHvFVay9PzQIdig/nXdC51cPxAXZehmalI5o+qmls24JjHq7XuWm25IjrK++EnzQM/+tuJt60lBDS0ML1NGSX+0MCGGrV/2A/ATMbjGGx0euH7O/wjcyNbqMHWm/s/OipDDHx+sazTaTFbd4bhCg8cr8VWOkMVDH7rpsVKkSremlMmS1xW8xRSU3/XXKf36E5eH0+tYZA6fpu2BGSxnTIu9kSIw5CM25MH/Ycl4LRROOM0g0yiUmK48ppfvLVulr67Fqp0nMU1qPImOQb/Z44RU2nsDcA4mevQJLANObG4WQmEeK6Tvm88mca8q2T+UwJbzRDl4+s7T5FwOTfV/1JDUeiuapQdAGFeDzSZignjESV2/T0aJe60VkmsRrml63twiZllIJZnDQWWAKyy7PygGAgLw07ywQxAAtiV0vCA7YZGAoXuo0baE8isBBjsuzyxxnqQBHvpE12PjB+jMQWqEbHJZBdNWBYR0j1VXxn+Cg+D5q41WytpBIo3OGfkco0hO8oJGM4uVMvxaAsXQKLBbLLZARoa00nx/+fWXtiQlP 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)(396003)(346002)(39850400004)(376002)(136003)(46966006)(36840700001)(82310400003)(36860700001)(2906002)(26005)(47076005)(186003)(16526019)(478600001)(956004)(2616005)(6506007)(336012)(44832011)(81166007)(5660300002)(82740400003)(8936002)(6512007)(316002)(86362001)(8676002)(36756003)(6486002)(6916009)(70586007)(6666004)(70206006)(83380400001)(356005)(69590400012); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:02:43.3018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e246aa04-051a-45ce-8644-08d8d1a999e1 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: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3615 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Lazy tlsdesc relocation is racy because the static tls optimization and tlsdesc management operations are done without holding the dlopen lock. This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67 for aarch64, but it fixes a different race: bug 27137. On i386 the code is a bit more complicated than on x86_64 because both rel and rela relocs are supported. --- sysdeps/i386/dl-machine.h | 76 ++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 23e9cc3bfb..590b41d8d7 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -688,50 +688,32 @@ elf_machine_lazy_rel (struct link_map *map, } else if (__glibc_likely (r_type == R_386_TLS_DESC)) { - struct tlsdesc volatile * __attribute__((__unused__)) td = - (struct tlsdesc volatile *)reloc_addr; - - /* Handle relocations that reference the local *ABS* in a simple - way, so as to preserve a potential addend. */ - if (ELF32_R_SYM (reloc->r_info) == 0) - td->entry = _dl_tlsdesc_resolve_abs_plus_addend; - /* Given a known-zero addend, we can store a pointer to the - reloc in the arg position. */ - else if (td->arg == 0) - { - td->arg = (void*)reloc; - td->entry = _dl_tlsdesc_resolve_rel; - } - else - { - /* We could handle non-*ABS* relocations with non-zero addends - by allocating dynamically an arg to hold a pointer to the - reloc, but that sounds pointless. */ - const Elf32_Rel *const r = reloc; - /* The code below was borrowed from elf_dynamic_do_rel(). */ - const ElfW(Sym) *const symtab = - (const void *) D_PTR (map, l_info[DT_SYMTAB]); + const Elf32_Rel *const r = reloc; + /* The code below was borrowed from elf_dynamic_do_rel(). */ + const ElfW(Sym) *const symtab = + (const void *) D_PTR (map, l_info[DT_SYMTAB]); + /* Always initialize TLS descriptors completely at load time, in + case static TLS is allocated for it that requires locking. */ # ifdef RTLD_BOOTSTRAP - /* The dynamic linker always uses versioning. */ - assert (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL); + /* The dynamic linker always uses versioning. */ + assert (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL); # else - if (map->l_info[VERSYMIDX (DT_VERSYM)]) + if (map->l_info[VERSYMIDX (DT_VERSYM)]) # endif - { - const ElfW(Half) *const version = - (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); - ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff; - elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], - &map->l_versions[ndx], - (void *) (l_addr + r->r_offset), skip_ifunc); - } + { + const ElfW(Half) *const version = + (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); + ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff; + elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], + &map->l_versions[ndx], + (void *) (l_addr + r->r_offset), skip_ifunc); + } # ifndef RTLD_BOOTSTRAP - else - elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL, - (void *) (l_addr + r->r_offset), skip_ifunc); + else + elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL, + (void *) (l_addr + r->r_offset), skip_ifunc); # endif - } } else if (__glibc_unlikely (r_type == R_386_IRELATIVE)) { @@ -758,11 +740,21 @@ elf_machine_lazy_rela (struct link_map *map, ; else if (__glibc_likely (r_type == R_386_TLS_DESC)) { - struct tlsdesc volatile * __attribute__((__unused__)) td = - (struct tlsdesc volatile *)reloc_addr; + const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info); + const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]); + const ElfW (Sym) *sym = &symtab[symndx]; + const struct r_found_version *version = NULL; + + if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL) + { + const ElfW (Half) *vernum = + (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); + version = &map->l_versions[vernum[symndx] & 0x7fff]; + } - td->arg = (void*)reloc; - td->entry = _dl_tlsdesc_resolve_rela; + /* Always initialize TLS descriptors completely at load time, in + case static TLS is allocated for it that requires locking. */ + elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc); } else if (__glibc_unlikely (r_type == R_386_IRELATIVE)) { From patchwork Mon Feb 15 12:02:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42042 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12FE63951C2B; Mon, 15 Feb 2021 12:03:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12FE63951C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390599; bh=fY510zbhBdiSBRlQ62iKecyabl2GFv4tUqzYcDusAsM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Vwpt5GulaK5Epj+hg4fdENpepTnmI7NOrUXO3lzBJzWGYsIBGzdHHPxXDQ9GOro3c D2kY8VOqYJaemTPSULESN7UMO1kkQoHB1tQl/ex4vDUn1js9UjILVg1+qSg/hNeJwA frmxvsy0MC8GJs58inf1CbN30f1m0WJmqLRDkj88= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0631.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::631]) by sourceware.org (Postfix) with ESMTPS id 2A1273951835 for ; Mon, 15 Feb 2021 12:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A1273951835 Received: from DB7PR05CA0052.eurprd05.prod.outlook.com (2603:10a6:10:2e::29) by AM0PR08MB3489.eurprd08.prod.outlook.com (2603:10a6:208:de::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.29; Mon, 15 Feb 2021 12:02:58 +0000 Received: from DB5EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::41) by DB7PR05CA0052.outlook.office365.com (2603:10a6:10:2e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 12:02:58 +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 DB5EUR03FT005.mail.protection.outlook.com (10.152.20.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:02:58 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 15 Feb 2021 12:02:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c15fa76bad4fd313 X-CR-MTA-TID: 64aa7808 Received: from de9d9db2db97.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1770B473-3306-42F3-9824-C950E57B95C6.1; Mon, 15 Feb 2021 12:02:53 +0000 Received: from FRA01-MR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id de9d9db2db97.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:02:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NkMxSln7DFcNk6BFxWTjnCrVfcyN++sBds4VKC6JBd+lkWN5tXG4VZ5PPu58bZJDbgfKF2Ffept9zJWrlo60mD+p8jA1wYFePlWTxMOz3TXOArIlUqznVeVkSUwkzXHoMZ1mgd56wg/5RrIPPFv4IjwbvbctgCx++VvJiH/eR+zDun4ktu3eQV2Q5WYNOG+x6ZbgUxlGtyFRsLZg5JsBRQAE/mfbFlshKwmNZMB8MakyHTXr4quR1zZgzp85xUrgGTEllbQVh7UPMaz/SzV9wj6l0R3V/qtvdM4C7Z92d2brdgks1OXOyWG3a+/ny9bCkaLbHAHfkFNW6ydNSf7tIA== 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=fY510zbhBdiSBRlQ62iKecyabl2GFv4tUqzYcDusAsM=; b=RNRjd4rtInSIlSNbJBiAGpWXY+bmoJf8xr3S3znFUVbXnwoomaCVbFoob8JTyfseAIhbGm5igQxr5aK7V7p+uaIJJM/j3JJBoTAFOz4+VxNx/gkI8ZlA0gviY2AYD2CJat3yd9QD2Xax9rJ4rE8bwoWlT+BqRo5H5tqbHK5RXQ2HMMF1lc6JbcYWXDyiVYZFwJOAdeJzrhi3RRjQppa7ADg9Vg/sDWFgtafMqXdDSJoDUJdLjSBDmVQtMCgu2OuVl9zSuu/moNxx5rLiiKthCaUWEHX8DOWlEc27u9PbmQhK1WbbsUvsiqbjv+X9wXBrgPsrFDCvL/K8VgHTEwSWjg== 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 PR2PR08MB4809.eurprd08.prod.outlook.com (2603:10a6:101:1a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 12:02:51 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:02:51 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 13/15] x86_64: Remove lazy tlsdesc relocation related code Date: Mon, 15 Feb 2021 12:02:45 +0000 Message-Id: <59686e4319f63d809adfb03cd7fbd0d0bb323b70.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P123CA0071.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::35) 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.49) by LO2P123CA0071.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 12:02:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eaae9e8f-0346-4c00-b07e-08d8d1a9a2dd X-MS-TrafficTypeDiagnostic: PR2PR08MB4809:|AM0PR08MB3489: 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: LscKRxGpXJHnduVo/fwsXQwvXYE8eoccnntIFGwTanjPxUeK2+EzI3wgAlEMN3ZBdjq0qYOfLYdiRMSy6SbKIuWXoyATyH6vELioNUJkuRVnnXZHmLGFpSjcf0mY8J6aOnIfHFceqAYVhnR2EBVEmJa2R5PrGbNuRrxGCsb8kLm/OGxIBPCL7etwbgSjSCoq7xRw/JRZStKgFN5V4aqmLYqNUJI8OYbUV0EG10XqN3ivuYpf1u7npyZtY6hh2ziQ8o2fTCub/IMMWmS5C2hspnEq54rkn1S0sZNrmdy8vnFsLo5Msf2ee/y+if/TDy8m4nGkVJ6BVO6paw+66H5IFqSmEq9Fzl8OiQgqa3MaoT8O3QF0PSTP7K0pVUTTpXOa85EIiRXFQEsk379+edJaEpilqU9Co665cMMQ4RFBnNXw594QQnUUSvUtIXhvEjYMqHTPTP12LuM5tU562eiYz94RrqOTGjR/DxnMtkaxRkHTnuFq5tk1y9nwCavF7E8mNl0QXQhfnIxO3TLfQdrEJ+DGt1EOd9nkbK0Z/WenAXotixJEcvHfK9zrXLqRyIhz/jNSNDU2Df7jwQ/EBeBUl+ENFEDuPgPGRRjqKY+j8fVPhc1WZQz1M2O5ag6f/U1N97tmSMxek4pADew251sNVUEVSSSkLrrOgOxua1TrOr4= 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)(39850400004)(136003)(376002)(366004)(346002)(44832011)(52116002)(26005)(186003)(83380400001)(5660300002)(316002)(16526019)(956004)(36756003)(6506007)(6916009)(2616005)(66556008)(8936002)(66946007)(6486002)(6512007)(8676002)(478600001)(66476007)(69590400012)(6666004)(2906002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /8chiXGsaCByW4gz4gK44CrvLMsMqUTPpWDwfeNtuC+MONU4qOh8JrbtU6v1ntXvq/dk0Gp15/OXzGbEAmDaYNVQLvE4a6YsyRTF7B2evfXoO/M72s0ZNjXRx3eg68TVl3fhVF3yRyG11tIAh209bcNhNc6NzxrCotyqa+UnDOJTB90GJtaj2DFggq6yLQ78vFRgfj8Ymeya33TACZ0Ae3rsKgSsdmhncLUE1UKHupuGkTxQv1u41sLCxxFiIn18uwMwZDYxhuipOXyCmHvknX+XbuJzJ7zgqr+NftBv7kEQKMH9CPmkWpDH0CD6atEKxvaxTSWcoKV+cfKNnIbYCBJbziFnkcQL+FRsmpX6JhK0rGUHO30pHzsLU7aZenrczeKOJmiua9mnzvbwy8l5aCDyOp3CRa7ggKQZhTZaQzEgZyT0ObtGzQSOXpyOCam7dgp4e5JBqSNsYviQjATtPnG6iDyH/HvPTwIAbecD2Orw93tmb28JqgTXMCy721/o4MX/mWg+zHN9dWE6Cq6nnSa9jn46odqjPPkO4bGXy6ot+dEO+6bZUGqaZZiNU4DoN7JGuUx/XPCPNvEWFF+simNnKf6vLKRPHvnQALg2qiRXLIlVkNgUEKr0C1RDjHQ8ugHg/rQJBmbtV0JYpLzTOAqLK3Rt6pDiDP4CfEcBm9mzrMriKWRNsRA5t4M1xlLD+1sR0W9zTZ4gpeRMU1TYg0Hy8cq9MOaLqUCwlxzh8FZqco0a3P+xe8ESttyUlQGdmWHVM1tTRM+9EbFXVmrDgwO/tyvZY0/lloX3BBqKJXCLdj17yIxebCXm78M+PFVHA8M9EU6KTysTTk3ahAnXt86kQVQIG6n+aG+RlR75shaM5UGtoex+7VpeO4tTYxhkFmMek8odL8p/jOrZI/a5hfmdTlJfP34ntqaGFGT75vvtNC00I4NfwPgr31/jKWs4q3Y9HUFvR/3JTIxD6BOQAo5CLuWtlxj1rjg5acGhXD/c7+trgFyA53KJCUPYbaJDJo3qqL4kdcEXWW5nbkbRGDwCjth9GoVD8McgtxjPcj4jIHRMWPF4M5CcQ5KHYzaQgVap2AluylJVxjrdbga8hN8dASRS9gy3iJ2oAa1tEul8oiwO4sH1ZkayDxCTTfGPJvqvInvayH/qgibcG7K/p+l+rLWkolFOMYl8mHHuItRH0FPH8ZIUvj2b0TOBxJ2EzbiEQbXTmoAmi+b9bM6JVuoCAyitOepn8lClCs5w5t6NYANsXIqqL8Z+M9quSmDC4P65cg3FQqPiWDFoOEv/MQ8I4DHyAXsWhoGhyu86nY3MDvG9SSgC3Kf3FHPcywpY X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4809 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: DB5EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4800881d-6dfd-4c5e-7194-08d8d1a99e8f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9lEz8pa24NqCD1XnYpzatDxvFyjtClEP+Czr1ii0+pbQshJBx8+E8UJwx3rQuDl9oriGFzWIqjy1Bi40cg52auMzZmGnpy89OjgaV18lI58NBil/Gg5rpdlzrj+6v1K3kj2/yjmuyqjBfYaevTNVNwCShKv0EZfGIkhsiOy1u0LDARKSY6ZdtRuB+iVT/CqcKXtzRd9YHGF3awojtiZ47FzAWQ+i5aKBZMUVzll5LTZYQUV6k0IB9PheduRIJ/5bE5o/r0Qqijnai45ceIB0iHe6+XYKANJlv8Jenrb4WuQEhdQnAEbKqMbyKBdZafj7zWRJ+FjOC/cqLk5yaDEbQcF7mRpXstJE9E+gSTu4hEeq1G+IcHSpsTrmbfp7QxyL0OG8PjZxG4xzEYjS+u/fM0UITpD5lu0SicqBERf8WRDoGhfa8p7mGdUTnPLZGX5TH+72hr1W6JK3pFMkfA5QIY9npfmtJE97nAiUMZRYX3qkQM6s+4bqft00tn+Fu7Avumix/adNNfraz88M4Hrxn0X1SJKCdNiP5AGK5Spmu/EHoqsdgERtzedFsHjlGeBnn87WUqONJOmi8sB5+RmovGLQ/dV8OXjyGlUeOMMGCB0USfoPSiNaALEV71Sblhoq81aC1T/Lb2Z4h5TNECOEzFDtSbNxO/W/UDXfYbB1OLME/MyO5Pr4eV0K2pisblmRy/80+DrFlP8nTN+kSNe0SGk/MCBz0V2Gtvu9qjvt1ytRMRo+6ShbNLpZqIIj66YGkWhVbtmONr5492BHNV8CHg== 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)(396003)(39850400004)(136003)(376002)(46966006)(36840700001)(8676002)(69590400012)(6916009)(83380400001)(186003)(6486002)(336012)(26005)(16526019)(6506007)(82310400003)(6666004)(478600001)(8936002)(2906002)(5660300002)(47076005)(6512007)(86362001)(36860700001)(82740400003)(81166007)(70586007)(70206006)(316002)(44832011)(356005)(36756003)(956004)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:02:58.4961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eaae9e8f-0346-4c00-b07e-08d8d1a9a2dd 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: DB5EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3489 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" _dl_tlsdesc_resolve_rela and _dl_tlsdesc_resolve_hold are only used for lazy tlsdesc relocation processing which is no longer supported. --- sysdeps/x86_64/dl-tlsdesc.S | 104 ---------------------------------- sysdeps/x86_64/dl-tlsdesc.h | 4 +- sysdeps/x86_64/tlsdesc.c | 109 +----------------------------------- 3 files changed, 2 insertions(+), 215 deletions(-) diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S index 1d055adadd..ca9236bed8 100644 --- a/sysdeps/x86_64/dl-tlsdesc.S +++ b/sysdeps/x86_64/dl-tlsdesc.S @@ -144,107 +144,3 @@ _dl_tlsdesc_dynamic: cfi_endproc .size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic #endif /* SHARED */ - - /* This function is a wrapper for a lazy resolver for TLS_DESC - RELA relocations. The incoming 0(%rsp) points to the caller's - link map, pushed by the dynamic object's internal lazy TLS - resolver front-end before tail-calling us. We need to pop it - ourselves. %rax points to a TLS descriptor, such that 0(%rax) - holds the address of the internal resolver front-end (unless - some other thread beat us to resolving it) and 8(%rax) holds a - pointer to the relocation. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_rela - .global _dl_tlsdesc_resolve_rela - .type _dl_tlsdesc_resolve_rela,@function - cfi_startproc - .align 16 - /* The PLT entry will have pushed the link_map pointer. */ -_dl_tlsdesc_resolve_rela: - _CET_ENDBR - cfi_adjust_cfa_offset (8) - /* Save all call-clobbered registers. Add 8 bytes for push in - the PLT entry to align the stack. */ - subq $80, %rsp - cfi_adjust_cfa_offset (80) - movq %rax, (%rsp) - movq %rdi, 8(%rsp) - movq %rax, %rdi /* Pass tlsdesc* in %rdi. */ - movq %rsi, 16(%rsp) - movq 80(%rsp), %rsi /* Pass link_map* in %rsi. */ - movq %r8, 24(%rsp) - movq %r9, 32(%rsp) - movq %r10, 40(%rsp) - movq %r11, 48(%rsp) - movq %rdx, 56(%rsp) - movq %rcx, 64(%rsp) - call _dl_tlsdesc_resolve_rela_fixup - movq (%rsp), %rax - movq 8(%rsp), %rdi - movq 16(%rsp), %rsi - movq 24(%rsp), %r8 - movq 32(%rsp), %r9 - movq 40(%rsp), %r10 - movq 48(%rsp), %r11 - movq 56(%rsp), %rdx - movq 64(%rsp), %rcx - addq $88, %rsp - cfi_adjust_cfa_offset (-88) - jmp *(%rax) - cfi_endproc - .size _dl_tlsdesc_resolve_rela, .-_dl_tlsdesc_resolve_rela - - /* This function is a placeholder for lazy resolving of TLS - relocations. Once some thread starts resolving a TLS - relocation, it sets up the TLS descriptor to use this - resolver, such that other threads that would attempt to - resolve it concurrently may skip the call to the original lazy - resolver and go straight to a condition wait. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_hold - .global _dl_tlsdesc_resolve_hold - .type _dl_tlsdesc_resolve_hold,@function - cfi_startproc - .align 16 -_dl_tlsdesc_resolve_hold: -0: - _CET_ENDBR - /* Save all call-clobbered registers. */ - subq $72, %rsp - cfi_adjust_cfa_offset (72) - movq %rax, (%rsp) - movq %rdi, 8(%rsp) - movq %rax, %rdi /* Pass tlsdesc* in %rdi. */ - movq %rsi, 16(%rsp) - /* Pass _dl_tlsdesc_resolve_hold's address in %rsi. */ - leaq . - _dl_tlsdesc_resolve_hold(%rip), %rsi - movq %r8, 24(%rsp) - movq %r9, 32(%rsp) - movq %r10, 40(%rsp) - movq %r11, 48(%rsp) - movq %rdx, 56(%rsp) - movq %rcx, 64(%rsp) - call _dl_tlsdesc_resolve_hold_fixup -1: - movq (%rsp), %rax - movq 8(%rsp), %rdi - movq 16(%rsp), %rsi - movq 24(%rsp), %r8 - movq 32(%rsp), %r9 - movq 40(%rsp), %r10 - movq 48(%rsp), %r11 - movq 56(%rsp), %rdx - movq 64(%rsp), %rcx - addq $72, %rsp - cfi_adjust_cfa_offset (-72) - jmp *(%rax) - cfi_endproc - .size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold diff --git a/sysdeps/x86_64/dl-tlsdesc.h b/sysdeps/x86_64/dl-tlsdesc.h index d134b3f4db..03d5ac7a54 100644 --- a/sysdeps/x86_64/dl-tlsdesc.h +++ b/sysdeps/x86_64/dl-tlsdesc.h @@ -55,9 +55,7 @@ struct tlsdesc_dynamic_arg extern ptrdiff_t attribute_hidden _dl_tlsdesc_return(struct tlsdesc *on_rax), - _dl_tlsdesc_undefweak(struct tlsdesc *on_rax), - _dl_tlsdesc_resolve_rela(struct tlsdesc *on_rax), - _dl_tlsdesc_resolve_hold(struct tlsdesc *on_rax); + _dl_tlsdesc_undefweak(struct tlsdesc *on_rax); # ifdef SHARED extern void *_dl_make_tlsdesc_dynamic (struct link_map *map, diff --git a/sysdeps/x86_64/tlsdesc.c b/sysdeps/x86_64/tlsdesc.c index 4083849f22..ecf864d6ee 100644 --- a/sysdeps/x86_64/tlsdesc.c +++ b/sysdeps/x86_64/tlsdesc.c @@ -16,120 +16,13 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include #include #include #include +#define _dl_tlsdesc_resolve_hold 0 #include -/* The following 2 functions take a caller argument, that contains the - address expected to be in the TLS descriptor. If it's changed, we - want to return immediately. */ - -/* This function is used to lazily resolve TLS_DESC RELA relocations. - The argument location is used to hold a pointer to the relocation. */ - -void -attribute_hidden -_dl_tlsdesc_resolve_rela_fixup (struct tlsdesc volatile *td, - struct link_map *l) -{ - const ElfW(Rela) *reloc = td->arg; - - if (_dl_tlsdesc_resolve_early_return_p - (td, (void*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_PLT)]) + l->l_addr))) - return; - - /* The code below was borrowed from _dl_fixup(). */ - const ElfW(Sym) *const symtab - = (const void *) D_PTR (l, l_info[DT_SYMTAB]); - const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]); - const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)]; - lookup_t result; - - /* Look up the target symbol. If the normal lookup rules are not - used don't look in the global scope. */ - if (ELFW(ST_BIND) (sym->st_info) != STB_LOCAL - && __builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) - { - const struct r_found_version *version = NULL; - - if (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL) - { - const ElfW(Half) *vernum = - (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]); - ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)] & 0x7fff; - version = &l->l_versions[ndx]; - if (version->hash == 0) - version = NULL; - } - - result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym, - l->l_scope, version, ELF_RTYPE_CLASS_PLT, - DL_LOOKUP_ADD_DEPENDENCY, NULL); - } - else - { - /* We already found the symbol. The module (and therefore its load - address) is also known. */ - result = l; - } - - if (! sym) - { - td->arg = (void*)reloc->r_addend; - td->entry = _dl_tlsdesc_undefweak; - } - else - { -# ifndef SHARED - CHECK_STATIC_TLS (l, result); -# else - if (!TRY_STATIC_TLS (l, result)) - { - td->arg = _dl_make_tlsdesc_dynamic (result, sym->st_value - + reloc->r_addend); - td->entry = _dl_tlsdesc_dynamic; - } - else -# endif - { - td->arg = (void*)(sym->st_value - result->l_tls_offset - + reloc->r_addend); - td->entry = _dl_tlsdesc_return; - } - } - - _dl_tlsdesc_wake_up_held_fixups (); -} - -/* This function is used to avoid busy waiting for other threads to - complete the lazy relocation. Once another thread wins the race to - relocate a TLS descriptor, it sets the descriptor up such that this - function is called to wait until the resolver releases the - lock. */ - -void -attribute_hidden -_dl_tlsdesc_resolve_hold_fixup (struct tlsdesc volatile *td, - void *caller) -{ - /* Maybe we're lucky and can return early. */ - if (caller != td->entry) - return; - - /* Locking here will stop execution until the running resolver runs - _dl_tlsdesc_wake_up_held_fixups(), releasing the lock. - - FIXME: We'd be better off waiting on a condition variable, such - that we didn't have to hold the lock throughout the relocation - processing. */ - __rtld_lock_lock_recursive (GL(dl_load_lock)); - __rtld_lock_unlock_recursive (GL(dl_load_lock)); -} - /* Unmap the dynamic object, but also release its TLS descriptor table if there is one. */ From patchwork Mon Feb 15 12:03:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42043 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1253A3951C1D; Mon, 15 Feb 2021 12:03:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1253A3951C1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390602; bh=YuJrvpT5gwhaz+358P/wSQY9SEOO/KLMwa7K0Er3SxE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NkWW2yZgl6OLJDCMzpnMwN19V8gXYUeSPsUBBouf9207sVP+3GFecNdx6h/p9+E5J Mj6P/rvlsYky29E0HYo94+lIL/oqHmRWDqYk+TUAxA9Rja4jTyF0NMD1fCZH/lFrwD lJdHtSckTWHrVJUt4aEOK5hRgbGCKYr/K3TpX46A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60085.outbound.protection.outlook.com [40.107.6.85]) by sourceware.org (Postfix) with ESMTPS id EEE1C3951C1D for ; Mon, 15 Feb 2021 12:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EEE1C3951C1D Received: from AM6P191CA0019.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::32) by AM0PR08MB3266.eurprd08.prod.outlook.com (2603:10a6:208:66::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 15 Feb 2021 12:03:16 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8b:cafe::f7) by AM6P191CA0019.outlook.office365.com (2603:10a6:209:8b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:03:16 +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 AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:03:15 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Mon, 15 Feb 2021 12:03:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7c927ee53020855e X-CR-MTA-TID: 64aa7808 Received: from f050e3d88eed.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 44B0F551-BFBF-4FCF-A112-1810C3B565BD.1; Mon, 15 Feb 2021 12:03:10 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f050e3d88eed.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:03:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8TY6YsuSyaoMsZW1pXk46Flo0a9AhJBd3PyJTLMg9YObi8JL7ALgHbXyKpdkm7z/jjjmMDEEHv32PhZfYw3zKtD8Qd10McghNSA5PSwq/T0VQf/kt7QtJV0EWtCe4qw1iX2Ip1ZWRkUzWurKcV29QB3XfBPyYyzZ7hfNU9/dPPMfM6I0NYghxOTdXsejePLXQWmRt3I8IW8kbgnoP8/TvcJWwArnSEY4R0KBs8T3DfSolwjaia4gIAnYKGydPBDbCEA3wbqAqvZ8ekdbDvulyKII7VtYaGBTF4CFHqdlQtTUq2KKs/mXuCGw1gnh4C6XAR/8OgO+6PSwia3EPzUsw== 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=YuJrvpT5gwhaz+358P/wSQY9SEOO/KLMwa7K0Er3SxE=; b=Inx/Vr0X845T11Z8/FuCEhWDJGZ4BJeFJf1GXdYVHF8/6YkkMLUro3pGwAOlQ8ysgyY25iy3gUy284b5b2fmVK1VXNEIzA2+jp3Iho+LwQ/0S+lK6dhhjO4NUGPtaLFwTEAunk7bClfhoXJfiEHufet2ZLwHU5fbDt7tQss8Oh2HMv6Njz96PdghA7AN8wJfHYVTdETOnX8KM5OdMKmQzINTj//Y8fDKwKIPhIjc9CX5V0MNCLmPIdf5WjpFQJCRm5QJCYI16TcG8oAzSH3Ppv3FIbt4eHu+wUN+Ww4SCM9bWlQev6cv5Xub+0k2uteajbALA9O/M3hoQ7DSfwm2gQ== 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 PA4PR08MB6208.eurprd08.prod.outlook.com (2603:10a6:102:e5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 12:03:08 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:03:08 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 14/15] i386: Remove lazy tlsdesc relocation related code Date: Mon, 15 Feb 2021 12:03:02 +0000 Message-Id: <9a60780a0f26c6bd124f0e06b8e1e25cce7728b3.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO2P123CA0108.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::23) 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.49) by LO2P123CA0108.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38 via Frontend Transport; Mon, 15 Feb 2021 12:03:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9b42a71d-9337-4b2e-7a2b-08d8d1a9ad41 X-MS-TrafficTypeDiagnostic: PA4PR08MB6208:|AM0PR08MB3266: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: zXO3GMS/1pYKwwVLptSFSMu+53ZOZAIgkk4bX4bHqhtYWfGn6J7FNf8409LNc/m4BcLYIH9Mk8e71QMwDRezmWPvesZZVgzgZKPa0HFthR7I1pWeQ++VhsGmXa9ORi14kXEo4OQ1pvmsOHN2jkIrVfWUtIjYI9mEKyuyCw2I36me+bsx92pS8c6hn4S66Icz6sTidfVSiot4VNsZEGZWwYWmDeubaVcCYJT43bFtjcw1kDiQciO+o9ix8soadn61Ol+N/Piz2FDaT01DBeRQqggUnAm9AfaloBjUe7zKI36bw7YtycyMkbUVIZp8EUuW8fnyVp3yu4m8XCbo8jGdHLCJLtB8lqtYDw5nW9bDF6kvo9Sn6KQxdXh5Q2bfHj0tfU0K5RTF1Qx9xWY6anEe9zjxyDWC4T0tJ9MW7Ar1tjlraH1kCS3ZmQ8zUgHrzbb8SryawBAy5QGzLb3Ltd58kuWnbhguoVIqQnvrH7DPQ0U8QdgZ/r9U8k1Zh9wUdhLrcPPKutdRql8IQUeAIq1XSDk/sDQo6/yT0bPnCFxzQVXuU4okPHQKjiJnoEUChXxeIjp+Go272ZEDZAkmiNGwkNJesJsDcxYfcLGtaK+NWCKIuJQcoutp2BPci3QLEz/o/cI5yokS2eFxHfSeNewBXg== 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)(366004)(396003)(346002)(136003)(376002)(39850400004)(2616005)(956004)(44832011)(66476007)(2906002)(16526019)(66946007)(66556008)(6916009)(186003)(36756003)(6486002)(478600001)(30864003)(5660300002)(26005)(6666004)(86362001)(6506007)(69590400012)(316002)(83380400001)(8936002)(8676002)(52116002)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: zKIHgNFhO/1W7/1OtMNwPSmc415gYSxu1XXRXs6pH7DeJm6r2CIT3ouqwx3f9K2i9G5PBZqOUryGJ2xtyI/YhBgR9/mdqifkAtjrY5KV4zfY6VU9m9OYajXgH5F50SRRQAaECTHHWCR8NuPjqAszUuebde1ZoFVam0vbmHHRmF0+YYG5833Z8AyBnof76tIc6Hai7oqHPBgDc46vEo9ZYPTdKLrqk2o17D3ZMfPBmoqzSaw033Oj0UBxuPu0cU0kEybUelBv0OR2MEnhXMZloTGpbymWYXOmzeZY/9bXGcVABL8gujt/lM9p0ZnBkqqOB93vzNAd2/CD07+HWHn8xes+ed08uOIM/9AdA+KmrAebHh9jDQVcOnO6qoY6Dw0UR6ffUT6NQjIP28QpduKtu1aKxyRfeSeAhWJ2dvk5AVkPlXDn8hUU+tuE1EWtW/DzOLhp896uxOG5b2SP+RkTog4nRm68JP8Xf9Z6Suh24+w9tMMT4rmBSy1htT8u3hHRRDW4HUmplFJrMPLGGxbCHza/KiMRBFwKYScPgak9YtlMBCCSTF+XxkOmRCRiRwfPEC64KDuYKj8u6X3lE/6lpSFDVJMHkhmzMgDa7Yv/bVnTiOvhdpWEB5M1ZlNt03JFPRng2QHUCQ2EjyXKOs04GhVYzD0egrVoT81i4qsUwbxz5zFzykG+fkDGRR9XAHe9umXygjy8tgOOG/DYw+NoKRbWAR9hc+LRr448bEplyLG2dQPd4KuFMw0gNa18Q2xbtUaAUDdPWavE7KzerK4Mfbn2EWU/h8mwOSBPhRtwiYIWPWTYowqGXughwsE+uAgYyPjuLu/nPpmX/Sa9qlP2TsGAXmxH23FXN+ldgCirYE6dJr1t4ZFkqDWFU3a2XsCuvGJliuZGO41IyaxZaHtrPx26kNkAPiaftDTf/VIn1J6g76dMRrLTKS05Yq3wVufkmhENYidtDBQ8yWWwpD5k2VQlFSO73zv7CGJzRDqB79QTvlgUDD28g3hIsBOWLaeZfsN9hhnn86KXHkOTMhJg/h/nxIZk7fEnNpsSRyO3iRaIs90bunYW9bSw0CHGeR822MsuRgDla2JDwh51oBreH8Ny977K7qbjRt1BV6tA+L+GFa3igeL9CQP8vf6GZ91ff0PYjDANbn+0ny+M6AEVMmgQZTdeQpz2hef7rCHTDZL3EQPo1A2nU6aNFK/8wB7N+Qput+sp3yJ80dMt7FA7FEaRbolI2/vNwoXNwxzijfea7Q7W/SbpiHzuvoTvgqrB4ofByp3GzmP0UVQcbzitbCqput8PzPdH3jG3aMrl7MZYUGyQ5Oa1T0084IDx6tiw X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6208 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: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 89d3693d-ea52-4247-b076-08d8d1a9a89a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +5Nu8hHmqDYnB1Fwh1dVpNURlXNZOICfgwcVts0Ba+okM1hZV40Q4b02akPwh1ocSxLtTZn+yAIn4MsdYXQ1Z6rrLoexFks86Q+5NBKYyevvsBY2ET4W6YWAHFBOmrWiuDZhlYlm2dnh7nctW9vq/dZsbsY+JRjE1lVIkizD9t0bSTomnc+OjBinysGFEHqOSy/NLl+favCGTE2vnModLs8GcesGuarHE5Sp0Qwb7ejvhH6wXdww87ytnvjKb64QhWMqIqwRLVU8smen/kc+BAwDs7zy210Hf5sVR16F5y1AYTmhuake4+2XNWp6vAZw8agDZ9t4rVGwWWpXQvnJLPx4FSXeSIcxAHm33l2u/fUMJbZv7q+iSwOUE8pA3X7sxDYL9UkHdGJrMlWhLQe5b0GS+mMrDTWWlKcjNzx47kPzJh0QsjzhxHz1EJPVI21URWL8guhv8o4kwMTPa8Va8apsmZOcWgtkCqgLV2D77o3tv3HrP7iFfB4ER+Q5eHH41MSt+YXFb0kdgGlqRRj9uOjERiwBe6xGMkUham0QEnpmPthEZJNgWyJo+eS/LP3yDpYNIus3/w7kyV6x4qS/l2LCnaADLYSRhk6C3ThVw0P1x/jHI8oUNvx3/OhT8IYiYGeQv79t5IEa40b47z69dAzfkBAkDZqICWGcOxHL+gkf0ttI2m2Od/KzfQjt4o+KH/wh2vi1qpHs/mtUSMIn294hn0I6MKS7E1tuGnfYloMYL5dJIEWbe5Xmw6Y3KzHA2puoihGfmqHVZuo/96B8GQ== 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)(136003)(39850400004)(346002)(376002)(396003)(46966006)(36840700001)(6506007)(2906002)(83380400001)(16526019)(2616005)(186003)(336012)(82740400003)(8936002)(26005)(8676002)(82310400003)(6916009)(956004)(5660300002)(86362001)(30864003)(36860700001)(70206006)(70586007)(36756003)(356005)(478600001)(6486002)(6512007)(6666004)(316002)(44832011)(69590400012)(81166007)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:03:15.8573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b42a71d-9337-4b2e-7a2b-08d8d1a9ad41 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: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3266 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Like in commit e75711ebfa976d5468ec292282566a18b07e4d67 for x86_64, remove unused lazy tlsdesc relocation processing code: _dl_tlsdesc_resolve_abs_plus_addend _dl_tlsdesc_resolve_rel _dl_tlsdesc_resolve_rela _dl_tlsdesc_resolve_hold --- sysdeps/i386/dl-tlsdesc.S | 156 ------------------------- sysdeps/i386/dl-tlsdesc.h | 6 +- sysdeps/i386/tlsdesc.c | 231 +------------------------------------- 3 files changed, 2 insertions(+), 391 deletions(-) diff --git a/sysdeps/i386/dl-tlsdesc.S b/sysdeps/i386/dl-tlsdesc.S index e781d973b7..255fe88651 100644 --- a/sysdeps/i386/dl-tlsdesc.S +++ b/sysdeps/i386/dl-tlsdesc.S @@ -134,159 +134,3 @@ _dl_tlsdesc_dynamic: cfi_endproc .size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic #endif /* SHARED */ - - /* This function is a wrapper for a lazy resolver for TLS_DESC - REL relocations that reference the *ABS* segment in their own - link maps. %ebx points to the caller's GOT. %eax points to a - TLS descriptor, such that 0(%eax) holds the address of the - resolver wrapper itself (unless some other thread beat us to - it) and 4(%eax) holds the addend in the relocation. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_abs_plus_addend - .global _dl_tlsdesc_resolve_abs_plus_addend - .type _dl_tlsdesc_resolve_abs_plus_addend,@function - cfi_startproc - .align 16 -_dl_tlsdesc_resolve_abs_plus_addend: -0: - _CET_ENDBR - pushl %eax - cfi_adjust_cfa_offset (4) - pushl %ecx - cfi_adjust_cfa_offset (4) - pushl %edx - cfi_adjust_cfa_offset (4) - movl $1f - 0b, %ecx - movl 4(%ebx), %edx - call _dl_tlsdesc_resolve_abs_plus_addend_fixup -1: - popl %edx - cfi_adjust_cfa_offset (-4) - popl %ecx - cfi_adjust_cfa_offset (-4) - popl %eax - cfi_adjust_cfa_offset (-4) - jmp *(%eax) - cfi_endproc - .size _dl_tlsdesc_resolve_abs_plus_addend, .-_dl_tlsdesc_resolve_abs_plus_addend - - /* This function is a wrapper for a lazy resolver for TLS_DESC - REL relocations that had zero addends. %ebx points to the - caller's GOT. %eax points to a TLS descriptor, such that - 0(%eax) holds the address of the resolver wrapper itself - (unless some other thread beat us to it) and 4(%eax) holds a - pointer to the relocation. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_rel - .global _dl_tlsdesc_resolve_rel - .type _dl_tlsdesc_resolve_rel,@function - cfi_startproc - .align 16 -_dl_tlsdesc_resolve_rel: -0: - _CET_ENDBR - pushl %eax - cfi_adjust_cfa_offset (4) - pushl %ecx - cfi_adjust_cfa_offset (4) - pushl %edx - cfi_adjust_cfa_offset (4) - movl $1f - 0b, %ecx - movl 4(%ebx), %edx - call _dl_tlsdesc_resolve_rel_fixup -1: - popl %edx - cfi_adjust_cfa_offset (-4) - popl %ecx - cfi_adjust_cfa_offset (-4) - popl %eax - cfi_adjust_cfa_offset (-4) - jmp *(%eax) - cfi_endproc - .size _dl_tlsdesc_resolve_rel, .-_dl_tlsdesc_resolve_rel - - /* This function is a wrapper for a lazy resolver for TLS_DESC - RELA relocations. %ebx points to the caller's GOT. %eax - points to a TLS descriptor, such that 0(%eax) holds the - address of the resolver wrapper itself (unless some other - thread beat us to it) and 4(%eax) holds a pointer to the - relocation. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_rela - .global _dl_tlsdesc_resolve_rela - .type _dl_tlsdesc_resolve_rela,@function - cfi_startproc - .align 16 -_dl_tlsdesc_resolve_rela: -0: - _CET_ENDBR - pushl %eax - cfi_adjust_cfa_offset (4) - pushl %ecx - cfi_adjust_cfa_offset (4) - pushl %edx - cfi_adjust_cfa_offset (4) - movl $1f - 0b, %ecx - movl 4(%ebx), %edx - call _dl_tlsdesc_resolve_rela_fixup -1: - popl %edx - cfi_adjust_cfa_offset (-4) - popl %ecx - cfi_adjust_cfa_offset (-4) - popl %eax - cfi_adjust_cfa_offset (-4) - jmp *(%eax) - cfi_endproc - .size _dl_tlsdesc_resolve_rela, .-_dl_tlsdesc_resolve_rela - - /* This function is a placeholder for lazy resolving of TLS - relocations. Once some thread starts resolving a TLS - relocation, it sets up the TLS descriptor to use this - resolver, such that other threads that would attempt to - resolve it concurrently may skip the call to the original lazy - resolver and go straight to a condition wait. - - When the actual resolver returns, it will have adjusted the - TLS descriptor such that we can tail-call it for it to return - the TP offset of the symbol. */ - - .hidden _dl_tlsdesc_resolve_hold - .global _dl_tlsdesc_resolve_hold - .type _dl_tlsdesc_resolve_hold,@function - cfi_startproc - .align 16 -_dl_tlsdesc_resolve_hold: -0: - _CET_ENDBR - pushl %eax - cfi_adjust_cfa_offset (4) - pushl %ecx - cfi_adjust_cfa_offset (4) - pushl %edx - cfi_adjust_cfa_offset (4) - movl $1f - 0b, %ecx - movl 4(%ebx), %edx - call _dl_tlsdesc_resolve_hold_fixup -1: - popl %edx - cfi_adjust_cfa_offset (-4) - popl %ecx - cfi_adjust_cfa_offset (-4) - popl %eax - cfi_adjust_cfa_offset (-4) - jmp *(%eax) - cfi_endproc - .size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold diff --git a/sysdeps/i386/dl-tlsdesc.h b/sysdeps/i386/dl-tlsdesc.h index 753c03e79c..12e90da3a8 100644 --- a/sysdeps/i386/dl-tlsdesc.h +++ b/sysdeps/i386/dl-tlsdesc.h @@ -43,11 +43,7 @@ struct tlsdesc_dynamic_arg extern ptrdiff_t attribute_hidden __attribute__ ((regparm (1))) _dl_tlsdesc_return (struct tlsdesc *), - _dl_tlsdesc_undefweak (struct tlsdesc *), - _dl_tlsdesc_resolve_abs_plus_addend (struct tlsdesc *), - _dl_tlsdesc_resolve_rel (struct tlsdesc *), - _dl_tlsdesc_resolve_rela (struct tlsdesc *), - _dl_tlsdesc_resolve_hold (struct tlsdesc *); + _dl_tlsdesc_undefweak (struct tlsdesc *); # ifdef SHARED extern void *_dl_make_tlsdesc_dynamic (struct link_map *map, diff --git a/sysdeps/i386/tlsdesc.c b/sysdeps/i386/tlsdesc.c index 0bc646541f..436a21f66b 100644 --- a/sysdeps/i386/tlsdesc.c +++ b/sysdeps/i386/tlsdesc.c @@ -16,242 +16,13 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include #include #include #include +#define _dl_tlsdesc_resolve_hold 0 #include -/* The following 4 functions take an entry_check_offset argument. - It's computed by the caller as an offset between its entry point - and the call site, such that by adding the built-in return address - that is implicitly passed to the function with this offset, we can - easily obtain the caller's entry point to compare with the entry - point given in the TLS descriptor. If it's changed, we want to - return immediately. */ - -/* This function is used to lazily resolve TLS_DESC REL relocations - that reference the *ABS* segment in their own link maps. The - argument is the addend originally stored there. */ - -void -__attribute__ ((regparm (3))) attribute_hidden -_dl_tlsdesc_resolve_abs_plus_addend_fixup (struct tlsdesc volatile *td, - struct link_map *l, - ptrdiff_t entry_check_offset) -{ - ptrdiff_t addend = (ptrdiff_t) td->arg; - - if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0) - - entry_check_offset)) - return; - -#ifndef SHARED - CHECK_STATIC_TLS (l, l); -#else - if (!TRY_STATIC_TLS (l, l)) - { - td->arg = _dl_make_tlsdesc_dynamic (l, addend); - td->entry = _dl_tlsdesc_dynamic; - } - else -#endif - { - td->arg = (void*) (addend - l->l_tls_offset); - td->entry = _dl_tlsdesc_return; - } - - _dl_tlsdesc_wake_up_held_fixups (); -} - -/* This function is used to lazily resolve TLS_DESC REL relocations - that originally had zero addends. The argument location, that - originally held the addend, is used to hold a pointer to the - relocation, but it has to be restored before we call the function - that applies relocations. */ - -void -__attribute__ ((regparm (3))) attribute_hidden -_dl_tlsdesc_resolve_rel_fixup (struct tlsdesc volatile *td, - struct link_map *l, - ptrdiff_t entry_check_offset) -{ - const ElfW(Rel) *reloc = td->arg; - - if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0) - - entry_check_offset)) - return; - - /* The code below was borrowed from _dl_fixup(), - except for checking for STB_LOCAL. */ - const ElfW(Sym) *const symtab - = (const void *) D_PTR (l, l_info[DT_SYMTAB]); - const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]); - const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)]; - lookup_t result; - - /* Look up the target symbol. If the normal lookup rules are not - used don't look in the global scope. */ - if (ELFW(ST_BIND) (sym->st_info) != STB_LOCAL - && __builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) - { - const struct r_found_version *version = NULL; - - if (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL) - { - const ElfW(Half) *vernum = - (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]); - ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)] & 0x7fff; - version = &l->l_versions[ndx]; - if (version->hash == 0) - version = NULL; - } - - result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym, - l->l_scope, version, ELF_RTYPE_CLASS_PLT, - DL_LOOKUP_ADD_DEPENDENCY, NULL); - } - else - { - /* We already found the symbol. The module (and therefore its load - address) is also known. */ - result = l; - } - - if (!sym) - { - td->arg = 0; - td->entry = _dl_tlsdesc_undefweak; - } - else - { -# ifndef SHARED - CHECK_STATIC_TLS (l, result); -# else - if (!TRY_STATIC_TLS (l, result)) - { - td->arg = _dl_make_tlsdesc_dynamic (result, sym->st_value); - td->entry = _dl_tlsdesc_dynamic; - } - else -# endif - { - td->arg = (void*)(sym->st_value - result->l_tls_offset); - td->entry = _dl_tlsdesc_return; - } - } - - _dl_tlsdesc_wake_up_held_fixups (); -} - -/* This function is used to lazily resolve TLS_DESC RELA relocations. - The argument location is used to hold a pointer to the relocation. */ - -void -__attribute__ ((regparm (3))) attribute_hidden -_dl_tlsdesc_resolve_rela_fixup (struct tlsdesc volatile *td, - struct link_map *l, - ptrdiff_t entry_check_offset) -{ - const ElfW(Rela) *reloc = td->arg; - - if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0) - - entry_check_offset)) - return; - - /* The code below was borrowed from _dl_fixup(), - except for checking for STB_LOCAL. */ - const ElfW(Sym) *const symtab - = (const void *) D_PTR (l, l_info[DT_SYMTAB]); - const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]); - const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)]; - lookup_t result; - - /* Look up the target symbol. If the normal lookup rules are not - used don't look in the global scope. */ - if (ELFW(ST_BIND) (sym->st_info) != STB_LOCAL - && __builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) - { - const struct r_found_version *version = NULL; - - if (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL) - { - const ElfW(Half) *vernum = - (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]); - ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)] & 0x7fff; - version = &l->l_versions[ndx]; - if (version->hash == 0) - version = NULL; - } - - result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym, - l->l_scope, version, ELF_RTYPE_CLASS_PLT, - DL_LOOKUP_ADD_DEPENDENCY, NULL); - } - else - { - /* We already found the symbol. The module (and therefore its load - address) is also known. */ - result = l; - } - - if (!sym) - { - td->arg = (void*) reloc->r_addend; - td->entry = _dl_tlsdesc_undefweak; - } - else - { -# ifndef SHARED - CHECK_STATIC_TLS (l, result); -# else - if (!TRY_STATIC_TLS (l, result)) - { - td->arg = _dl_make_tlsdesc_dynamic (result, sym->st_value - + reloc->r_addend); - td->entry = _dl_tlsdesc_dynamic; - } - else -# endif - { - td->arg = (void*) (sym->st_value - result->l_tls_offset - + reloc->r_addend); - td->entry = _dl_tlsdesc_return; - } - } - - _dl_tlsdesc_wake_up_held_fixups (); -} - -/* This function is used to avoid busy waiting for other threads to - complete the lazy relocation. Once another thread wins the race to - relocate a TLS descriptor, it sets the descriptor up such that this - function is called to wait until the resolver releases the - lock. */ - -void -__attribute__ ((regparm (3))) attribute_hidden -_dl_tlsdesc_resolve_hold_fixup (struct tlsdesc volatile *td, - struct link_map *l __attribute__((__unused__)), - ptrdiff_t entry_check_offset) -{ - /* Maybe we're lucky and can return early. */ - if (__builtin_return_address (0) - entry_check_offset != td->entry) - return; - - /* Locking here will stop execution until the running resolver runs - _dl_tlsdesc_wake_up_held_fixups(), releasing the lock. - - FIXME: We'd be better off waiting on a condition variable, such - that we didn't have to hold the lock throughout the relocation - processing. */ - __rtld_lock_lock_recursive (GL(dl_load_lock)); - __rtld_lock_unlock_recursive (GL(dl_load_lock)); -} - - /* Unmap the dynamic object, but also release its TLS descriptor table if there is one. */ From patchwork Mon Feb 15 12:03:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 42044 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 240863951C9A; Mon, 15 Feb 2021 12:03:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 240863951C9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613390631; bh=GlFM7+eu7q7Mas5jSCHnPd865/l2fjscVEpXXLt/aRA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=YLnk+fm6OHdxEPKdxb+rpOdCci3zMj2o4sT1WJ+xXzjrd27Wei3VLkR9F2q/q1Inv HxlWi2ST37Q0Ws2cgPjiHNOTwoM81DYcrL05FCgr6Ei0i5ALMdgcS5A9+tgI+Th0ON /OpnOkyjBdkEize06sgWr/6XNP1S36CtBUMfb714= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2044.outbound.protection.outlook.com [40.107.21.44]) by sourceware.org (Postfix) with ESMTPS id DD6623951C9A for ; Mon, 15 Feb 2021 12:03:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DD6623951C9A Received: from AM5PR0301CA0024.eurprd03.prod.outlook.com (2603:10a6:206:14::37) by HE1PR0801MB2010.eurprd08.prod.outlook.com (2603:10a6:3:4b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38; Mon, 15 Feb 2021 12:03:34 +0000 Received: from VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::fe) by AM5PR0301CA0024.outlook.office365.com (2603:10a6:206:14::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Mon, 15 Feb 2021 12:03:32 +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 VE1EUR03FT047.mail.protection.outlook.com (10.152.19.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 12:03:32 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Mon, 15 Feb 2021 12:03:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e0dab4479c766245 X-CR-MTA-TID: 64aa7808 Received: from 9f5e23bc5411.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BF859FAC-3099-46C2-8C8E-D0A17FDE5016.1; Mon, 15 Feb 2021 12:03:26 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9f5e23bc5411.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Feb 2021 12:03:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPFZXvR/7mHjqLoBVmFIvXgwt+aGwrJ7MfLaPuBc5GQilW5CbeqxkBDOwOwW4CBCOJvlXpkdLaSeTwPa34XxClZzcU0ONSmnOoRnKt9NiCUnF0ys/j7uaddt9NJmWm1EMCrX2s65gTFPIBLw282dfCghFGRG6fAUpWMKwnHnBa6UUxLDVYqTyna0Q3OEbMo/Bc5jOOS6csRLcfG25iywv2lhFe0UADq6kyl23T2sZqpOggcjullsgkPyfkidNPTurbW5cPDSH/xW49wv0cWb24JDojie89UhtT+FysnMhwlP72e35t4xqets8oWH62pXwVyQ7v/wwYdLrFvwxOmHww== 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=GlFM7+eu7q7Mas5jSCHnPd865/l2fjscVEpXXLt/aRA=; b=KE8aw0wRVAQDXR5iAUpwRgLEKZf42w6/J882P7R2JycJtwgWGVJtde9U9BOmBxcImo4hR+6jBzcVZ9AoepfneaBNMhhTmIB1hWq6BuTElrS0tD/tg+xqmjHvd7m1vQvWIu4QDeieEgFdTPEniPDkGWdtL8hcJ4Ewqn2+nZTy67lW2lRW+gun9O+xldZfPo4fNpPWnSYgAzx81SlFRQ9+qUQWAVYY6tGF5Z8RvCtzQe/sjFBc8HsNDmhteZJw17IyKVhhdvJb3G20PUTyUQN8c8qsl01S3SfoYktpvMkpXkAhIZzpNCObCoUJ5Hg0QMP2evZNptfgbGojhHlhLyg/8w== 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 PA4PR08MB6208.eurprd08.prod.outlook.com (2603:10a6:102:e5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.28; Mon, 15 Feb 2021 12:03:25 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3846.042; Mon, 15 Feb 2021 12:03:25 +0000 To: libc-alpha@sourceware.org Subject: [PATCH 15/15] elf: Remove lazy tlsdesc relocation related code Date: Mon, 15 Feb 2021 12:03:19 +0000 Message-Id: <99e61c835b6365a54ee282392cc3241b2b7de46d.1613390045.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: LO4P123CA0096.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::11) 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.49) by LO4P123CA0096.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.35 via Frontend Transport; Mon, 15 Feb 2021 12:03:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3234b1ee-deb0-4616-2eca-08d8d1a9b743 X-MS-TrafficTypeDiagnostic: PA4PR08MB6208:|HE1PR0801MB2010: 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: tzImqJ+oRs/Op+pNPxH9zLrv8+hGumEd1dgJJRcKCx1tcD4vB6cJaoWv3Patt7sRD2r1MgFQA2QY3klH36lBZNMJtRnoXwQ8fjB692LET4SzxVTrx6n8uEL0UKErSZtgAOvVzbq67GJZ2UjUbP6trmKbG7AvY0f2JYdF6m6KFOXj9qWnzwDxpEaMj0p9vMJn06iOXqJW7RGAn5CcN5hbiCVsce/ABDCsQ+WbZ/VmXAbtFdDLDW2tdl0pnTUxfy/Tm15g7zkz98whTTLJfeDNiMejowZGOEgo1brJwWW9Fgx6EoyYwPtOwJmuWSOl7jYEdByVAOJupGo4D1iFyHmrlPZILrXjQXjBH1/TUiJZUTwHqdq5aHChih4oWVpB0cn7MpM9jPqab0L7m+1+Kt6y0swfT5VagM5dppywWvSPAg45qVML11sUv1qZhwRxxEzawb8W8eLA96b36osGfsP7Tbf8f/KvN9Rwa1K1FJIK/+ZJe9aVoMJIWbJKUcfi3eYMvyeUXLsJMbMVDj3oa+Qti3bRmdyEfuNMkOBgRVI4OqvkQhxIxeWEjDvRew/87q5oCDzGQ6Gy0wjqmo0FwTkwGQ== 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)(366004)(396003)(346002)(136003)(376002)(39850400004)(2616005)(956004)(44832011)(66476007)(2906002)(16526019)(66946007)(66556008)(6916009)(186003)(36756003)(6486002)(478600001)(5660300002)(26005)(6666004)(86362001)(6506007)(69590400012)(316002)(83380400001)(8936002)(8676002)(52116002)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5BtK4mIx+g3lWCljKd5+urm0aMH8MRV0H1qci0ote2xBJvR+Zep9eRDCksM7k0wK1FUyCK2qXm1hPjXbyjWuno1xOvtr6uJcJeqoDBeoFGaaDXXG9jft9qEreOOb9oREbzYrHmPaWD9ekthhHiGXCrolMWgiWjJky1pBrpZb/8On5iALc1jBk2s5vGqbw0pkFFmjQblVQQi96M9sncgCsNTihrdPDULI026Jsqes0rtXnr2IQt0x4uvPzZScoJKXBNLxLxdEMYR1vOsYAUPFFPvf5oC0FjxBi7EeXVYjei2Fz0XHKz81AHd4qMu/kw9kVVGqGd65IDaIN1vqB8jDNXt3ba4Ez/OWznas9HoW89HF5q0XYJjVk7NKPnNJyRjzyKXGQ5B7FFQj2NHzhS+j4qp0vDJuXx38HMKyucjAjJKPf3LLAVoVSbn5K6NTikkagRb2v2jdhA5T6ftv+UZu1s0Q0JTwspevpWXgcPSEc9YgnhRfhs8Ae23chVdkWGMSQoeVXFQ0uGFRAy/IJ/AL3O02o6BCCQhkOyYdfcdXbJtNOha1dHTT7rvUYGxc1souRwasrHTdFounfeWbRqjuEW4vayOk2O1iRghKuRUL/Xqv+fEdIlFClsvREsZY0eQim3JQsAAzMzRMOnz17dyGxDYr3LwZGzfMNBNbsl550G8jK5CRuAaRzX4eY32wZgA0QlQnyKrd1+TgJMxPrl0cBRtsmguTVd1uCXofjA7kujkr7GdVg9cygrNHeVrTewv975ecjTIpZ9MeHARhdo+FGxSVz26KM+Styt+eKWRiGp/G7/8LJGJQljJRzPRhWPOYvypCjFyaqfZ0j8xUhIG72DGQ7PNraO1tPJ0tqsFPRKB+pC59cxZdr0TzOjiMDscxoFxXrlmIv/ihRGeRhesy/WMpJZqqZVsPfzPfR8WHzXuI9D1+JzeAQxaRdy1nXxKScdqvmGtYOwof3Ap2mM8PzWBLSa74wb95Y96wJ5YeJqHw+ZVXGKMNqSHW3MgxsVujqs7YpB9mcxjfpueNW/VLmL0y0eeNt9fj4rZm4zCknGiEfgJoMwIc/dYN9jN9osVa6ZON5g2Otn8t4YZFOVouqCXrgNjoTkD8a0PUe3OZPVh7QfO7FQ9HTGOxV7NTVZvgMWHBxJ2LyrYkz2g3q27kzzIzJ5P5yEu76XX4rjuh8BfwkdKz1bsezTe8YPjVKZqD/AWVzVX5T1qNSZ21fM39luUhEhmBOwnVVDL+Yy02D2cEm+esbRk9MO8pq6dBIRS+QYZh2LsFBx83exhZ2eohJr0ZEDT5wn+H6KRLJY+2Pskz0ScX9OKNpf7eO2/tdHvx X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6208 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: VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 06b71157-db8d-4510-310e-08d8d1a9b2c2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: swd/DJ9Wa9Jm2nrFNQKW6yxywWGr1CXzIqszA+wv1YUPyOZ5NxuzMoLU/Bintl4oahIk91X0TyvSdl9poC65S8qpQS8E1/lF+3isnRCsz0mPhNoubAXZWtAt2o6pMJK69Y9szxEFnHrgUmuVcEf162RtW1iwjFl+wMCZKYsYNDrdJsB48BLNlcsseWxrrAZbqkgMeOHsxx+tEP6k5ebmvezs7XwL0AFtHr608eW/77822lR0XpQ2WuVxdxzyYddy2exwJqmlhkWAI/NTFAghv0AJ7YM64sPBhQrYbUB2Ik8/9okqJyg6pkQswihqMv2NNMcTmeYjBOJT1uOrN/OplviaBO0rpMB6m39TRoMzxNYg0oaLV2s4j81w19+WLkY7Ln9OrzOCE8DYAyFQ3DVmuMQaDh+JkSrReRvRpnmHVzAVUuHUK7m5kMv2z8KiJ2q2iMYdkR8dEPPzmbGdyypHV3XlzyxrZmtVx2d003O8tncqsE24QqE5/s7qY6WjpfvkI9SYCqZEeWBmCoXdgLwEe+tOUReAOWYmYMmqZTzoLutlP/i76RVDlqc+rZoh1JfrjBkUcnXJgWPj9R6jJoU+upUzA2tsANaEOG1/kQfhoEmmsTp98jLkg1j+46ClQoQXWrxfdzpdNz5milBRlGHzQjQHXXTnpg9zG5zCR11JInLEGV2xdl/eoXxOWIPb8JWf 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)(39850400004)(396003)(346002)(136003)(46966006)(36840700001)(82740400003)(81166007)(356005)(16526019)(186003)(6486002)(36860700001)(2906002)(44832011)(26005)(6512007)(69590400012)(478600001)(83380400001)(336012)(70206006)(316002)(6666004)(5660300002)(86362001)(956004)(47076005)(6506007)(8676002)(2616005)(70586007)(6916009)(82310400003)(36756003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 12:03:32.5907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3234b1ee-deb0-4616-2eca-08d8d1a9b743 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: VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2010 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Remove generic tlsdesc code related to lazy tlsdesc processing since lazy tlsdesc relocation is no longer supported. This includes removing GL(dl_load_lock) from _dl_make_tlsdesc_dynamic which is only called at load time when that lock is already held. Added a documentation comment too. --- elf/tlsdeschtab.h | 53 +++++---------------------------------- sysdeps/aarch64/tlsdesc.c | 1 - sysdeps/arm/tlsdesc.c | 1 - sysdeps/i386/tlsdesc.c | 1 - sysdeps/x86_64/tlsdesc.c | 1 - 5 files changed, 6 insertions(+), 51 deletions(-) diff --git a/elf/tlsdeschtab.h b/elf/tlsdeschtab.h index 21695fd1e9..85bd0415e1 100644 --- a/elf/tlsdeschtab.h +++ b/elf/tlsdeschtab.h @@ -78,6 +78,10 @@ map_generation (struct link_map *map) return GL(dl_tls_generation) + 1; } +/* Returns the data pointer for a given map and tls offset that is used + to fill in one of the GOT entries referenced by a TLSDESC relocation + when using dynamic TLS. This requires allocation, returns NULL on + allocation failure. */ void * _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset) { @@ -85,18 +89,12 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset) void **entry; struct tlsdesc_dynamic_arg *td, test; - /* FIXME: We could use a per-map lock here, but is it worth it? */ - __rtld_lock_lock_recursive (GL(dl_load_lock)); - ht = map->l_mach.tlsdesc_table; if (! ht) { ht = htab_create (); if (! ht) - { - __rtld_lock_unlock_recursive (GL(dl_load_lock)); - return 0; - } + return 0; map->l_mach.tlsdesc_table = ht; } @@ -104,15 +102,11 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset) test.tlsinfo.ti_offset = ti_offset; entry = htab_find_slot (ht, &test, 1, hash_tlsdesc, eq_tlsdesc); if (! entry) - { - __rtld_lock_unlock_recursive (GL(dl_load_lock)); - return 0; - } + return 0; if (*entry) { td = *entry; - __rtld_lock_unlock_recursive (GL(dl_load_lock)); return td; } @@ -122,44 +116,9 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset) thread. */ td->gen_count = map_generation (map); td->tlsinfo = test.tlsinfo; - - __rtld_lock_unlock_recursive (GL(dl_load_lock)); return td; } # endif /* SHARED */ -/* The idea of the following two functions is to stop multiple threads - from attempting to resolve the same TLS descriptor without busy - waiting. Ideally, we should be able to release the lock right - after changing td->entry, and then using say a condition variable - or a futex wake to wake up any waiting threads, but let's try to - avoid introducing such dependencies. */ - -static int -__attribute__ ((unused)) -_dl_tlsdesc_resolve_early_return_p (struct tlsdesc volatile *td, void *caller) -{ - if (caller != atomic_load_relaxed (&td->entry)) - return 1; - - __rtld_lock_lock_recursive (GL(dl_load_lock)); - if (caller != atomic_load_relaxed (&td->entry)) - { - __rtld_lock_unlock_recursive (GL(dl_load_lock)); - return 1; - } - - atomic_store_relaxed (&td->entry, _dl_tlsdesc_resolve_hold); - - return 0; -} - -static void -__attribute__ ((unused)) -_dl_tlsdesc_wake_up_held_fixups (void) -{ - __rtld_lock_unlock_recursive (GL(dl_load_lock)); -} - #endif diff --git a/sysdeps/aarch64/tlsdesc.c b/sysdeps/aarch64/tlsdesc.c index 9b6a8b0ec4..3c1bcd8fe6 100644 --- a/sysdeps/aarch64/tlsdesc.c +++ b/sysdeps/aarch64/tlsdesc.c @@ -22,7 +22,6 @@ #include #include #include -#define _dl_tlsdesc_resolve_hold 0 #include /* Unmap the dynamic object, but also release its TLS descriptor table diff --git a/sysdeps/arm/tlsdesc.c b/sysdeps/arm/tlsdesc.c index 2f70adef5c..b3d1735af4 100644 --- a/sysdeps/arm/tlsdesc.c +++ b/sysdeps/arm/tlsdesc.c @@ -20,7 +20,6 @@ #include #include #include -#define _dl_tlsdesc_resolve_hold 0 #include /* Unmap the dynamic object, but also release its TLS descriptor table diff --git a/sysdeps/i386/tlsdesc.c b/sysdeps/i386/tlsdesc.c index 436a21f66b..364c7769ce 100644 --- a/sysdeps/i386/tlsdesc.c +++ b/sysdeps/i386/tlsdesc.c @@ -20,7 +20,6 @@ #include #include #include -#define _dl_tlsdesc_resolve_hold 0 #include /* Unmap the dynamic object, but also release its TLS descriptor table diff --git a/sysdeps/x86_64/tlsdesc.c b/sysdeps/x86_64/tlsdesc.c index ecf864d6ee..3bb80517a3 100644 --- a/sysdeps/x86_64/tlsdesc.c +++ b/sysdeps/x86_64/tlsdesc.c @@ -20,7 +20,6 @@ #include #include #include -#define _dl_tlsdesc_resolve_hold 0 #include /* Unmap the dynamic object, but also release its TLS descriptor table