From patchwork Wed Jan 20 15:29:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41770 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 A2AF6396EC5A; Wed, 20 Jan 2021 15:30:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2AF6396EC5A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156620; bh=70q/f2AguAgwsZQaN8dE8n+sYY5M8WLsIjCm7JgNmmI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=a0Bg9p/11hIa70qbsT8ycHT/y23qQTI8RMyPyrWn5aAKJO4D24U+sQw/ltSctMwPq 2m2yMZ/H82m2+cZOkOq+Wc+xFLi8zU57+G8/ipf+VujRacC1EM2SBia7dSMKyfmBOk y10nJBzuRPGlIiTO2qBscY5CgDfUV0oyCfVrebyo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70078.outbound.protection.outlook.com [40.107.7.78]) by sourceware.org (Postfix) with ESMTPS id 7E7833857831 for ; Wed, 20 Jan 2021 15:30:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7E7833857831 Received: from AS8PR04CA0196.eurprd04.prod.outlook.com (2603:10a6:20b:2f3::21) by AM5PR0802MB2564.eurprd08.prod.outlook.com (2603:10a6:203:a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Wed, 20 Jan 2021 15:30:12 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f3:cafe::f9) by AS8PR04CA0196.outlook.office365.com (2603:10a6:20b:2f3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Wed, 20 Jan 2021 15:30:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by 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.3784.11 via Frontend Transport; Wed, 20 Jan 2021 15:30:11 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Wed, 20 Jan 2021 15:30:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a4f247d6935c06bb X-CR-MTA-TID: 64aa7808 Received: from f7de49a88af7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E9A03892-5D18-4586-A15C-79074EDF325C.1; Wed, 20 Jan 2021 15:30:05 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f7de49a88af7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:30:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S7TV2x4kpegTV29ybzFW+DE3Is6piDeDOnrWwFTWQo+kS6llUrhO0K4ZdL8J+PHcD1d90rvPN2mA6tpxYbwgo51R6R+e19J5w2h81xHLsyWHXbKXACvsqFDnEVa/DRGYpQq9mscjzydToQ23kLCDw+WvXZJ1bFAVzRcGGlgk4ZbMXPptEwjvFoY8EG0v/GLOBjYhUY+BniM+tUaJ1q+OQFKF2ONeQoFiWiCUd/3U8W6d3FMN4kez5hO9hB/7sEZKnWToCUGGlwYgPIWLGZplyeugnUR6bDoEIcLKRLrZRO1akrTZRjcdNRiIKZh4oRwIBVhc0q80/5YsQBRYhuMsHg== 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=70q/f2AguAgwsZQaN8dE8n+sYY5M8WLsIjCm7JgNmmI=; b=XVIEzDDfb0tqKmdzv9dYb5ZJo30O/jLeJQ9SGetP16p2cE4LmJ6G5ZAmVovLG5/X/5AkYc1St3BnPlu5yG5lelVvigw6sPDljeyar5q/3wfpdF4VqWCEjFTIaLHcOdMVeEARC+g5WokTXtc92kZlZUiPuk3Ym35DJ9qeRhP27pO+604HKAkBBUPy50zP2MaWFlTgwAAotyE2f04wDmohHH96oO0AXnDRwA+IZSetYomokFEQ1cHVbDPBRfZyEj0Zhca23QqvK8QiNdKuWVkDbYh1QCRmnfZuP39IsPj8GtpQSeQP/mzVKYshzTLyxHaLqqA+mMX/QFvC+FO/hHQ3rw== 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 PA4PR08MB5967.eurprd08.prod.outlook.com (2603:10a6:102:e7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Wed, 20 Jan 2021 15:30:03 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%7]) with mapi id 15.20.3763.014; Wed, 20 Jan 2021 15:30:03 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 0/7] fix ifunc with static pie [BZ #27072] Date: Wed, 20 Jan 2021 15:29:57 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO4P123CA0182.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::7) 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.51) by LO4P123CA0182.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Wed, 20 Jan 2021 15:30:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e0dadcb3-a736-4dbc-5667-08d8bd58470f X-MS-TrafficTypeDiagnostic: PA4PR08MB5967:|AM5PR0802MB2564: 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: B2yajmAYh0Y7D1AOMpspAku/9PP+pRWv33/rL5+yxX7V83fVGyvMPFJq9oMvJKOqcDVtUV/ZR6ggVofjz6+GltnKAbBj3LKE9aZEm1rAQbutAYG1W+Z3inxPU/9TZd4b5Id8gRg9FZATTtd+TCYqh7NyYw1hQANof9nqA+hPGoxvbzwVtaizkE5ZQ7E8L4/lYnwFwWDJmqZtqbC0TPQnvnTKg9/to7yo5x5bd+uwUB6uYpkgXqrzESyAiVv2IDaIUh1h2OIt/dC124egPFqMjrBFAsnXgvla8uvD9Su1j1Xb6si2K8BNlUJJTo9z5qmqNELwaoYVcQ6+Hems+uaLyCGNjcAO2IiFsfert41EIDHOcuSjzQtSN+p87MiWcLHLxOWWFDYFxd5c1oKjytXrBCH71M8HEvv7olCXjqOZK84FQFYHeFVEAMlgkpfOginxufNqve49q7oRNKVH1ZwSmA== 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)(376002)(396003)(136003)(366004)(39860400002)(346002)(8676002)(8936002)(2616005)(44832011)(16526019)(52116002)(69590400011)(6486002)(36756003)(478600001)(956004)(6506007)(6916009)(316002)(83380400001)(5660300002)(6666004)(66946007)(66476007)(86362001)(66556008)(6512007)(26005)(2906002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ABYBgbfLJw5wD02FvWG/UL2iRZT4thkMzedVGkmZ0Eo49kN/Rx3F/2QIUbIN/tSMbvzAsweISMNXXVowTKBw+KSRr1Nlu3E7ZOV1H1RyvVazJXhs89i9rhsUzkEQcs71oiuX+/8wnP7GOFlaPkpBBxhSVyKMXhV06Bs6sNgtgcFB/OjxJC8FR59U2MjrAYL9Reb6HIk3KxCGUINRRMfC5lNWLfgRpSz2X+0jxYBS7w0b9vnznRQg1MUGFly9QS2emS1zt/Vnhvif1nTsvGXHamcnvwtO8Yf00QQJIBYcU5V+Mb9pEod4WVuTKXW+DjRhXoQE1YKAmHXFyphKauwXmi2XWVmoj9IteWXInO8X6JEid+krWTdSaIUNGlG1LBI487ronf3J2ITgmPAyhKApD9e/hk25CoJDJSjwgx8cUebH62DgOKKKhW4L3eTryRaJLe0cMLuHEzM+JX8ZeCYLqsAvZQjoz93MqqI8PaqssQtG85Vj56QFE3fGineSV0fK0RxpvcRIyMwR4gIVxneFQd8aDFc3NcXemuzN8+vJIc8cmusnXJWDKdoIaNPlbh9WlxPQuE96EZ8X9K3PfT+YXk3S0JPJ9XZZMb4bt7tvrLWFJ6X2FC/5gh0vW4kr3iopQzBrFh6Pd1GWIR/KugR4dy+01TgZeVWIsBwYi764JnTvP+J408BfYXopbvBUzWlrUeJTOOrphKST/km0MMEfWkI3ZWmX9rcsXsjp00ZeyxFu8AJlt6DTktiP+4b7UX6kux94rmiHiP9Eb3nB83aVvGuImyKf1Ix2/HTOXpWA8XkgGSpuKH55v4nXUx0d8VfqO5/+dI3ir4BZ4Tt6Xbm6GSnmVDCIvTi1XkFMXCzE9YFgOyb4L0ugtSICWaUsiHYC1hyw6J5IXGiTp4pXNVYK2A1ZleEcuLRRCOmeeRlKQJMsk1Xg0fy4jmF5HQJgjjCJaSntLFMGfQ1gfuJnCCSQOB5k7i2dNVQMO3yaQvVU1lf4zNyqTaNr9vfjPiBg019w X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5967 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: c2ab80b4-2247-481a-29b5-08d8bd5841f7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9tMMbQZTTo5ZrCiSDrzCIvvf9t+95C5PijXr4Z4mA69jtOEl+Nd8FLKyaunkzCBP7UBp39VT5HK9iKwDpAnqSBDHMKbPUC4bEwfha1GH7yXxLe+foSTYzzFyYafI3GFbx4XCfkR2Qt0QWD5EiPuczz6RUNWnjyWlKg/VGpgKZdmxl2+zRYZ0EVtu5H3rauO8X0MiSpBqobqLuE/455oTJ2bpqWCYmyWKH+MKzJDnV95UrMg4UTeBs2UFDx5NkKd0O8mfCpbVLjOFDU7P94ep12Ux38mkoNDR3z+RyZEWHs+Bh1uZ8pV5IurOfHQJVrbUWV+3vP+sYWxPAFq6epa4CXriaJeUnBSq/yDTKXtzuFv2D0AOYTEZ2qmY7iIZXCEHPEYi58+8XQJH6rmGbCrJpe2RjZ7jkXWu6guOjqCuuQoWzWVq1BjE1ajR9ax2eIMbMI/vdLFhqgRsDngh6g7+WocPAKVCPkRXhQdIQqOi3bxK2RdpI9OU5XtuyxMH2H0p 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)(376002)(346002)(136003)(39860400002)(46966006)(6486002)(2906002)(47076005)(356005)(81166007)(26005)(316002)(82740400003)(6666004)(5660300002)(36756003)(69590400011)(86362001)(6512007)(6506007)(8936002)(2616005)(83380400001)(336012)(70206006)(44832011)(956004)(186003)(6916009)(8676002)(82310400003)(16526019)(478600001)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:30:11.9265 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0dadcb3-a736-4dbc-5667-08d8bd58470f 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: AM5PR0802MB2564 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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" v5: - reordered patches. - config check SUPPORT_STATIC_PIE (instead of PI_STATIC_AND_HIDDEN) - fix __ehdr_start differently: just drop weak. - update commit messages for hidden visibility changes. v4: - added patches from H.J.Lu: - x86: fix libmvec tests - x86: fix syscalls in libc_enable_secure - x86: avoid relative reloc for _dl_sysinfo - x86: add ifunc test - i386 cannot mark all symbols hidden, so use fine grain marking in files that participate in early code before static pie self relocation. - the patch that makes all libc symbols hidden is still included: it is now only an optimization for non-i386 targets. v3: - refactor tunables: move internals out of dl-tunables.h - use generated max string length in the tunables list instead of magic values. v2: - check PI_STATIC_AND_HIDDEN for --enable-static-pie - change string buffer sizes in the tunables - fix env_alias == NULL logic in __tunables_init - move __ehdr_start processing after self relocation force pushed into nsz/bug27072 branch. Tested on aarch64, i686 and x86_64 with and without the last patch (some of the make check is still running though). Issues that are not addressed: - tunables try to allocate memory even with non-suid exe. allocation is only needed for rewriting the GLIBC_TUNABLES env var. (i think a case can be made that if anything there is TUNABLE_SECLEVEL_SXID_ERASE then this env var would be simply dropped, that would simplify this significantly). - __sbrk only needs the hidden visibility magic because of tunables, ideally we would not do allocations before self relocation. - tunable list data structure is not optimized for compactness. Szabolcs Nagy (7): elf: Make the tunable struct definition internal only elf: Avoid RELATIVE relocs in __tunables_init configure: Check for static PIE support csu: Avoid weak ref for __ehdr_start in static PIE Use hidden visibility for early static PIE code csu: Move static pie self relocation later [BZ #27072] Make libc symbols hidden in static PIE config.h.in | 3 ++ configure | 13 ++++++ configure.ac | 4 ++ csu/libc-start.c | 15 ++++++- elf/dl-reloc-static-pie.c | 2 + elf/dl-support.c | 6 +++ elf/dl-tunable-types.h | 42 +++++++++++++++----- elf/dl-tunables.c | 6 ++- elf/dl-tunables.h | 35 ++++------------ elf/enbl-secure.c | 4 ++ include/libc-symbols.h | 9 ++++- misc/sbrk.c | 4 ++ scripts/gen-tunables.awk | 16 +++++++- sysdeps/aarch64/configure | 4 ++ sysdeps/aarch64/configure.ac | 3 ++ sysdeps/i386/configure | 3 ++ sysdeps/i386/configure.ac | 3 ++ sysdeps/unix/sysv/linux/aarch64/libc-start.c | 5 +++ sysdeps/x86/libc-start.c | 5 +++ sysdeps/x86_64/configure | 3 ++ sysdeps/x86_64/configure.ac | 3 ++ 21 files changed, 144 insertions(+), 44 deletions(-)