From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by sourceware.org (Postfix) with ESMTPS id 5A0CF3954444 for ; Tue, 3 May 2022 16:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A0CF3954444 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=NxrCW6UtY8/d+M5NSNsTlCvmYlyfHTjqYHg4TMXZTCCRktq6KrDAFiE0wToMGhY8txElpUg55MSRqiKBJwFkhQHi4wfu/MmqJZfy+5HClZW5eFffFqR5OCcKbQvmjbO4pUMml3NydXCUkJXaaRBVy1DOs+uIFAb3qlxtYKCxE4BgsxTMpIp+wXgOitYs3x6j22Px/PSpWicWooaYjfAkxc6hHKUoCgq/uZLfsac9Jonph6iKni1qUUsPWrlLmReiNHwkgFjZf9cOOzO/MRsT1wodoxDZ5TwUfBhTLlQxrT/4AOufUctDlTnspex25WZzvObEU4/gnyFFU1b0BJ8i+Q== ARC-Message-Signature: i=2; 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=40yxiXsDtIUsP6zkl4OaSrgc7z4nfRg4R5bNL3OB+yE=; b=BeuDhBbpWtCNcIXADWuHh53WTWtWshGcdt/kh7X8AAzBWMrat9ejuHBSkvZnedWEfJ0gptEVv0bTlxjgHzd8RZYA/1AnVCn3/gZ8qAiuLjVV4Mf5vrUJ7RPTCQlD+GULFQfnHSwq+C9jJtp3alqsF4xOM9P77+MwY3ikDboHReI6ttifOoGpEjFD2FjoGZ6Cg1k3+7Fcv4n52+Llm43Xj+Tb7p/SCJ4lMuty1OSbWTvSpUWHlW311ir4CnJ7nRQhJArBdVrrvwRja763hCX8fS3Z4f0aO9hxFcYZo7XHQSIGgB81UA6YTqJOEDgEsEW90z+gmfDHvttUeVMyJM2aHQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR0301CA0015.eurprd03.prod.outlook.com (2603:10a6:20b:468::23) by VE1PR08MB5597.eurprd08.prod.outlook.com (2603:10a6:800:1b3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Tue, 3 May 2022 16:54:10 +0000 Received: from VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::c2) by AS9PR0301CA0015.outlook.office365.com (2603:10a6:20b:468::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24 via Frontend Transport; Tue, 3 May 2022 16:54:10 +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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT045.mail.protection.outlook.com (10.152.19.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12 via Frontend Transport; Tue, 3 May 2022 16:54:09 +0000 Received: ("Tessian outbound 9613c00560a5:v118"); Tue, 03 May 2022 16:54:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fcbfd2e23d9a3fd2 X-CR-MTA-TID: 64aa7808 Received: from 01f57076d805.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8ACC18CC-39A1-42C5-8B81-5FCB184DA7C4.1; Tue, 03 May 2022 16:54:00 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 01f57076d805.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 May 2022 16:54:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXNqxxcyuOChxyFM4amdSIjoOxTxuEKBxH5Vm8mc7R/RwtUGTCZRylt2OdgvxucPM4nsJ/hJ4VcdCBb2RcQ+M9tA7U2TqTYbicdRLUb2ejEn7dUyQfpNT2RcFniDKC3MD1QpG5Vk3r0O/y1sCb3mQmqdruwUZfD0moWX8/lnZyBXUWsKtnsGZeVvhBZI9adBMLdE4ScfnpCqa3d/KBiyCvOsUCUhRAXEIlCXBwR2ITWBOBMp9o6/g3WCzbiVK3Op3Ot0OxnfZRUpw4fJa2hXarBqJq0eL+PHSuWJQ7HN0l+dOTlo7dcZLqgWyw8m4tyDkHtjFjUZYSxQw9UaasgrAg== 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=40yxiXsDtIUsP6zkl4OaSrgc7z4nfRg4R5bNL3OB+yE=; b=lSG7Eqbfu241Av0CrpmLlfcbax3MQe5Y7Beiht/4C0Y0pIAE2JfNc/dSnIlcF5z8Ix4WMdkW2U1Xw7p60h/7H/YxmtjjOl74GBPuH19shsr8tNPDUi2khCYxzoCDSAdQm4tpscvwujJefj7f9Ri+FjS/qM/SkQbLo3bwjS0noEAbCVozjQk0o9mK1YGvvo73s2b1pDKIuDL5leGOad4VvVNk0zN/ba0ZfCxYK9gA505wBm9FVZOKoPj4wBlPtGN/tbggAVmyj726Y0WyD/+uHDq/AIeHEoKfVqDJZT4szRW7KtB8ZkLc3H8f8haVDHJn0XI91UoBh9Gwd0rH9cZlig== 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: 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 DU0PR08MB7414.eurprd08.prod.outlook.com (2603:10a6:10:352::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Tue, 3 May 2022 16:53:57 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::9ccc:fe7c:19e5:bfa6%4]) with mapi id 15.20.5206.024; Tue, 3 May 2022 16:53:57 +0000 Date: Tue, 3 May 2022 17:53:39 +0100 From: Szabolcs Nagy To: Florian Weimer Cc: Szabolcs Nagy via Libc-alpha Subject: Re: [PATCH v3 1/2] aarch64: Use generic argv adjustment in ld.so [BZ #23293] Message-ID: References: <4a157fa95462503bd1b6c3218644a0334ae52325.1649854695.git.szabolcs.nagy@arm.com> <875ymmx26o.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <875ymmx26o.fsf@oldenburg.str.redhat.com> X-ClientProxiedBy: SN7PR04CA0240.namprd04.prod.outlook.com (2603:10b6:806:127::35) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: a4e20e49-7070-488d-02cd-08da2d258af5 X-MS-TrafficTypeDiagnostic: DU0PR08MB7414:EE_|VE1EUR03FT045:EE_|VE1PR08MB5597:EE_ X-Microsoft-Antispam-PRVS: 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: JBlj52/HC82QM7uT86tgDAEzBwDnwClGsbsVMA7Rr1B72uJ46dd65p59o/ZcxHZ68z/nUuhVSRam7shVQRQqUW/u/I3TuNA/nDcSM1bDDkyHd/X5ew/UopH6Bn7pAzM059Xan1gaDG8wf+uqK0yzaHuwE2aw9XS75kmQTPl1Ajb+YYzuAgu3KYQBFldRuajdkEf7+q17NdEGBQWp5AIzhuvxHeQrwQ8BreObraebanlxcwIoCefNbsWp4R1YyMCGGRzr8Nk8S+ocGFPi3+OHLvmenoGo0ftk6Hoj0/b8bpg3khDdnOgfoxI6Fvuw7r1etKv2ITkMHeesAuGXHGBPPZh15z/xbw/R0Z7SKt/8LZwvZeXbhzp8lkIbchlrHKUtG6EzobZPX/AmaEN9pvAPj1eM2hNczzeH90Z+JyyuPTII/nAUVcawMWwIZ1Xl+Dkc11gGlQOU3FbC3VdYwVD3KMkSSI4N5nCjtAfEg8iFvBp2p2o0T0k/iWxlroGgU98c1obgFGArHleREehzg3lI6pHNLntHfbWAXP9ZduEIYnYm1nWpKyQaVGETr9I8rOkWNcMBGhHdGZ4oD47YOSD/mZSCBagsYwQINM0CfLeRcQheZVsqnEeTSDTjnWkTeLRPFvANpGl6DtDLRd8ShDGDoxlT0s9BmRc1ubc/UBc+2QH69d6hKQ3eIEjDNuwc7b7tROFPowkKuyinjjOx/Iw7FQ== 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:(13230001)(4636009)(366004)(86362001)(2906002)(6506007)(26005)(6512007)(36756003)(508600001)(8936002)(6486002)(38100700002)(6666004)(44832011)(5660300002)(8676002)(4326008)(83380400001)(66946007)(66556008)(66476007)(186003)(316002)(2616005)(6916009)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7414 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: VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 00ca4f86-71c5-4b83-1f3d-08da2d2583e2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ww+emLcO4YHR1IiuCskQSoejMm7ztoRsfFAzkaHoGRiQ63JEr1XFu41PQ3gl4Zr0djk1wb2e4JskgdLjx35FPVQzhFDA7b2hu0JJcKz4r+XuKH0IFVevcRQLi0yndj/rSW/s0XAdanWEFsN5uhwIVg+9es5YzRKdKSxk2QQdJNDtGGy+NwzgewWd2gtMd08TlwoDRk5AIVvkDUto3s6MdRzMyQkASqIiZfFbvHvPNeBU76bFfTOTQlKbAhQENOj3+xSqIK4M23tu5sH1aSwzXKatovsNHs8Cb438CaU5m+DcYbPHIUSVpCTLusg7Ria6onIJycglDwLJpkFYXNwvyjN8ecu0zlalmo0/BcmgYnHSfoulveKfUN5SwAdgYP+iiMKy9HjG38t+LiHDFjmzB+jel9iGGmIaN3Km09kMXNrRwFayaqCkuA9RJbBcTCxALdNtsV3OCMhDCKsgQ+HF/OB21MAh4vMCZFjXPvH8LvlYZgAFxZC4xQs6On0dEiIM4JqIpCpXa6kw52mLpj59A/pnu38BITyGjcg+u4wr0mXtazlToWI4rbBY2whJAHBggX1SanN0qpTaQHQBdvBYNZgAIt3HZ1ydk81xoc/A4tRyjc4gBwlaBmgJpRBh9QFeaYZHYFf+AFWOqVyLuXDnwi2JU8MysfkoiizYY/NKGa9mex/J89gFHdPFrGH1gwe/Xd9/h5nLhEEOKqvHPOga1Q== 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(508600001)(81166007)(44832011)(6486002)(82310400005)(26005)(6512007)(6506007)(83380400001)(86362001)(2906002)(316002)(356005)(6666004)(36756003)(70586007)(70206006)(2616005)(186003)(8676002)(6862004)(47076005)(4326008)(336012)(8936002)(36860700001)(40460700003)(5660300002)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2022 16:54:09.3636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4e20e49-7070-488d-02cd-08da2d258af5 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: VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5597 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Tue, 03 May 2022 16:54:14 -0000 The 05/03/2022 13:53, Florian Weimer via Libc-alpha wrote: > * Szabolcs Nagy via Libc-alpha: > > > When an executable is invoked as > > > > ./ld.so [ld.so-args] ./exe [exe-args] > > > > then the argv is adujusted in ld.so before calling the entry point of > > the executable so ld.so args are not visible to it. On most targets > > this requires moving argv, env and auxv on the stack to ensure correct > > stack alignment at the entry point. This had several issues: > > > > - The code for this adjustment on the stack is written in asm as part > > of the target specific ld.so _start code which is hard to maintain. > > > > - The adjustment is done after _dl_start returns, where it's too late > > to update GLRO(dl_auxv), as it is already readonly, so it points to > > memory that was clobbered by the adjustment. This is bug 23293. > > > > - _environ is also wrong in ld.so after the adjustment, but it is > > likely not used after _dl_start returns so this is not user visible. > > > > - _dl_argv was updated, but for this it was moved out of relro, which > > changes security properties across targets unnecessarily. > > > > This patch introduces a generic _dl_start_args_adjust function that > > handles the argument adjustments after ld.so processed its own args > > and before relro protection is applied. It sets _dl_skip_args to 0 so > > the existing adjustment in asm is not invoked. Each target has to > > opt-in to use this new adjustment since some targets don't need it. > > Once all targets are updated, _dl_argv declaration can be simplified. > > > > A new _dl_start_argptr was introduced because the original sp is not > > passed to dl_main which now has to do the adjustments. > > > > -- > > v2: > > - use p != NULL, and a_type != AT_NULL > > - remove the confusing paragraph from the commit message. > > Looks good to me. > > Reviewed-by: Florian Weimer thanks, meanwhile i started working on v4. that always does the new adjustment (even on targets that don't require it) since ld.so invocation does not have to be optimal but it's better to have consistent behaviour. then the bug is fixed everywhere (not just opt-in). is that an acceptable approach?