From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id F5qjH3SWjmg3pgIAWB0awg (envelope-from ) for ; Sat, 02 Aug 2025 18:51:32 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cjtkAA2k; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6D3481E102; Sat, 2 Aug 2025 18:51:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 886101E091 for ; Sat, 2 Aug 2025 18:51:31 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 129F63858D20 for ; Sat, 2 Aug 2025 22:51:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 129F63858D20 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cjtkAA2k Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id B4FA83858D1E for ; Sat, 2 Aug 2025 22:51:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4FA83858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4FA83858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754175061; cv=none; b=j4iomw9ZDPxLeZ7qM+7pKU9dU6GCg0+LCU7NuuJoNVHeeUjf0uWPvHvsC0U/AJ+b1LaR+GeuNF1BnYj7Jz67V+3fdfm9vv6ow2kqfpn9yXdn/cZpA7WQfUkdYiwOsgMd4BkpFOqPAjEzppLAKJZ+CFQF8uQeYD/8A07AjUl4m9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754175061; c=relaxed/simple; bh=iNA9ZfSGZKMcqAB1CVnLRfkcKEoyJGR0FLOS1lRlO6M=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=OEhPev+0mFaAagVvWrFwfIBUchugxqZn3k+dqVrafMdW/7QsRKG851muFxmAjXEFPEcZFBZSR6SQmFu+n7OxwVAeOQWHL/SE/p63ZePtOzFjRVMaMmPmgrY1WHyinAtX85UDx9Yt2bJrGHZ0lD8nNxs+Ow5yQk2AxkqerGq5uLI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4FA83858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754175060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ilaKQOqW9I/MPImRZUGsduZa1E1Se4A1QIBDfb+0KmY=; b=cjtkAA2kqVc3fbjqGqDI6+mKYI8U5Vj4suMIVvCobjADNNmZ1yiM9F1JK/mgh6Usdq0H42 PxmBi6qb5nMo/zWZdMs0mTQbkqRhflXNsRcQT2KdeNnlxRjuOcWL6UvGTH9VVlpK2dNSlN DDtm6x9n0rQILJYTZdI6r3YTkRqU/P0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-_svB0oUKNlGE6AdAnLOKEA-1; Sat, 02 Aug 2025 18:50:59 -0400 X-MC-Unique: _svB0oUKNlGE6AdAnLOKEA-1 X-Mimecast-MFC-AGG-ID: _svB0oUKNlGE6AdAnLOKEA_1754175058 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 370321956089 for ; Sat, 2 Aug 2025 22:50:58 +0000 (UTC) Received: from f41-zbm-amd (unknown [10.22.88.20]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 53B5C1800B6A; Sat, 2 Aug 2025 22:50:57 +0000 (UTC) Date: Sat, 2 Aug 2025 15:50:52 -0700 From: Kevin Buettner To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] should_validate_memtags: Do not dereference references Message-ID: <20250802154829.0e2bf696@f41-zbm-amd> In-Reply-To: <60afe2cd4b01bc7955fcf2b4e18727de0440801b.1754064717.git.keiths@redhat.com> References: <60afe2cd4b01bc7955fcf2b4e18727de0440801b.1754064717.git.keiths@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9dj5ZVfO4k253nyX1Tc0THxfaBfKFhNIW-Gl9cgywjQ_1754175058 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Fri, 1 Aug 2025 09:39:43 -0700 Keith Seitz wrote: > should_validate_memtags uses value_as_address to evalute > whether an address for a value is tagged. The comments for > that function simply say, "Extract a value as a C pointer." > > While that sounds innoncuous, that function calls coerce_array, > which will dereference any references. This is not what is > desired here. > > This can be demonstrated on an MTE-enabled host, such as aarch64- > based Ampere (example taken from tests introduced in this patch): > > (gdb) p b.get_foo () > Could not validate memory tag: Value can't be converted to integer. > $2 = (const foo &) @0xffffffffed88: {m_a = 42} > > While the command completes, gdb didn't actually attempt to > evaluate any memory tags. > > Fix this by using unpack_pointer instead. > > Tested on x86_64 Fedora 40 and aarch64 RHEL 9.6. > --- > gdb/printcmd.c | 4 +- > gdb/testsuite/gdb.cp/method-ref-return.cc | 42 +++++++++++++ > gdb/testsuite/gdb.cp/method-ref-return.exp | 70 ++++++++++++++++++++++ > gdb/value.c | 0 > 4 files changed, 115 insertions(+), 1 deletion(-) > create mode 100644 gdb/testsuite/gdb.cp/method-ref-return.cc > create mode 100644 gdb/testsuite/gdb.cp/method-ref-return.exp > mode change 100644 => 100755 gdb/value.c Aside from the mode change of gdb/value.c, this LGTM. Approved, with that change undone... Approved-by: Kevin Buettner