From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: jan.kratochvil@redhat.com
Subject: [PATCH] [PR corefiles/17808] i386: Fix internal error when prstatus in core file is too big
Date: Thu, 08 Jan 2015 16:16:00 -0000 [thread overview]
Message-ID: <874ms18cyz.fsf@br87z6lw.de.ibm.com> (raw)
As reported in PR 17808, a test case with a forged (invalid) core file
can crash GDB with an assertion failure. In that particular case the
prstatus of an i386 core file looks like that from an AMD64 core file,
i.e., it is larger than GDB would expect.
The patch replaces the assertion by a warning and skips the invalid
core file register section. In this way it is guaranteed that no
bogus register values are read from the badly formatted section.
Note that this behavior deviates from the default policy: In general, if
some future kernel adds new registers to a register set, then a GDB
unaware of this extension would read the known subset and just ignore
the unknown bytes.
gdb/ChangeLog:
PR corefiles/17808
* i386-tdep.c (i386_supply_gregset): Instead of yielding an
internal error on unexpected input buffer size, ignore the data
and emit a warning.
---
gdb/i386-tdep.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 7d174c4..d02aaf2 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3727,7 +3727,12 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
const gdb_byte *regs = gregs;
int i;
- gdb_assert (len == tdep->sizeof_gregset);
+ if (len != tdep->sizeof_gregset)
+ {
+ /* Buffer has unknown size: assume wrong format. */
+ warning (_("Bad size of general register section"));
+ return;
+ }
for (i = 0; i < tdep->gregset_num_regs; i++)
{
--
1.7.9.5
next reply other threads:[~2015-01-08 16:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 16:16 Andreas Arnez [this message]
2015-01-08 16:43 ` [testsuite patch] for: " Jan Kratochvil
2015-01-09 9:47 ` Andreas Arnez
2015-01-09 16:45 ` Pedro Alves
2015-01-09 16:59 ` Mark Kettenis
2015-01-09 17:19 ` Pedro Alves
2015-01-09 19:35 ` Mark Kettenis
2015-01-09 20:11 ` Pedro Alves
2015-01-09 20:30 ` Mark Kettenis
2015-01-12 14:30 ` Andreas Arnez
2015-01-09 19:27 ` Andreas Arnez
2015-02-05 7:38 ` ping: " Jan Kratochvil
2015-02-05 9:47 ` Pedro Alves
2015-02-14 15:12 ` Jan Kratochvil
2015-02-17 12:56 ` Pedro Alves
2015-02-17 16:56 ` Jan Kratochvil
2015-02-21 14:28 ` [commit] " Jan Kratochvil
2015-07-14 8:52 ` ping: " Yao Qi
2015-07-14 18:07 ` Jan Kratochvil
2015-07-15 16:14 ` Yao Qi
2015-07-15 16:58 ` Jan Kratochvil
2015-07-16 14:15 ` Yao Qi
2015-07-16 14:37 ` Jan Kratochvil
2015-07-16 15:35 ` Yao Qi
2015-07-16 16:10 ` [commit] " Jan Kratochvil
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=874ms18cyz.fsf@br87z6lw.de.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@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