From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2050.outbound.protection.outlook.com [40.107.14.50]) by sourceware.org (Postfix) with ESMTPS id 074353858D20 for ; Fri, 31 Mar 2023 05:50:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 074353858D20 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=hPG/oc2BbUWs4RAWzHJWDxwU1sAGFYRtvhGDxoZa9fttTiwmcoFd77rtns1SHrIpoZJKqUHTFWmGcSKl6bZJOKvXgqoE1Wwk9l9uh1IdaIKial+mDqPjp+BSSs7lVmAByIBRxod1BoObIhJzC5daZz/FPQyouwZ8jQKKodD9QRUqNwrwz//Fxb/xMbO8xtRLtSHH0y+QAHGDA6fS0qixzQuBNZ3jMAsZj98mfoHLuY++yt/zNbBo1zc4ODeS6y1/mY9OwVLXrRtBnNEY/qvEbE/ubZD5Rsi2/IRquzxfwz0+R5ZwffMbYLpkP0TqBQilDcbkP6pqYUKXOuQC/Ukzbg== 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=1ASOhmgaC3nHY/rEtW5C6VdtIZU3KlV/kjom+T72U6Q=; b=m41WSzxPIwh2ZbDKOw1NXABgw95F+hXETVme/9cXoQ8DSBHgbD7SyVv9G2Q7GtPK8yu7lrxdbVGwlQAHpTKsqmFbaSvu0lVmtl2qw02twwP68LX3ZynXl//7schZdb84vGQjg2kOdHEQx5SCQya8zYIbE0bdbOSma9YvEgBhcoRUnc3zJN8E569FownucKVzo6388BJez9bYRangZTLmAD/aLn7akVooTzJnpmVKIvC2DVK4vUQZoFZfFpN/oDbps1vfhqXY3iKJX0i1ZpXN/J8/1yfWh5/X6riphy3rYTJWaJ3ieWeYVYH5QFIjJ+geNStoAtKdggVr4B35ZtYjmg== 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=1ASOhmgaC3nHY/rEtW5C6VdtIZU3KlV/kjom+T72U6Q=; b=uRqycwNPZWxNTqtzyVbCINdgFr14E6ihf2Ef+YgJFaxSx+DU5VX7y831MmKBeBLeXRF6YlAQ0900he98t31jmktMJw325aVEUDudj7jQ3ZexZs9a8xI4hwLndQnOy1lSQTml0JpSiBYkSCuAZRt2FD2bklaUtcI1dglQfDMD/yvBiQmBYDH6vNUPRnj0zZemH9B1NXxEqsWDl5UCoIlBZu03XIPFF5A+ts0wv3qSPtgI/OWfGTO1F+U+uQomGB7JXUIkBqHvv4H/AlcWS0d6JVV7PEwoz+WEep5NUgA+V7nRQfPZ1jbsd9472G/RWVXPhh2E1HK1IJRlxfcApzyg4Q== 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 AM9PR04MB8289.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.23; Fri, 31 Mar 2023 05:50:15 +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; Fri, 31 Mar 2023 05:50:15 +0000 Message-ID: <83a4bd07-fa95-fd39-0b0b-64a895a54211@suse.com> Date: Fri, 31 Mar 2023 07:50:13 +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" Cc: Nick Clifton , Alan Modra , binutils@sourceware.org References: <20230320170313.354203-1-hjl.tools@gmail.com> From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR2P281CA0127.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AM9PR04MB8289:EE_ X-MS-Office365-Filtering-Correlation-Id: 125b5d15-4b5f-4973-fbd3-08db31abcce7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CEx0occJcJcd10OQvf8P5Y1lmH3sCKsTJhmPsr6UHN7vNDhUZSc2vdKqS1Mt51GEH+T6kuY20ca1LMci5IRZzBjh/u67Fu0Mrf4OWYCiL3ha68gkj42rX4dor4hzTc5uHrg3lTjx8eeXEuJdII/Hl4Wni/zfvXLD4E8pX3O9pZSdnovqXEJr4DsmU0N30oP8faS6UWNY7N72qASEnz32qdCowkRQdwgwyXpDWiIj1N3fyNSfidAZeC/DTnahxA3qxVeRE+b5K9fd6dJ9Xjh6FAenM6lfO14ceoDDH7ESyXWvis+HMQ5c3O3gTaw8C2edyaUy6aHpW5qBf4gk8IZKaDcvtXaHzGxaunCGSkvbPzbx6zMxDHI4KN+f+YAi1Q23JvvWAbCKp3TCB8SoT6AH/1x/VnVPqWS9oWYdOP3N2NvJxX+N+fhbBzaJcq02vxVv0SrxlhMgp+PqCvuGMsfIC0YnPVss+zVK6Vj7ouwNcxIShn8pvE3t4qnDA7iLbY4ac29e/131krOiXe3SOeNmEllmzTV+hT50AzmiNQrx87muYVpPIDWyCL3Gy1gFKFQ8jf3UC4c+w/O+GvkWnQe50C7uMFkcw/vmaohQtJux7tUht9FlDPzC8JETYBgeloxwdEDn1QBuurHZ1PNDaNTAFg== 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)(136003)(376002)(366004)(39860400002)(346002)(396003)(451199021)(5660300002)(38100700002)(41300700001)(66899021)(8676002)(8936002)(31696002)(86362001)(2906002)(6512007)(26005)(53546011)(6506007)(6486002)(83380400001)(2616005)(36756003)(31686004)(4326008)(186003)(316002)(6916009)(66946007)(66556008)(66476007)(478600001)(54906003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OVVnWDErTUMwVURMMWRFcThSTVczUEc4SXlEV3g2MnZLdklOdEZkMHNSRnRE?= =?utf-8?B?SXQweG5UWktBYVl5aXNoVU9SY0dTNVhGbVlMR0Y1TXhkVGpnUCtUODhGTlph?= =?utf-8?B?S0RzREtQeDlIYm5nVkdPSHZBRjNHOEMxNXRuVVdxTHh0S1h5cVNCL3RYTzFV?= =?utf-8?B?T0FCRGUwREtHOENCWHVmWFhFY1JPTmVTSXBxakNydmlyVEw3aGNaMVZVL1NV?= =?utf-8?B?NUFvb0M0Y0dnRzY3MkU1NVJNaitPUkx5ZTNmZEZCdWVwbFVXUVIzYmQybHdU?= =?utf-8?B?WmpNWkJsMlBYQ2phMTUwenBRMU8xV0g0TzJPVTJaYWlkdVZveWNMam1VdURr?= =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OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 125b5d15-4b5f-4973-fbd3-08db31abcce7 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 05:50:15.3082 (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: uzOxVhudYh7nBKCOqeC+xgIgbcLAczPvuo4lwZ+wGEaM3cLS5TQHw4K1TrpaLaGFdr9ni7FkbnmBjIlqf56bKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8289 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_PASS,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 30.03.2023 18:49, H.J. Lu wrote: > On Thu, Mar 30, 2023 at 7:54 AM Jan Beulich wrote: >> >> 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). > > What is the end goal of this complexity? Assembler is changed > to accept more obscure syntaxes which aren't expected by the > original framework. I think assembler should be as simple as > possible without those obscure syntaxes Quoted symbol names are a general feature of gas; they should work everywhere. Or else that capability would want to removing again completely (which I'm far from suggesting we do). What you've done in your "fix" is paper over one corner aspect of a much wider problem. IOW even without the change you falsely blamed there would be problems from the underlying cause that I've identified (and which wants fixing there instead of curing symptoms all over the place). Jan