From: John Baldwin <jhb@FreeBSD.org>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Mask x86 segment registers in Windows gdbserver
Date: Mon, 22 Jan 2024 08:57:06 -0800 [thread overview]
Message-ID: <94184f20-5e5e-44a3-839f-4959dbbed61a@FreeBSD.org> (raw)
In-Reply-To: <87edeemq5f.fsf@tromey.com>
On 1/18/24 10:51 AM, Tom Tromey wrote:
> John> LGTM. Treating the x86 seg regs as 32-bits has required workarounds in
> John> various places, but not easily fixable unfortunately.
>
> Tom> Well, to my surprise, this patch caused regressions in our internal
> Tom> tester.
>
> Tom> It works again if I explicitly exclude the 'ss' register, like:
>
> Tom> if (!windows_process.wow64_process)
> Tom> return r >= AMD64_CS_REGNUM && r <= AMD64_GS_REGNUM && r != 19;
>
> Tom> Now, this seems "ok" to do in some sense. However, I can't explain why
> Tom> native gdb works fine, as it has the same logic in
> Tom> amd64_windows_segment_register_p.
>
> Tom> I'd welcome any thoughts you (or anybody) might have.
>
> I finally figured it out. The Windows CONTEXT structure uses 16-bit
> types for these registers' fields. So, gdbserver is actually
> reading/writing past the end of the field here.
>
> My patch correctly truncates the value, but the truncated value is
> preserved and written back -- overwriting other fields in the thread
> context.
>
> I have a new patch that fixes this problem and some other related things
> as well. I'll send it once it's been through a bit more testing.
Ouch, good find.
--
John Baldwin
prev parent reply other threads:[~2024-01-22 16:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 14:48 Tom Tromey
2023-12-20 22:03 ` John Baldwin
2023-12-21 20:29 ` Tom Tromey
2024-01-18 18:51 ` Tom Tromey
2024-01-22 16:57 ` John Baldwin [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=94184f20-5e5e-44a3-839f-4959dbbed61a@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).