From patchwork Mon Jan 18 16:23: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: 41746 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 A2270383443D; Mon, 18 Jan 2021 16:24:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2270383443D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610987081; bh=cROr2nG0R15ZNZ1ED1uDI0TD4qS+y923pUEAW6v29ZA=; 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=c5MhroqKyKpCmZsswxwfFvReCeKJphA4oXRgeDl8xl0YWTDFVqxVTuFGUIlAQC4QP fwnkKgXJZoKUfjLJtWdepGE/GA5EKQbT20rGeYcd2H+netMmPj2r9rb7E2wr8UKzKA 5RHpZr/t3AfBXvUB0EZty7HnopkuudNMYbVILhvI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130072.outbound.protection.outlook.com [40.107.13.72]) by sourceware.org (Postfix) with ESMTPS id E4D923834404 for ; Mon, 18 Jan 2021 16:24:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E4D923834404 Received: from AM5PR0402CA0011.eurprd04.prod.outlook.com (2603:10a6:203:90::21) by AM6PR08MB4567.eurprd08.prod.outlook.com (2603:10a6:20b:b0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Mon, 18 Jan 2021 16:24:36 +0000 Received: from AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::c4) by AM5PR0402CA0011.outlook.office365.com (2603:10a6:203:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Mon, 18 Jan 2021 16:24:36 +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.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:24:35 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Mon, 18 Jan 2021 16:24:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e1a13cf188467e94 X-CR-MTA-TID: 64aa7808 Received: from 30ba2a8df3b6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CDEAC6F2-D691-40B5-9DDB-29F50B36B54F.1; Mon, 18 Jan 2021 16:23:58 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 30ba2a8df3b6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Jan 2021 16:23:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxsZSqh91jc69HexriJv6BhdPsvjR/FA+RwXFhAB1mR81d6nWx3NEYS4En1QB76IPBIrG1DDK0kUcZ//mdKurIY5T6QJkePG5nBAz3+J5Qn/YToixeIVTqb/fglFoJzCl1RDg6HpINbkBx0oRrpveD7A+Qf27c17nxI0T/c40w2QF/M/yWHVxa2F6JbgVJy76+x8By9OOKDc3XsUJM+2K6Kvvhydd34x2uj+NN53F5hysHwppQHQ5+UFDKGdJeb0paIYgYrsCZrqYEKvMRwmmLR/zNM/OOCp9l48rIzbsa6IExHq5a+WQE6ZGPzi3z4lEWPQ7/RZgXrlXMj3+I5EhQ== 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=cROr2nG0R15ZNZ1ED1uDI0TD4qS+y923pUEAW6v29ZA=; b=eiZ/r5PDEmq7w5aVsKMjwsgK01U5UY2jSQFcsBKwHBB0ycLdaT/7m7/vwRa68e2zo/8UImHvILoOS4JpyqyUCfols4KBR6SuBVvxiOcZWxlBr919+wlcPSMugfro7MB3VQfvMULt/gl40tqj//zEqmsPRAQQlwvVZTG2cwNvupVhht5W1SrTiLQBRXW7ZSXXHqg86e0RAs3ID0BKTc773Mx7qArFhu1uiKxBSHLbTElDLT7+gR+/z+UehSsiLLrCLIeSx2b+OIxTZ7f0VKkZ3iSuYdL+EzLrPLSPzu2FepPWy/sAhoQwUZRKUBb9jp8D7vKWCDO43HKuiQiTi+fIBA== 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 PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Mon, 18 Jan 2021 16:23:57 +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; Mon, 18 Jan 2021 16:23:57 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v4 03/10] elf: Make the tunable struct definition internal only Date: Mon, 18 Jan 2021 16:23:45 +0000 Message-Id: <58d4e6b7948d34f948b7a04386f5ec6baa82b9ff.1610986541.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN7PR04CA0172.namprd04.prod.outlook.com (2603:10b6:806:125::27) 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.54) by SN7PR04CA0172.namprd04.prod.outlook.com (2603:10b6:806:125::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Mon, 18 Jan 2021 16:23:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: de1cd43d-c52b-408d-b28c-08d8bbcd8bbf X-MS-TrafficTypeDiagnostic: PA4PR08MB6238:|AM6PR08MB4567: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: kWml++j4LbFjpWFEEpShp0cWNRyBXyWeNc9kSBTp+yCHds9d80jcy/RGGghRS+3Fi/mW+OwDIpTn1Xi8InuBLs5hV4+XHlLbhblxAEtCBKx8WMw3SmeWBp9jLNsl0npgCenVQ+TXDxBA/ociG3rtmYg+MP0AekAWFXK8OFBbsC+kV8uAmywwYkUpQ3gD/AH2KGt6BXn6R4M0pcLep5tpcO0jJOcTb02B8JEliH86+i1mfjzH3c7c5+UeDj6eE0auCyNn4dWCCnV9xOEef/g9u81vi2EFwnSAaKHz1bni57BluTG9ideqCNkj2sL4o0m/zYVBYcwkHSPmZWDEYW8CSYD4j4ZdgMg8zMZ7fIi2RRR77SnF8M5zoCkq6ff+/10Ej+5gm18SXGw4TJil6Ty7FfYJT801WWhRcwc/OKLwv4jt/xj9XAX2fnH9zq2SP39w4g5fj7OLkVq1naCv0gTwow6rd2CqSvk3ggfflg1N5mzVuwUuziCyPLQYv+l+3v/9YfyFX5BY/cH9vdqFN17IJZ+xlK1QT6u3Cd092Tw6SRtbZDUL8wEbs87yGpXrAvHYXOI2GST4Kz8mpvb+EXERA07GO8xUVhPm8meeTkZWqe0329MpKJle48KHJ+5EY2OT91ne4PwsXRmm9EthJdEWutXJAMNwTo8F66dNerIqOdzQWX7frHkiRfKHOVj6lp9c 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)(39850400004)(376002)(396003)(136003)(346002)(83380400001)(6486002)(8676002)(69590400011)(478600001)(6666004)(52116002)(6916009)(316002)(8936002)(66476007)(66556008)(66946007)(5660300002)(86362001)(16526019)(26005)(6512007)(2906002)(186003)(6506007)(956004)(2616005)(36756003)(44832011)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: n1IVi7labUId1J7vsG5YGgXGJFQNuAjea01srwehOpJYc9uW3S2wkuxSc88U8A1et2Y2FV+KZreE6nI705qBaXzwbzMm4QbQqh0BHD5dNYhbYpuO1n3nfUElsrT8fK5usym9gxUilqtQCsYQVoTDQGYWj+l2p6hghk1GnyNDBpWtRgkVg+p61Is9qk5J3HVDGqc+EAHLa3FfEEJ0taza3a0z75957XXbXU7ss2Njpg19VWhx+XXLo2cmOx4Rho/NKDDgR9XOn31C11fqx5kiT5Qk17fGRnVIDVNZpWtdxU+c9crBxVmCSfIBDjDbJhtTEH59UdYERGzWQpMLsm81SbSFyhbToD+CO1PCq7p0LUTmdap3rZioKMf2Plo9vZA2kMA1b02xAfjzw/AYAZ7vGCKdaFtCFRPH5G1i90Sm2Nh7ByOd7ATZRuMZamixSEm73e9eOOeXZOCKhdCYBwhM7WlyVuInGPJK5eIFyNAOBPTacP2OB8Nhjr8yu9Rgh7MttrJTexfCQlRXJeOMQZ3CDmN1EXCdP4YgES7jUJT80eD72hTbZhFD4DOr2f/1PbM30dTfrVfYzFyGrQTVfw8+43C1x1lSCHY6sSK6KZzmGYAZVO+iOMGqhBXiiBWMQVsI3Opz2gDqaFWIEKJ213SUr0TVLoeSBv0rL9kRT0pxHtL4miiz4Gas6O9iBSknHwWYZUWxyzl//Yi1VC+97WlNwtpRKU+PG7uaFRMLiemJrCcFMAsLfvVMsSRvGA0+3WsZ/xRvBwKYpusargPTplfpbDpwfoCzNW8amWvQiE9dM1iDUQEZrW44enDAqYb5b8axtG67PzfjYoN2ZkF7/L4zJR7agFsLNcdFVQH1il7jutRG1WcB6BNr/Vo796xOOA3q6D1tZv+mkw5Pbi4nH+9S8ddeQQshJ7O2yRKSdMsR+1a6IRTyg9lwg55yAk8E/heWInvt2Ocd35/qAh6L+3fdWpupNx8V3fpvHrI0OhVLNZbqrd5uRgf5CMpU7r3qqFsr X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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: 295b1467-483d-48d7-18ce-08d8bbcd746d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6UnUw8SZjDYo1lpCGbX6/eYAba4tV+L1vlSoPXWDK3Hx75GYEZhOFYdrCTTyxitQmt2jEmxsu2QUNSvLvkxR+qq7sdlqI8Tq13IwmaIr9atJXNkdxWxuRyW7SbbVxTwcDq8Puc8qez/1Ac4a4oKN4Dz7ZO4Bp81LSxhYmKpYE40Sr8ckC3Rz0lCl3FUGqe0XqNoIG7yQJrdL8ggoFtfooGqDAtsbOD5TWaLJkSJ1h01Z15T/hhBgmq5ZPUVIxHzoPS37DsFe1W8TJpuNj++brV8Cwn5fK36LtBWNR4KgDPbjoyF9DX8w4bAOMCBJPvgKTF4Uq12MJW4eowwLdtfwqhO3QFTMUQZsEVSzbvlizbe1VC2GM0om9xstcaWQTyQLQXi+LcHdVFZpoGaxF9NoMjt3yKEQrOdzQW/cbUZ0rtgz7Bt0SiMBMSmioDMEOQ5wcfGkNB1eO/OIKmtve/vm4AuN8u3HOW/MY4CAveski+t1O1WwiwrqCn0ChqEMmDS/etUfH5zvJXDziLy2XCm8jsKGWZ+cRpkMmuNVuI4K0QrXqIcnYmGBkB5GObuw8xwpVNzbLGkY8YL4vaijYYn05qvW4+RS2uZOyKzWstxw5+w= 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)(376002)(39860400002)(136003)(46966006)(6916009)(70206006)(6666004)(36756003)(8676002)(6506007)(6512007)(83380400001)(82310400003)(44832011)(336012)(956004)(6486002)(70586007)(2616005)(478600001)(82740400003)(316002)(5660300002)(86362001)(16526019)(186003)(47076005)(69590400011)(8936002)(2906002)(26005)(81166007)(356005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 16:24:35.9601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de1cd43d-c52b-408d-b28c-08d8bbcd8bbf 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: AM6PR08MB4567 X-Spam-Status: No, score=-14.4 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" The representation of the tunables including type information and the tunable list structure are only used in the implementation not in the tunables api that is exposed to usage within glibc. This patch moves the representation related definitions into the existing dl-tunable-types.h and uses that only for implementation. The tunable callback and related types are moved to dl-tunables.h because they are part of the tunables api. This reduces the details exposed in the tunables api so the internals are easier to change. Reviewed-by: Adhemerval Zanella --- elf/dl-tunable-types.h | 42 ++++++++++++++++++++++++++++++---------- elf/dl-tunables.h | 35 ++++++++------------------------- scripts/gen-tunables.awk | 4 +++- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/elf/dl-tunable-types.h b/elf/dl-tunable-types.h index 8f6a383dcc..05d4958e1c 100644 --- a/elf/dl-tunable-types.h +++ b/elf/dl-tunable-types.h @@ -1,4 +1,4 @@ -/* Tunable type information. +/* Internal representation of tunables. Copyright (C) 2016-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,8 +18,14 @@ . */ #ifndef _TUNABLE_TYPES_H_ -# define _TUNABLE_TYPES_H_ +#define _TUNABLE_TYPES_H_ + +/* Note: This header is included in the generated dl-tunables-list.h and + only used internally in the tunables implementation in dl-tunables.c. */ + +#include #include +#include typedef enum { @@ -36,14 +42,6 @@ typedef struct int64_t max; } tunable_type_t; -typedef union -{ - int64_t numval; - const char *strval; -} tunable_val_t; - -typedef void (*tunable_callback_t) (tunable_val_t *); - /* Security level for tunables. This decides what to do with individual tunables for AT_SECURE binaries. */ typedef enum @@ -58,5 +56,29 @@ typedef enum TUNABLE_SECLEVEL_NONE = 2, } tunable_seclevel_t; +/* A tunable. */ +struct _tunable +{ + const char *name; /* 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 + initialized. */ + tunable_seclevel_t security_level; /* Specify the security level for the + tunable with respect to AT_SECURE + programs. See description of + tunable_seclevel_t to see a + description of the values. + + Note that even if the tunable is + read, it may not get used by the + target module if the value is + considered unsafe. */ + /* Compatibility elements. */ + const char *env_alias; /* The compatibility environment + variable name. */ +}; + +typedef struct _tunable tunable_t; #endif diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h index dfa16c1977..971376ba8d 100644 --- a/elf/dl-tunables.h +++ b/elf/dl-tunables.h @@ -21,8 +21,6 @@ #ifndef _TUNABLES_H_ #define _TUNABLES_H_ -#include - #if !HAVE_TUNABLES static inline void __always_inline @@ -31,34 +29,17 @@ __tunables_init (char **unused __attribute__ ((unused))) /* This is optimized out if tunables are not enabled. */ } #else - +# include # include -# include "dl-tunable-types.h" +# include -/* A tunable. */ -struct _tunable +typedef union { - const char *name; /* 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 - initialized. */ - tunable_seclevel_t security_level; /* Specify the security level for the - tunable with respect to AT_SECURE - programs. See description of - tunable_seclevel_t to see a - description of the values. - - Note that even if the tunable is - read, it may not get used by the - target module if the value is - considered unsafe. */ - /* Compatibility elements. */ - const char *env_alias; /* The compatibility environment - variable name. */ -}; - -typedef struct _tunable tunable_t; + int64_t numval; + const char *strval; +} tunable_val_t; + +typedef void (*tunable_callback_t) (tunable_val_t *); /* Full name for a tunable is top_ns.tunable_ns.id. */ # define TUNABLE_NAME_S(top,ns,id) #top "." #ns "." #id diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index 622199061a..cda12ef62e 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -156,8 +156,10 @@ END { } print "} tunable_id_t;\n" - # Finally, the tunable list. print "\n#ifdef TUNABLES_INTERNAL" + # Internal definitions. + print "# include \"dl-tunable-types.h\"" + # Finally, the tunable list. print "static tunable_t tunable_list[] attribute_relro = {" for (tnm in types) { split (tnm, indices, SUBSEP);