From: Kevin Buettner <kevinb@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] should_validate_memtags: Do not dereference references
Date: Sat, 2 Aug 2025 15:50:52 -0700 [thread overview]
Message-ID: <20250802154829.0e2bf696@f41-zbm-amd> (raw)
In-Reply-To: <60afe2cd4b01bc7955fcf2b4e18727de0440801b.1754064717.git.keiths@redhat.com>
On Fri, 1 Aug 2025 09:39:43 -0700
Keith Seitz <keiths@redhat.com> 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 <kevinb@redhat.com>
next prev parent reply other threads:[~2025-08-02 22:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 16:39 Keith Seitz
2025-08-02 22:50 ` Kevin Buettner [this message]
2025-08-08 18:04 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250802154829.0e2bf696@f41-zbm-amd \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox