From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2077.outbound.protection.outlook.com [40.107.8.77]) by sourceware.org (Postfix) with ESMTPS id 27A9D3858425 for ; Mon, 4 Sep 2023 16:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27A9D3858425 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=euNRnY3Tol2ZAF6Qukl38xZlokT5xMt17gaS83iyrLk=; b=ayFVVNMfX/3giZqLpNBFr34ut15iWF8kidImW3RgkXdInw8eQhV9UteCzCGaZOTwjCJh8QEIsV0UDr2BN5V+5SDEGkaCG93Qeu5Jr+8+VoLo7Q4o3j7wJ/+8dG7BdkcWAAzOZRu5uRMvlKeG1XICbF+R6mBa4VPTZ/q9oCcpL9k= Received: from AS8PR04CA0002.eurprd04.prod.outlook.com (2603:10a6:20b:310::7) by AS2PR08MB10083.eurprd08.prod.outlook.com (2603:10a6:20b:647::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.32; Mon, 4 Sep 2023 16:37:43 +0000 Received: from AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::f2) by AS8PR04CA0002.outlook.office365.com (2603:10a6:20b:310::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.32 via Frontend Transport; Mon, 4 Sep 2023 16:37:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT055.mail.protection.outlook.com (100.127.141.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.18 via Frontend Transport; Mon, 4 Sep 2023 16:37:42 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Mon, 04 Sep 2023 16:37:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b614115515352484 X-CR-MTA-TID: 64aa7808 Received: from 23fd5d69f761.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3CBFC850-C8DA-4E23-A129-2B32567C3D64.1; Mon, 04 Sep 2023 16:37:35 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 23fd5d69f761.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 04 Sep 2023 16:37:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQh7wv8dOh4nE9ncbo/M013qsG3UtZR+NVJNA+BKB67Au482wnfnSUOshTPnLb+i40rOJ/d4iQ0nQm0mxn4RSSwdMs2ltVYQbb99HMRwV7TUCnGwRUf8gj95jIs7ILCn02w1n9uJkT7N1TXL1nbkm4lfwUP3n+sXMBAGg5BN70JXtA+AuXGQ2oDmZGQKBMBtDflpkXQDuaQvO+gRY83MXBAIcFa2qSeb+TOyYr1lTeXK7SwzNxwO5d6cwifAjUrZJdN4Q6r/oub9n3TGNhP7CgOip7kgrMjnmCZNscN1eXKVlL6TDZZngHr5/pDnz9y2IsyhdY7K9GlPpjs8nsxvfQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=euNRnY3Tol2ZAF6Qukl38xZlokT5xMt17gaS83iyrLk=; b=UqtC9NVGE1bJ2eMv1/4cfI2mDrkI/SKQlHZxA9cMyY/u6cHF0nrcuFq6gWiWzbsRJf/gUB4OVotduJ9at4ZeYfGnyU1brtmLRYHYp20n8doNhRFKMLqKbQegEWSyyWTvgOWIX437A8ArGFMDPE3ZsPHlZKmRzeHm92Jj2vrpXfxPCRXsvtPJs9JiEkC45JTt6hjcij1x2ZFMS9OXGV23S6VDj+FsEuzAOWh2aJU4m0JTH7ecast/wA8xDU54Y5T9rwUWoU7H82bSzxf8SQXWTcBcEpK8amDi16zsnKSFV5k87sPWnM6MKf+dwsHgf+0ko2KY/V9PgexU8OGDMaRWwg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=euNRnY3Tol2ZAF6Qukl38xZlokT5xMt17gaS83iyrLk=; b=ayFVVNMfX/3giZqLpNBFr34ut15iWF8kidImW3RgkXdInw8eQhV9UteCzCGaZOTwjCJh8QEIsV0UDr2BN5V+5SDEGkaCG93Qeu5Jr+8+VoLo7Q4o3j7wJ/+8dG7BdkcWAAzOZRu5uRMvlKeG1XICbF+R6mBa4VPTZ/q9oCcpL9k= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by AS8PR08MB7839.eurprd08.prod.outlook.com (2603:10a6:20b:52e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Mon, 4 Sep 2023 16:37:33 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::adb0:61cb:8733:6db2]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::adb0:61cb:8733:6db2%7]) with mapi id 15.20.6745.030; Mon, 4 Sep 2023 16:37:33 +0000 Date: Mon, 4 Sep 2023 17:37:17 +0100 From: Szabolcs Nagy To: Florian Weimer Cc: "H.J. Lu" , libc-alpha@sourceware.org Subject: Re: [PATCH] Linux: Support non-variadic calls to prctl (bug 29770) Message-ID: References: <878rkiu72f.fsf@oldenburg.str.redhat.com> <87cz9usjn3.fsf@oldenburg.str.redhat.com> <878rkishbo.fsf@oldenburg.str.redhat.com> <8734zuuhbr.fsf@oldenburg3.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8734zuuhbr.fsf@oldenburg3.str.redhat.com> X-ClientProxiedBy: LO2P265CA0487.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13a::12) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|AS8PR08MB7839:EE_|AM7EUR03FT055:EE_|AS2PR08MB10083:EE_ X-MS-Office365-Filtering-Correlation-Id: f48fb749-fcbf-45cd-a357-08dbad6542d0 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 9kJ4wW9vsr34XbhrG+L/Jwx5gPWl7nSsMYfB0u5lxwiKAeV5On+OEmpjRN2WP5FHkaBOexSuLsBRgTOnSqsgGlnGQ/BEhKlCDNa78WJVCCOmLaF4aI+/UW0w6Xd25OVS9QJqmj2Keq+K3gGpgtj2cz00+4Xfe2eep7ocGg9CD68T7Q43ROvc3agjxe109Acwu9fbu4cbT7dJW2uyCBJEbfFHdQt1fhVrZZF+z/h6rL3vE4iowYwtQt2WGsUkl6z8hLZOKsuwsf6TYoNuz5x64FVRnD1EyG8hJU4kgw1A0G3KuO6HsnZtuVtaIq/TR1SLAAJZnsvxa2aaj9HFOVHB97pBHkgwNc1VHbYZQlIcNospBABB6eg7vLb8XA4DhMDkZL0e22CBfDyX1eQ1qZ2A+KiH+nZhdr0EZHaKeSGwseBYvZD//GfYyzEr1YiEgr2aMIgNAmXQ1p1tJpHiQ1vZov9QkUR/DVDj9ioELWYIKQWv4CtIebGIlG838mQ5vm10ggMo/20HnfFqP91JtedE5sxtWsY+ioS1Ger+Tkw02+GVtffoVbbmpFOLQTfWIgSN X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(366004)(396003)(39860400002)(376002)(186009)(451199024)(1800799009)(83380400001)(5660300002)(8936002)(4326008)(8676002)(2616005)(26005)(86362001)(44832011)(6512007)(36756003)(66946007)(6486002)(6506007)(41300700001)(6666004)(38100700002)(2906002)(66556008)(66476007)(478600001)(316002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7839 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2e9de07e-1f7c-4630-677c-08dbad653d15 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9/4mNpEaODy+6AHdPyZFKXgV5j9H7HQSrlUiAyAT4slYmWj8quoXD7OlXJcQI6Nf2QU6zJYwPIrZd9jUQDjCxVnHPqM6swpzvq2Pm1OoCNH2bwW54DxDIFSNErpVzdSTAKO8W606jkrnnlEFWkGKlgoZU4kLvqgirwxxyejdGPMWY70WYLCbKbmWWSWJXze4IYmm2CuJNo5SFvaeyNWnZF5hZRTag91rFWkTHGmmUgrQzX16zo6NN7L3ymI66PwetwzUdALWT8sfLO9whjVF4Ey4Ace63ImpAFyqfG6+DJ2DbIBWHh6jEM2CpkFfJcdMc/GZ8wqWuFXECOXQm/bpvwGWCsj6b6kMi0LV+tjyt3VXx47v0Ee1H10W/FTIP7WqBgLpK0SkO4UuznhWJ/3P/ZzYivzlEut5UbQt8Fe9SsFl0ywpX+3GzVRghTOjMJORZtnsvInj2DfMoRnzQlah2+O4rCnci2ncuRLDQNsh9MiMzZzp0DWr1jNAbeLb338waU9G01nQ3B0BjGT5gsd/x+hefDZsq43MME1MencKitIJmjCWCrr58J5IUNUtphhYIJ38PtAcCRMhliHligztM5U+xsu68+LlYRR8wtJy5Y2AyneOfjC7YZtm6YiVgB8ZkBqUy1IItP+TMzpDo/l6brx5K6LPxNDFoEL0SXmfChGuV59QKh4RTfVYTWudrxLGRT0qYuf32p6qzBcJrGcNOmgyg5Sk1B8ZPdJcwsUN3nb7REH9eUIr+ZMN0UGGykCF 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:(13230031)(4636009)(376002)(39860400002)(396003)(136003)(346002)(186009)(1800799009)(82310400011)(451199024)(40470700004)(36840700001)(46966006)(40460700003)(41300700001)(356005)(82740400003)(6666004)(81166007)(26005)(86362001)(478600001)(2616005)(83380400001)(336012)(6512007)(47076005)(6506007)(6486002)(36860700001)(40480700001)(8676002)(70586007)(70206006)(2906002)(316002)(36756003)(8936002)(5660300002)(6862004)(44832011)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2023 16:37:42.6547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f48fb749-fcbf-45cd-a357-08dbad6542d0 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: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10083 X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 09/04/2023 16:46, Florian Weimer wrote: > * Szabolcs Nagy: > >> I don't think that's true for our current ABIs. They support > >> unprototyped calls, and by extension this also means that calls through > >> a variadic prototype to a prototyped non-variadic function must work as > >> well. There are other ABIs which do not work this way, but glibc hasn't > >> been ported to them (and it's unclear how useful they would be for > >> GNU/Linux). > > > > this is not true in general. > > > > unprototyped call to variadic functions is not valid in c. > > It is valid C before C99. as far as i can tell iso c never allowed unprototyped call to variadic functions. (looking at sections "3.3.2.2 Function calls" and "3.7.1 Function definitions" in c89.) > GCC still accepts unprotyped calls with a warning in all C language > modes, which is why I think we need to keep supporting it. for me gcc accepts void f(int, double); void f(); but errors on void f(int, ...); void f(); as it should. > > so unprototyped call abi does not have to match both the > > variadic and non-variadic call abi. (only non-variadic calls > > with arg types that promote to themselves need to work.) > > It's true that the ABI does not have to match exactly. We already have > several ABIs where non-variadic calls to functions implemented as > variadic functions fail. to my knowledge, we do not have something in > the other direction (and we really can't, for pre-C99 support). i gave an example below if we allow floating-point arguments. > > e.g. on arm variadic functions always take float args following the > > soft float abi, but an unprototyped call with double args uses the > > hard float abi on armhf (int vs float regs). > > How do you maintain C89 compatibility with such an ABI? I assume the > difference is only in the non-variadic part. For the variadic part, > float needs to be promoted to double. an f(1,1.0) call is abi compat between double f(int, double); double f(); declarations (double is passed/returned in fp regs), but double f(int, ...); is different (double is passed/returned in a pair of int regs). this is valid c89 implementation. > > i guess the prctl case works on existing abis now, but i think > > future abis might want different variadic call abi (morello is an > > example, though that's an experimental target). > > The ABIs are already different today on powerpc64le today, even for > prctl. Variadic functions on powerpc64le assume additional setup by the > caller, which does not happen with a non-variadic call. > > The man-pages project used to document prctl as a non-variadic function. the man-pages project is confused when it is documenting syscalls, sometimes documenting the linux abi other times the libc api or not following c rules at all (see e.g. open or futex man pages). what matters is how the function was declared in glibc headers.. glibc could make the declaration non-variadic which would solve a lot of issues, but i guess a new symbol should be used for that then. > > prctl is nasty because the arguments are often passed with the > > wrong type (e.g. int arguments instead of unsigned long) and > > with variadic prototype this can pass wrong value (e.g. non-zero > > top bits on 64bit targets) down to the kernel. unfortunately > > whatever glibc does internally won't solve this issue: the public > > API would need to change. > > The C wrapper I'm fixing tries to solve this for the ILP32 with 64-bit > syscall registers case. It's just that the original fix exposes another > bug. not sure how you can solve this with a wrapper. unless it is libc header magic.