From patchwork Tue Jan 12 17:22:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1425345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=iKX3ltBB; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DFcpY2Yz0z9ssD for ; Wed, 13 Jan 2021 04:22:45 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1159389683C; Tue, 12 Jan 2021 17:22:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1159389683C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610472162; bh=KFLRP/UR1T3V1ePdWgOTCGZuAdS28qOo5XdFgSPrCH0=; 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=iKX3ltBBF59gS520+Us2cP5hRCtRcS4WVcK0h36epoMuUsdaYbbjjDqpsYJvtFqZJ uVnfQMUJtT4hUkEFl2kcw33eVYC7hCPAtjmIYQJs4WkwPPCmZwJP4eDgHUn+I2RMPt nJK+8hobrfI1TGOwkz4xwnCY2CbiFgR/q+iOG0Qs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40086.outbound.protection.outlook.com [40.107.4.86]) by sourceware.org (Postfix) with ESMTPS id D88EA3894C33 for ; Tue, 12 Jan 2021 17:22:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D88EA3894C33 Received: from DB6PR1001CA0019.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::29) by AM6PR08MB5061.eurprd08.prod.outlook.com (2603:10a6:20b:d6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:37 +0000 Received: from DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::a) by DB6PR1001CA0019.outlook.office365.com (2603:10a6:4:b7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:22:37 +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 DB5EUR03FT053.mail.protection.outlook.com (10.152.21.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 17:22:36 +0000 Received: ("Tessian outbound af289585f0f4:v71"); Tue, 12 Jan 2021 17:22:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 242385fbd773d8c1 X-CR-MTA-TID: 64aa7808 Received: from 9ca4217b47f6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3544509E-4860-4569-B965-CBF2E19A0D59.1; Tue, 12 Jan 2021 17:22:31 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9ca4217b47f6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Jan 2021 17:22:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5dVU7A83WnjMXVtCazk7DE27S8Ev3qK3XXjAthnB8WfCCv4OTfpK+qRWEg3W23rJtgte40ote98g37unQL2PTlyIppLeP1NfAKtHK3TiM7tW/03efpf0u8tPkhqfHx2qES4fMU+1rr9L8vtJbQU50qZKaJx2xRYuCuz2FoOZ1Zsi+Afns92Zl/V6P8jfT72me7axlr+53he/vqrrGNA84g3O0un4iOglXaQM34n7Cst1PQ7js18PfVLanJI9xpKjO13Nn5UnSGYzrrzZgyLw1QinamzR5bOwTDkdUI/7LaCuUFj89HVKwaLpQRTHaA9xZrUB0rf1E7TqYRssYa7GA== 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=KFLRP/UR1T3V1ePdWgOTCGZuAdS28qOo5XdFgSPrCH0=; b=fg47UpCKpMoG6AM+NyiCeQ5Heeno/JZpXBLKcoJDi4LAXnyz6Eq5sxhZBAE9N7Y4crDwUIMdXTmrdZa+dkgj0Obg2TY9BP/8tVr23tsxGjq4MRN8/DNKf1tPGIjvwFL1DIbq16GzZdLLST5QRUJ3rv/hemrkSuG5kysgRwZmhJOCmGuOFA4mzNzA6bs5T9KO8ESWe1bPkDgFK24spohLXve2IBaU3N8UccfLCibb8gh9nvN+P48w90B1FJSMXkPrShzrS/1rez8fORTVB46I/bhnbj4W/v9+0qnzusCFmpWwkLmRl0sji6A530Mx+9nvYb+ZneecrHMfsULBdbGMUw== 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 17:22:30 +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.012; Tue, 12 Jan 2021 17:22:30 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v3 3/5] elf: Make the tunable struct definition internal only Date: Tue, 12 Jan 2021 17:22:18 +0000 Message-Id: <7b64c9aa6cd771ec569c51d50395147e4b22acc5.1610471272.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.50] X-ClientProxiedBy: SA9PR11CA0007.namprd11.prod.outlook.com (2603:10b6:806:6e::12) 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.50) by SA9PR11CA0007.namprd11.prod.outlook.com (2603:10b6:806:6e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Tue, 12 Jan 2021 17:22:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a0e12876-21f8-46df-b8f3-08d8b71ea813 X-MS-TrafficTypeDiagnostic: PR3PR08MB5753:|AM6PR08MB5061: 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: sCOvdsPGtRowJp4Lg0u44EvgRuhWzsc6LzxEpzN38r/8xyBv9Et8VZXYZF4apmngXRqZROll3zn/YWHxQs+i8y5E9TseOMdRkwygQ0oa7lS4FElVac2DyRGw7SlL0rYPcPqL+jjX1Qysvn6pc5glDkK0cTjt4oi8ytS0vg3/DU7RHSho3eGuT73ECikX/6E6Mw14XrOi8eL6+CzqJOwG3EFGEysvmb8HGG53GuW8yxheSHjSCFEjopjpL/hIXRHPYRoRULYf6QkVYHguh0iL1lYiJxUbm6E1HXOnhr6320RAtz8qjOZuZAlnVkbURXEei6iyuqdi0FNw+wEsmQ5cON84qHbf2Ft/f42tRCH41VasyI/teFjzGYNWbleVqlsKTeq7J1rb25da61vp5iZHZiPY5qRgR9fZ+E+pdKmzcR01DIfO2WHImIbXsQ+0TmcRy1jRaJjGPqStAlrG/3ZX0mSASn2loYpPs5066vKOQEFwmbWCFG7QMoDX4RdmoM5EagvvXFmZf1VsDwyCaOzUjjvTb6A4aa8P6SqFpj7IErI= 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)(136003)(39850400004)(346002)(366004)(396003)(16526019)(26005)(6916009)(86362001)(6506007)(956004)(36756003)(83380400001)(69590400011)(478600001)(2906002)(8936002)(186003)(66476007)(6512007)(2616005)(6486002)(316002)(5660300002)(66946007)(44832011)(6666004)(66556008)(52116002)(8676002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QPd6KySVr0SYynQrLVE1eyhQdf2Brfd588+B0gtsNdMzaTv9jgkm2RsSWDmr46W1Stnvt8IXToeUbJa/LBBBgOi074sl1JO/SamgGne93E5LrUHw0QBT5nGwYmBwRFBQVFKifutyVLL9b8LLa2alvB9LqEiw3m+JZcNUuSMsE49CWESKFYtfbnAbLvmi2XEyht4Fr3Qm1nuZ0CN4/riobzJV0tRnp91Kn4IPOTkhQArraJMnhK2gaUyWhqqfZ1JqiePN2gU9SqPgfWaKTckxWF2JLgxHoRV3NoGL8fGlHoAopKvKZ29VhNzxYgjRtGsAdsijllyCBi1q06TkNtc7nDig6La8+KEsbiYEzX4IJAhJ+7lHqyAcMUk3kuygQviQVqmUIc9ByX3k2dP0eyZKlb1LGZr2vHom2ULcSoSDQ7tcipuifxJHkoGUuF83WzhhNo1vk6UlY8x0+cbnQYnzNwh6MRsSCd4lEfgYrwA75q7NEkOhO+ORGKv5cpG1qFfN4y1nhIpOZt+7/l3JVPdzXqEfnUKBlWaa2dw5xPkjzo8/N+VfPkr+m+vRlxpkQSfTvx1OI/AtFn0fcWJxG7Im/GwPJVD5Gnsks7Sz9YFe0l5vY66PuGr6SATijbo3eww7ekndAsqMWvYBsumGQB6IsMaM5gx8MblSwn2VBPlOYxiG0xKUVGbMyoVP5CWArkur0qOKZSA7HGY515arrrHzL4fOoErk+He5rqgQRO/4LdzPQHfOCuNMJlr4ZXMOAO6FSNmowKkEINAPHSYsbh/GxoFMZtUEktkd25WPcYJGBp5D4PguSJbgyjqxyLXoq5MLfQSsb0SvNXG7apAa+vS2rEFUq71XSeIdFsYVbiA7YYCkqH4jFH68FFctEbP0u8PlraITGfRofBnxVEIfhjNQYImWt3VX2r39X2+j6zdQoYE8MByo9HgKOVfhMUNYqWRLjIG9ACmvfIj8R3hd/qjUgCsaM4H6AHnZiSBJvdq0PsaP8E5AEe8VGUSqYiSDvSoK X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8dece590-7aa4-4552-797e-08d8b71ea41c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QBSFwADcCLxXpD5rrf2gFeuHnhTo6olG4LruUfD9sW9a5gYgpJmAJGaF8KU3AKiiyEvhUCcuDqu9DH8TS+iG14BMDpBuO635s1aXkw93xulxe0XeiYo8JxAxYrBhTNLP80FE4T2G3JQ5S3+1g5xeoIhfLcJXucnMD6hbJcJm8u/6kAWRTu3QHwh5sureyVCyHlh5uBQvIzONZoGUPs/9RfO8WbtfOftKS6Xff+6v1mf6lLDGoTOxMmRQGAprMO/CIeY6hCwe1fCzka24h/Zact19MIkWp3mnGHq9qcrKPqIzf57/93A2SiiYmManEkIN84XHtmt2Va0OVLp3ly9GWM7nEbkwduiyTgegQ+C3QYcERZqzL2gN+rrsrDwg6nEePrNBBP58wCdc3vgpvjIAQqRlVbHfU2FPX7RTMdSAO9AtScTSF96oBJaubZLbM6uFHOwqx7zaDxNfqk5+v2KyFldS6xrRlN4yffCX51khGuk3TNfQJkjw3BALFF3xPnai1YZFIZwA2Sd/nsRG+Zy0aBoxZ0tRh/kf/wD9yz3API203cqUNpNEZ3aXsvqxeSiW9lE2PU0qcSvJqf+Aoxc710Mw4axE92EDczbi7bSarj+WcbbV5a3gLkMX8MD4bxD2 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)(396003)(136003)(376002)(346002)(46966006)(6512007)(86362001)(6506007)(6666004)(316002)(69590400011)(70586007)(83380400001)(186003)(26005)(36756003)(82310400003)(478600001)(2906002)(6916009)(16526019)(8676002)(70206006)(34020700004)(6486002)(44832011)(956004)(2616005)(5660300002)(336012)(82740400003)(47076005)(356005)(81166007)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 17:22:36.9622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0e12876-21f8-46df-b8f3-08d8b71ea813 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: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5061 X-Spam-Status: No, score=-13.8 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 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 518342a300..1773c7e254 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);