public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/26804] gdbserver crash at <init_cacheinfo+22> when program has canary and is 32 bit.
Date: Tue, 19 Jan 2021 07:12:08 +0000	[thread overview]
Message-ID: <bug-26804-4717-p19gMguctq@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-26804-4717@http.sourceware.org/bugzilla/>

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

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #6)
> I found the place in gdbserver where gs_base is overwritten. It's in
> x86_fill_gregset:
> ...
>   /* 32-bit inferior registers need to be zero-extended.                    
> 
>      Callers would read uninitialized memory otherwise.  */
>   memset (buf, 0x00, X86_64_USER_REGS * 8);                                 
> 
> ...
> 
> Commenting out the memset fixes the segmentation fault.

Hmm, but that causes regressions on Leap 15.2 (with 5.3.18 kernel).

This doesn't cause any regressions on Leap 15.2, and still fixes the problem on
Tumbleweed (with 5.10.5 kernel):
...
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 35dfdd7e0f3..d2abf3c2712 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -414,7 +414,11 @@ x86_fill_gregset (struct regcache *regcache, void *buf)

   /* 32-bit inferior registers need to be zero-extended.
      Callers would read uninitialized memory otherwise.  */
-  memset (buf, 0x00, X86_64_USER_REGS * 8);
+  {
+    unsigned long long *ptr = (unsigned long long *)buf;
+    for (i = 0; i < X86_64_USER_REGS; ++i)
+      ptr[i] = ptr [i] & 0xffffffffULL;
+  }
 #endif

   for (i = 0; i < I386_NUM_REGS; i++)
...

Effectively, the patch fixes the code to match the comment.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-01-19  7:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  3:25 [Bug gdb/26804] New: " 3480283348 at qq dot com
2020-10-29 13:44 ` [Bug gdb/26804] " simark at simark dot ca
2020-11-06  7:11 ` 3480283348 at qq dot com
2020-11-12  6:59 ` 3480283348 at qq dot com
2020-12-02 16:46 ` vries at gcc dot gnu.org
2021-01-11 18:17 ` bp at alien8 dot de
2021-01-12 17:06 ` markus.t.metzger at intel dot com
2021-01-18 16:40 ` vries at gcc dot gnu.org
2021-01-19  7:12 ` vries at gcc dot gnu.org [this message]
2021-01-19  7:13 ` [Bug server/26804] " vries at gcc dot gnu.org
2021-01-19  7:37 ` markus.t.metzger at intel dot com
2021-01-19 12:40 ` markus.t.metzger at intel dot com
2021-01-19 12:50 ` vries at gcc dot gnu.org
2021-01-20 13:00 ` vries at gcc dot gnu.org
2021-01-20 15:35 ` vries at gcc dot gnu.org
2021-01-20 15:36 ` vries at gcc dot gnu.org

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=bug-26804-4717-p19gMguctq@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).