From patchwork Wed Jan 20 15:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 41771 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 3A2D3396EC4B; Wed, 20 Jan 2021 15:30:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A2D3396EC4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611156634; 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=kxzGSfyOUuxjeqQgNECkQWT9ndOj4RZi1g0avNcB1vi4oyxrSFDtj0r31IG28Hh82 qEmpO6dJ/8HK+SPi7ntELsZB4OoBgZjTDmpCr4Lb7tgWbSZgEAKFr5kBLkJsb9lVjZ 93w8jtj1L+8qRoaSl05uxpq6QhiXsMI0NCwYfb1c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80070.outbound.protection.outlook.com [40.107.8.70]) by sourceware.org (Postfix) with ESMTPS id B846A396EC34 for ; Wed, 20 Jan 2021 15:30:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B846A396EC34 Received: from AM6P193CA0096.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::37) by AM6PR08MB4008.eurprd08.prod.outlook.com (2603:10a6:20b:ae::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Wed, 20 Jan 2021 15:30:28 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::f9) by AM6P193CA0096.outlook.office365.com (2603:10a6:209:88::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 15:30:28 +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.3784.11 via Frontend Transport; Wed, 20 Jan 2021 15:30:27 +0000 Received: ("Tessian outbound 4d8113405d55:v71"); Wed, 20 Jan 2021 15:30:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c8846c176bead6e X-CR-MTA-TID: 64aa7808 Received: from ad3578ee52fe.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 93FC0AAC-EF7C-43B5-8210-3E6CFAE2CB89.1; Wed, 20 Jan 2021 15:30:22 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ad3578ee52fe.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Jan 2021 15:30:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OD+4/5zsabMQjAko2sb4cr4fbfMBdcOv4xDQHEchJ2WspmYXxAHygYzhD8NlPJLhWS5Q/DA+lmimrJN5JwWRKcP4C2x+qh1farsRh4BFhQrwS4Up971UghxT+iXow1n9Z9OnnQPXhGYsmzzhjbrSKQEKZFbYkSOpOnFz70opJz565tasSAnQ0RHXpC9+rElkcYwqzBpT2Hjiy/30oViamxcmrMdD4QWgvcnRN0CQvJsRX5roVolkwaPk5in1cwczXVs1gaaO1yMohxQtpfz7COIG5U/UxkCQM+wWZmFdFTHwVuotKBEZwrm4t2gNI/3lv3mREOX6sGvo6D72LIDiaA== 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=dAKkIUeRymlyvEfXX6WZDBQucthr3BK2mWfFXStThK09KNmBMJZC6TCeEVKqSpYDDSnDVUoZuL3xyRneR9DRfnzsa6R1khr+1OmANDLpfr3NEQInVyskl7Es6dekdim412kimE1AO4BMYlRLnX0s1MxOYQRnNLBaII8uPZ6pPt3OWnvwDec6XJcvZvs6QN7KrAD+Bx2lIKyQDkkTUU9+AdAqYkVduKPWu3SyfFtICgZSKojVA+x9Aqnmd9t2Aul1i2lPjtZJInulqxVuOroC/nuy8dos9nWmw/i78JqHAge5rlAUGVEbPD5SCnOCe2eyWK6GXyK6Y92dh7g3pLZUkQ== 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:20 +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:20 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v5 1/7] elf: Make the tunable struct definition internal only Date: Wed, 20 Jan 2021 15:30:14 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.51] X-ClientProxiedBy: LO4P123CA0171.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::14) 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 LO4P123CA0171.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::14) 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:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4bb7373a-40be-42de-2b76-08d8bd58509d X-MS-TrafficTypeDiagnostic: PA4PR08MB5967:|AM6PR08MB4008: 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: nKsyjcb6UKNM3PxKh6qLpFYs2BqTHGgJ8tD7voTCLwCIWvFS79wcda1dgAxsPi92BxB/exo/9mhIU41jnhxjg6EVvVOBvHtVP092mjkTzq9CElXBNabAmsPnL3HFkEvDBrHP1+P4bgsll4OZxdNKNIQ2LpGTRAxjYH6o6QXZnlEGxRR0chPXd6XRzYJ658eUJaN/Q4PeO3KUfPRfjWtnhoFQN9DbDj1DMkPK0dyD3oQr/wK/cspKztnPSoqI8CkcsrS/HKdmvCG4uGYdiWSV094k4H7DTK9CGdRZ0uVTxziDh6dTskESqZPVAjH/ZDzup7cUqN2GBVAN/3M1f0nk0cmDG/YwFILqzg/DEjHG6zEjWV4dIFJWCWsVasEJZAlV0HrZTyNyzZ6LKsGKVOoP23/1bCbeKL1PCy7DhFcI8nK3uaW25QrVL876h0mZeytcuiHh8hqapxHLKXf+q7aFoJrfmAn4EIhDi4k/4nr9XVTOz+GcdYVPAlJFfB0xhVaZTtzYSMYJjqB9a/Ol4g9FJ8dZ9hhwoMyttgatKXsVOH8= 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)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1ZEqh8V1m/Ri5QFFUkbP6jGmoJu1NyCg6cHCfqyrR5d2RJ6ysgbwKQJaMwgpe+OoiRvuGB1W/Wyh4JNBN4Bvd5JJzu8wgeQ/FsJAXtv4vWwII8A8idZZRsdXpSAvW8KxswUzwMRY8E0fZHjR1T8E6mQfXC90aGEtPo39lr3dVKDpN9GHPnBnyk8Z1S1H3I2T2c8ePj+dgbyztqr1SOk8UUvGGMqMKBWe35JoHDTfTMdUJDRJMPM/OZYWy8jCDYYInHtxy7ibSN7v29umv4Hf4PlhO4UrdHsSe9BAox/OCgMl3vAPFe2EJkA1/kIqftz1bSf8n5x24DwAUX/3kY0Llhg6MQJAbQDwtrACw/6R11SMfG5C8P7Q8ooMMYIWMfyEuPdLiND3sndfQsbAjYmWALFgsSFCMLzYMEL8zBZRf4QhFa061IBmsRMj0V3SMohUiTNK+jWm6CW+1hHSDxxwjbkuJAGJfYO8gHOsP1278a3rGpyiYipGt3iXHjjXK2HCkXaO8oGM1VVjN92N5jo4sNgooNiRxRAjKYutb72vh2RLPCPxFobIibxa9t/XsUKMOxDAZvHKSAA98/axIFF9RkRcaX45QvalyAjpVT2dnfY/w0hHTzPgweV3qUyJu8+pPncYjSBQUqqsqgxEgVY0gfZNZ3V65kcH8RPcW55bq+t2k4w4N1aTDt8DOGsV26hnAuhxiYl7QPNvWouHiHz0Eqros0ky+gKntKP+nNSZcdm8/KCOurDPye1IMe9XpDoiO0VQuM8upzbiK8p1aXcE5mWLw3kjypduqqHyNTrVeKDG+HgmuHHnd19V22BF3PyxI2DVfa4LGcpzb94iVndhp8rI55OgKLSBHsL1GZkN9abvbzH9idi+94AZIF0r5xkmV2DvbpjU/0+4pldWhMPZqkLkHo0tf/0DD/qoZN+QxpN2tpXni5VXN9KS6E/AjCR7IjQEK7bDNJ1+/qVjM0aYNfo/yHuHK/en2lL1cWONaP2ufJYqmr3BvCWbEimhRoQV 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7fbc1540-8f7c-431a-8e75-08d8bd584c37 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P4EchQ/VA+zMRFClZd6k37dxkDzWnG+1DCPbOQGV4P+M+YmJTBynn15YcLgELpkPuuHKYdz23CpbrxodYOBpmFqC7CNX5eCQG33fLwzsr8gPK3GixJHrB8sxvF8nz/sW7bnotyRlbvyjqihW7gsYrzTqBANBl2WiQNY3pil9IIxaWV1Jlkl7DwgFs3DZtVahJH808l9DJlleENWCLKHeSbpjpdCtuAWG3uqUDzpT0mnNmza2Yi7qwrkj0N60sIpiZcFVLghAEBjg1nWxJ/AFzZ6tBJCW/HP1F+kG1rDRxcx7JBYr/Oyr6HLcWZak4t3VMesyo6e/1BO5nzksNxfK6gWKsXWbuypwDNxIPurq5M2lfpX9nk8kAUNFROK0hHGaB+a+17ZfJB1TtnZnqNUlokAKM7KxwuyuoMQkP4lmvS9je59l6aK3ySc8Q/7zURfe5oNFkxAqj/3hCfJ/t30x2efBwtwlFv5wzOnfj6NCsH7ur5crAQBf3AIyZZtOn9MNDsk2GY/A4djnrcpj3u5tE/FmjojLjATlJ1T3u+EhsaO9FQhdmdFjbWsCcrPgMfkrWZThUzojgQu76rBt2yv8t3vrhKBSUpKbYs5jjVFWHFs= 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)(39860400002)(136003)(376002)(346002)(46966006)(316002)(478600001)(82310400003)(69590400011)(70586007)(186003)(6506007)(44832011)(2906002)(2616005)(83380400001)(26005)(356005)(6512007)(8676002)(70206006)(6916009)(81166007)(6666004)(336012)(16526019)(5660300002)(956004)(82740400003)(47076005)(6486002)(36756003)(86362001)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 15:30:27.8485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb7373a-40be-42de-2b76-08d8bd58509d 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: AM6PR08MB4008 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);