From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2049.outbound.protection.outlook.com [40.107.104.49]) by sourceware.org (Postfix) with ESMTPS id 6E4733858CDA for ; Thu, 30 Mar 2023 14:54:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E4733858CDA Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VvBAL5pUGxAPqQ/AI0XDwy6armebf410b2fAS4Eq9Skf8VuxLYfQMHmoLxUDyOHKe0V+Hw+xvbuJdsS4wxB59ZrNozgxPhUu5Yk4xwEqIIvulXmjAaYZ7VrT589pTHDBnR6HZjg4OReDN6A8kJP6hBtrQJaZOk/mrt+tLR/zuQKvVc177ZtGQ9G3WqNbGb5+of39IQsazHDws02FUokUt2UXGh/csLHPyQZbi91KxOq9QfNTAu6XLNDMU+pKGSZXMwWesHyN4zdoNykkkM08sCJWBSLexpQ4TUdOvrVXBElD/Ireog2bAN/RwQyBwlLNuyIcYSmUUKXogJ8dCar7iQ== 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=gwkSlEXH7/PkVavwSih5q2kXqTDd1KZ7aR5MmAwZWpU=; b=CfHU+/SCHChBpOBTp74ILNhKdc+0ILjCa2INlObBBO3XkfEtukQFaweZNXAUgvrntw+1Oq36AXBIp3YssyEOQmg4J0Kcix48/NWFs8rwkp46OFINprFvIZNlFliyZnqLZ+FnYCAcJzVa57BmCAxuIfIDQpljB8nb625NC62P3wmUAgGkUrohTx/1gUydhVSFr1wkEnN9CA70sMI0H9osgPPXS57L6kZzEdOYrBqM50V+IuB9l27yZhf0FAkWpcbOQm97KM95vfbHvK9yngJCfm5o8doH175yv+0BPyEuwATaViODjvKRwVSgaLmU20b1Zn8RKoHKlj+pDNQgw78ybQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gwkSlEXH7/PkVavwSih5q2kXqTDd1KZ7aR5MmAwZWpU=; b=rbovTxhRZzTRoJ18CdL1k2O3Md6RYdNIY1HVH0NB2dD8zfBIJD4H2hfznH3ZddMTbJsj3ve83rXIne0oJCFfipGmaeY6bpoyHRTo6ZupWQEIw7IOG8b4MPGxz2DTITaG6C3QtuDf6kBsqk53f6l7fGQqHaQsKo5yma1R+Kjsdnx7wvbqXHHV1nBixEvNAg4fAmdhdwOneHIKlBPMF7az3LPqWYVO4hLVjo2/74iLIUfsS08iyIMuxH8emvnyC0KkCqIDmwgAMFPGYcQaPHe0CHuHusK/px+75ZuacenOPspVh+OqPMofJDED6b3iR60jAqSFam6nFR9+tpyNZXKNZQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB9189.eurprd04.prod.outlook.com (2603:10a6:20b:44c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.21; Thu, 30 Mar 2023 14:54:22 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6222.033; Thu, 30 Mar 2023 14:54:21 +0000 Message-ID: Date: Thu, 30 Mar 2023 16:54:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] x86: Check unbalanced braces in memory reference Content-Language: en-US To: "H.J. Lu" , Nick Clifton , Alan Modra References: <20230320170313.354203-1-hjl.tools@gmail.com> Cc: binutils@sourceware.org From: Jan Beulich In-Reply-To: <20230320170313.354203-1-hjl.tools@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::10) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB9189:EE_ X-MS-Office365-Filtering-Correlation-Id: 393bb9b9-84a2-46e7-8c75-08db312ea571 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PpayYD58RF3/0Z1zCcFIlebld5x/MkYyF8mv/5/255sTjmN8dcWIIeAnnHn5vnhoqeraQu9Po3W0LyDsIg1vlSttCLKGYRVUkBlE1QXYZhjGxFq0TwBUlk5DNhOMQP8xzL6gowzx/iKuOFy52p7epk043uIIYUW5dIO1mDreNg2W59z/mI7s0V0kKz0++N9LGlWElxwrWaFFCNje9KhPArQ+GoUL4jytiq1TWDS6taVfam7KdA+X2/VlYA7GZMdFnLQ1n8GbqNj+5eKDY6X/k5ac1lxzMFN3k7+MZHvLBivkyr8K4pX4nNskm40cfa7y57PfKPSXQb4JWNDhIfaGl3rhiwyVsjN8/gnm4ndxTWwKNnO6WZ4SA6uhGXX0m0tj/nFPqZIV8RdtmbVzK3EddoDdxx7YyDLZzuTVW5MPEc2Fs9fy4bps2ghjPksO3O0rO7q930GVc0byv0jkIxY2GX0MJJoYfjZcbQo3fLgrPN/VvInc0HYY61VtJxBXD1K5dEQ9V2EEaF3fIq2TMxStrsAj+LcR3EVA6tJobwWwD2JiRYJ+GHbbWQJiNwC3WS5VqjHVN8VA6WEyl884Z1DbUghx9pEKgLa8D0+TcSA33MZIxfEVjqeouIGFMk8RAZQQVz65sB2nUJt3M9RJf9pkdw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(376002)(136003)(366004)(396003)(346002)(451199021)(478600001)(110136005)(316002)(2616005)(36756003)(83380400001)(38100700002)(186003)(86362001)(31696002)(53546011)(6506007)(26005)(6486002)(5660300002)(8936002)(6512007)(31686004)(2906002)(4326008)(66946007)(66556008)(66476007)(8676002)(66899021)(41300700001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UUY5WmtkdStTeXR2U0dBWXZGOU45c2FESTRVcTZ4a1lENzdiRmFHNEp4R2tV?= =?utf-8?B?WWtPZTlXU3FXd0FUU3hXYTlwdm1yb1hUUXNtRzFJeGFWb09jNVFhcFgyN3Zu?= =?utf-8?B?OGRiSlNOVnBYcVBYV24zTjh5a1MvakJZdU5jbW5lMXY3NDVvOHY1MmtDZDNp?= =?utf-8?B?eWV0T3N6SGtPZUU3Mms0VnZ1QXlVWWEvS0prYXZ3dnQ0SGtsTWtkdVBoYkhV?= =?utf-8?B?Z1RDVkY3YjloWmg3K2lNZlBaczNRbmxsY3ZxOFowZU55Sy9SRkVJRDNlcVlE?= =?utf-8?B?akd4UTNWVE4zVUEvYXVxeWFETHBUZm9EaE5WUEFZNDJ0cW12TnVLZFZlcEFB?= =?utf-8?B?elM3UXltMmtBb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S-Exchange-CrossTenant-Network-Message-Id: 393bb9b9-84a2-46e7-8c75-08db312ea571 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2023 14:54:21.8707 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NUcJC2d+6f1wX5vu2Al35zJ+4tYsmGuz+F1f0aM9raG5CHsTMkq1GGzaCSqzyi1tgkx7xdtO/QghMD3wscXJww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9189 X-Spam-Status: No, score=-3028.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 20.03.2023 18:03, H.J. Lu via Binutils wrote: > Check unbalanced braces in memory reference to avoid assembler crash > caused by > > commit e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506 > Author: Jan Beulich > Date: Wed Oct 5 09:16:24 2022 +0200 > > x86/gas: support quoted address scale factor in AT&T syntax This claim is wrong, and the "fix" is wrong as well. The assertion is correct, and it triggering correctly points out a problem, but elsewhere (which makes me suspect you didn't take the time to understand what it actually is that is going wrong): The parse_register() call from i386_att_operand() ends up zapping the trailing three quotes from the example operand in the testcase ('")"""'). Which renders invalid the checking done earlier in parse_operands(). This behavior of parse_register() in turn is because of bogus behavior in get_symbol_name(): It consumes all pairs of quotes (i.e. the trailing three ones) with the apparent goal of concatenating adjacent strings. But in this case the function stores two nul characters at different positions, yet the caller cannot possibly restore more than one of the original characters. Hence the previously properly balanced quoted string becomes unbalanced. _This_ is what causes the assertion to trigger. Please revert. I'll see to get to fixing this where it needs fixing, unless someone else gets to it earlier. For now it isn't really clear to me what the best approach is going to be: Having all callers of get_symbol_name() deal with the situation isn't nice. But dealing with this in get_symbol_name() isn't nice either, as we'd need to replace the "excess" characters by e.g. blanks. Yet code elsewhere often enough assumes that adjacent blanks were collapsed by the scrubber. IOW even then many/most(/all?) callers may need adjustment. Possibly get_symbol_name() simply isn't intended for cases where the original buffer contents is to remain usable for further processing. If so, - this property should be called out in the comment ahead of the function, - we'd simply need to make a copy before calling the function in parse_register() (or in callers where retaining the original buffer contents matters). Nick, Alan - do you have any thoughts here? Jan