From patchwork Fri Jan 8 16:20:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41682 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 E45B83982423; Fri, 8 Jan 2021 16:20:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E45B83982423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610122843; bh=PL8drRQcuMwzeTxnFgV4hwfYDIKyYtPniGJFhG4I1g4=; 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=uHEL/mDqYKr5e5mZPrmm8V8GtTjq8+FyZfgVeavBsiWgCrLAd6XdFOoebZfd7s0lt U6C1FUwz/UZmH2Ow7F+5TqzIWcIQRX+Kci1CvgFDbAeWlrY8FUqeiT0DxoIZqop5b1 hCeAUGY3X6P5LryRkGQ8aeNv9g1PLFPauu9QV5nw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04hn0240.outbound.protection.outlook.com [52.100.17.240]) by sourceware.org (Postfix) with ESMTPS id 7A8123982423 for ; Fri, 8 Jan 2021 16:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7A8123982423 Received: from AM6PR10CA0099.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::40) by PR3PR08MB5850.eurprd08.prod.outlook.com (2603:10a6:102:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Fri, 8 Jan 2021 16:20:39 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::bb) by AM6PR10CA0099.outlook.office365.com (2603:10a6:209:8c::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Fri, 8 Jan 2021 16:20:38 +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 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Fri, 8 Jan 2021 16:20:38 +0000 Received: ("Tessian outbound 8418c949a3fa:v71"); Fri, 08 Jan 2021 16:20:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: caca8df2c82cb125 X-CR-MTA-TID: 64aa7808 Received: from 13142a515bea.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0765D699-BB0B-4DAF-A7D1-E173E7408E68.1; Fri, 08 Jan 2021 16:20:32 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 13142a515bea.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Jan 2021 16:20:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C3EOoofy8BwytpFFR0RscA8lU4QAUD++1Tmbv67vZZ6Z6juYqj8ZjG6M2iUydf3SDjpTEYXJO2NE7cQKPYAv0oCTJhXju94mkVwa1lQWEwnDRnRNjWHx/FOlIyH/alJttbamlIONtUhBcJtD4Y6lL3qfe1AX/mmQjDXV1vuF4lgJEK9wJO5d7yh8oGS2D6vrDoeLMfEZSeVYze/In1/I9LQhH5MOWidenXtlsryAD30Q2hPfll0dpXxzBOn2rGD+HHzWWsnvMrRTIN/woqxvZnO2utd09CFilkCa4FRlq5Nk7JMrF++92dWFDOj/cWMt253Nf1dD0s8IAWP1kH02ag== 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=PL8drRQcuMwzeTxnFgV4hwfYDIKyYtPniGJFhG4I1g4=; b=LnSwhOq2t1Cu2f3a4aQo3BcTsiHXPvdg9//U2xQMH0UpQY2v/zei6Dnrf4Mmv4G98diE1zMwd23XPkmRRhO96IHazQxFo9TS5E7oiAewo7K1joMjuOooc+/mJGmtXJiY/CVxxrVa4QknDeG0q951jL6anJt+j4HUR+553jKZxWqmZIsFuxTqqpdJ4Z7GxUTk4DFXTe+1UkD39SGn3l3KbO71V5UZpJioW4fvB66nsvFIVoLH93Q2LyJRjz4CQhE68K6IDePvdxu9p5rzrP4omhSRhxyM00OSbWVkqlJIP9OnZzEqAoL0uDmqmioOnZ1UQAkKNUuMZl514IvCGL609w== 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 PR3PR08MB5578.eurprd08.prod.outlook.com (2603:10a6:102:83::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Fri, 8 Jan 2021 16:20:31 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::700f:ddbe:a347:ee4f%6]) with mapi id 15.20.3742.006; Fri, 8 Jan 2021 16:20:31 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v2 3/4] elf: Avoid RELATIVE relocs in __tunables_init Date: Fri, 8 Jan 2021 16:20:25 +0000 Message-Id: <69ef59c70daa586fdda61fd818506c1f9fab06d0.1610121077.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO2P123CA0013.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::25) 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 LO2P123CA0013.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Fri, 8 Jan 2021 16:20:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3b3778b3-9a86-44b7-8787-08d8b3f15614 X-MS-TrafficTypeDiagnostic: PR3PR08MB5578:|PR3PR08MB5850: 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: YEfuT2Vmjf0orzu0LZzhApF9L5ZaviyUFvnhVShXBt4ssevHQCncMDGw7d9363uHMl6qQW1KZ+d4zWO9UDvLS6Cm+EYOErHWMyHTxm5Pk2sLIeIMwjZcDyhGo/BLFhrMWwYDYrHHdXEAZRLd7eWJjv7xZy4rLI65bTNcHzEhNl+ma+se2s4xHDBy4BodAVKJOVbGpMmLI6G2u4XPrn0XmyVBnrY+1/V7Wgr6YR7iK3anJ+Md/4j+5Pq1EYdtEBUL4zSu9O+gC3/hs115bHFjzNiNOsOeaMSJExTHlM8gZr2NpKlMrD0KRy/DCfvdmOHcwBq/KNhE9BGg+KSbeLDwrfKCjdvY6QnzUKK2a9nqMdIvqLcBu048aNeemxmGYnjvOQ+4Dq72eqmwSoUTKIF5IxS1dYkgH+ZFywwDKbA8hz+c+2KNSMOviSqOkM1Kk5QAkuj7wh664bbnP7jhAowHJg== 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)(346002)(376002)(136003)(396003)(39850400004)(366004)(36756003)(8936002)(52116002)(86362001)(69590400011)(16526019)(6506007)(26005)(6916009)(83380400001)(186003)(5660300002)(6512007)(6666004)(66946007)(66476007)(8676002)(316002)(66556008)(6486002)(44832011)(956004)(2616005)(2906002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UaWHlwOoQpDcvxkcUSedtDtr+s+fSjiBgAWpKxc9PEBcU3QQER92bgytn1pOqB7r8A+Tgd4+KAJFBGquM2DNujptNqvIoAb0wTOhk2E/SwckCrMOIzVP3F2LeDBpC/KSjGMJ0CuVCIEgVD0hzfKg3vZNx8NDCTtc15ahqt+Tb/kkM/DkeFKtb7fnUAuaZHCJwsWtVnpdqvZOSUBAYsJXqKhdnID2ugwk72Yta1cSAhN03TqbsNIrJ0wJbbKITvGkHpG6DiIbBBDIYDZOTcvHKZubflYKmCC8Q8nmE0qUxSBC7DXsPUglze/dCnNGDyoSpgtQR+E8xEz0BtjR1/BqR/ByGrSiR5sAqwPvcnF3f0kv4dFlzLFGbEwAUNDLTpc6NEwwhSROcVCmd9JgJvLzFGGTsH7PhLuiX/tgyE3itTYjtD+GiuN02PdMjWiW8zTOm0z3L+prZP2LiFbtLevUxAwvdhk3AjkCeB5cWJ5x80eao1HNGRRA6H4t0EkITG0J1rqIoeLxS4MwSmKWeixRaj3HfhC9W6lhapxkIM910rgSQ0dedK9u2cZPEnv9QWXGEjh1ztkhMNV2VJGhBYsds9k3kRJpX5ON6z5fwMGmJpLRLX1Lx5peapk5I/IS+cGVYgtctRSKxq7mW9vlZYcpnj3ucohnjiBhTjvv92VbgqefSQmJbUuoF/Jl2DLBYV61cRvC34NRFgtC7buStuvOZQkx7Z2LjKbNTiLWWDVL0YaVSzVgsl6y2d9MEFoFjvtP3fwMiCrDaB79/zxkc5/ub68xRIX1GqZt+n54PQVuaS3ftQagk1aJRcBkhTzMZSicsLDeT8e+OqTW6stgom/y0yswohJg707bNhgyh4/fBzbfQ0I43qfMCSqY4cCp38aV9R2lDYa9ZEgVZ2U25PqKjIUOMdtWzllEmJKAekrpOEmrDF/JyUU81OUe0222Aru5vxkmkADDia4OW6i3SJbRXmIK16q5RV5eNmd/h5WASIcwB6GjYRj6gGyXN1W3Vzm9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5578 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: AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ceb145ad-0069-408d-ca95-08d8b3f15200 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yMLg/o82GE7FfY4JDRr36IVWfoNEhfFFnZMhy0KLyDFW4/2rssGPyc2SmDOxNGAqi1yRz8s00ZQi3hUzSXUIGRVRFtpfVOrNqCUdL/B4icq0qmyGgelLTph9wFDNkdjkkLcoW/QBptDuRIjtsuF+yXzbuhFoArpkbWy8GIrb5aZijtLGeCmGVP6wJPZ0s9vg8G4tR3k/qJesHJCzjKwzRj8XRYMPJg2Mge9M44ZW2paSwDukiq6B0VT/IIPlUJByQmXop3oP8seIQwh1HJbawdZckMAU85i01wVD/hnqqdhVw14c0MeYIqRkfoevhZduglkEJyNN+f1idwqNYpB27CqSZkLO5tTlE/JTNSWSDn5soTgw2a/AqLOMSNZMjBbGVKPFng96ESNeaUg78w3R+BM81RA+21B+OzQBFxb1kvvDApvY7pb4jOMalNJFbDhGGz4aqd9KZlSB6aJMKs2eQDH83CYph4RabLLGPY9wqVyF05g9xBcclHB8mRFnk4iy3xjkXYXgc9X3HBdAxbWuNA== 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)(39850400004)(346002)(136003)(46966006)(8936002)(69590400011)(86362001)(316002)(336012)(8676002)(478600001)(70206006)(36756003)(83380400001)(186003)(16526019)(70586007)(2616005)(26005)(47076005)(44832011)(6506007)(82740400003)(6916009)(2906002)(34010700040)(81166007)(5660300002)(356005)(956004)(6666004)(6512007)(6486002)(34020700004)(82310400003); DIR:OUT; SFP:1501; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2021 16:20:38.5081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b3778b3-9a86-44b7-8787-08d8b3f15614 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: AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5850 X-Spam-Status: No, score=-13.8 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" With static pie linking pointers in the tunables list need RELATIVE relocs since the absolute address is not known at link time. We want to avoid relocations so the static pie self relocation can be done after tunables are initialized. This is a quick fix that increases the tunable list size a bit. --- elf/dl-tunables.c | 2 +- elf/dl-tunables.h | 4 ++-- scripts/gen-tunables.awk | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 9b4d737fb8..3845b2c04e 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -350,7 +350,7 @@ __tunables_init (char **envp) /* Skip over tunables that have either been set already or should be skipped. */ - if (cur->initialized || cur->env_alias == NULL) + if (cur->initialized || cur->env_alias[0] == '\0') continue; const char *name = cur->env_alias; diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h index 518342a300..05997d028a 100644 --- a/elf/dl-tunables.h +++ b/elf/dl-tunables.h @@ -38,7 +38,7 @@ __tunables_init (char **unused __attribute__ ((unused))) /* A tunable. */ struct _tunable { - const char *name; /* Internal name of the tunable. */ + const char name[64]; /* Internal name of the tunable. */ tunable_type_t type; /* Data type of the tunable. */ tunable_val_t val; /* The value. */ bool initialized; /* Flag to indicate that the tunable is @@ -54,7 +54,7 @@ struct _tunable target module if the value is considered unsafe. */ /* Compatibility elements. */ - const char *env_alias; /* The compatibility environment + const char env_alias[24]; /* The compatibility environment variable name. */ }; diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index 622199061a..9e7bd24e13 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -57,7 +57,7 @@ $1 == "}" { maxvals[top_ns,ns,tunable] = max_of[types[top_ns,ns,tunable]] } if (!env_alias[top_ns,ns,tunable]) { - env_alias[top_ns,ns,tunable] = "NULL" + env_alias[top_ns,ns,tunable] = "{0}" } if (!security_level[top_ns,ns,tunable]) { security_level[top_ns,ns,tunable] = "SXID_ERASE"