Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Stephan Rohr <stephan.rohr@intel.com>
Cc: gdb-patches@sourceware.org,  tom@tromey.com,  guinevere@redhat.com
Subject: Re: [PATCH v3 0/1] gdb: fix assert after register write failure
Date: Fri, 06 Nov 2026 12:06:15 -0700	[thread overview]
Message-ID: <8733tdwziw.fsf@tromey.com> (raw)
In-Reply-To: <20261104130344.44218-1-stephan.rohr@intel.com> (Stephan Rohr's message of "Wed, 4 Nov 2026 13:03:43 +0000")

>>>>> Stephan Rohr <stephan.rohr@intel.com> writes:

> I checked the "store_registers" implementations for other targets.  As
> far as I can tell from reading the code, the ravenscar target has the
> same use-after-free bug when the target beneath is a remote target,
> see ravenscar_thread_target::store_registers ():

>   temporarily_change_regcache_ptid changer (regcache, base);
>   beneath ()->store_registers (regcache, i);

Thanks for pointing this out.

I filed a bug for this:

    https://sourceware.org/bugzilla/show_bug.cgi?id=34973

> IIUC, on the store_registers path, the regcache can only be deleted if
> the remote target is unpushed, which is always followed by a
> TARGET_CLOSE_ERROR.  If we want to be on the safe side, we could add a
> lifetime token to the regcache:

>   std::shared_ptr<int> m_lifetime = std::make_shared<int> (0);

> and take a weak reference to it in raw_write before storing:

Cool technique, thanks.

It does seem like overkill here.

OTOH the current code seems fragile, like maybe more UAFs are waiting to
be introduced in the future.

I didn't dig into the lifetime issues here to try to figure out a robust
solution though.

Tom

      parent reply	other threads:[~2026-11-06 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 13:03 Stephan Rohr
2026-11-04 13:03 ` [PATCH v3 1/1] " Stephan Rohr
2026-11-06 19:01   ` Tom Tromey
2026-11-09 19:03   ` Tom Tromey
2026-11-06 19:06 ` Tom Tromey [this message]

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=8733tdwziw.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.com \
    --cc=stephan.rohr@intel.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