From: Roland McGrath <mcgrathr@google.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>,
gdb-patches@sourceware.org
Cc: Bradley Nelson <bradnelson@google.com>
Subject: [PATCH] Fix buffer underrun in i386-dis.c.
Date: Thu, 09 Jan 2014 18:26:00 -0000 [thread overview]
Message-ID: <CAB=4xhooGrDed7eSXbPOYZjx57-HOQKCQq9wwEphWAgL0=Q8Hg@mail.gmail.com> (raw)
When disassembling any instruction without a REX prefix, the print_insn
function touches all_prefixes[-1]. This is usually harmless in most
builds, because the word preceding all_prefixes will probably be the
last_seg_prefix variable and it was usually zero already. But in some
kinds of builds, all buffer underruns are caught and cause a crash.
AFAICT the obvious local workaround is in fact the proper fix. In the
similar cases nearby, there is a PREFIX_FOO bit in the "prefixes" bitmask
that guards use of last_foo_prefix. But there is no such bit for the REX
prefixes. We could test "rex != 0" instead, I suppose.
OK for trunk and binutils-2.24 branch and gdb-7.7 branch?
Thanks,
Roland
opcodes/
2014-01-09 Bradley Nelson <bradnelson@google.com>
Roland McGrath <mcgrathr@google.com>
* i386-dis.c (print_insn): Do not touch all_prefixes[-1] when
last_rex_prefix is -1.
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -12645,7 +12645,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
}
/* Check if the REX prefix is used. */
- if (rex_ignored == 0 && (rex ^ rex_used) == 0)
+ if (rex_ignored == 0 && (rex ^ rex_used) == 0 && last_rex_prefix >= 0)
all_prefixes[last_rex_prefix] = 0;
/* Check if the SEG prefix is used. */
next reply other threads:[~2014-01-09 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-09 18:26 Roland McGrath [this message]
2014-01-09 18:31 ` H.J. Lu
2014-01-09 19:03 ` Pedro Alves
2014-01-09 19:28 ` Roland McGrath
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='CAB=4xhooGrDed7eSXbPOYZjx57-HOQKCQq9wwEphWAgL0=Q8Hg@mail.gmail.com' \
--to=mcgrathr@google.com \
--cc=binutils@sourceware.org \
--cc=bradnelson@google.com \
--cc=gdb-patches@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).