From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: fix bug in pieced value with offset
Date: Fri, 14 May 2010 22:35:00 -0000 [thread overview]
Message-ID: <20100514220057.GA31601@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <m3y6fmp6mo.fsf@fleche.redhat.com>
On Fri, 14 May 2010 22:31:43 +0200, Tom Tromey wrote:
> What do you think of this revision?
Except one severe problem I find it OK now myself.
> case DWARF_VALUE_STACK:
> {
> struct gdbarch *gdbarch = get_type_arch (value_type (v));
> - size_t n = p->size;
> - if (n > c->addr_size)
> - n = c->addr_size;
> - store_unsigned_integer (contents + offset, n,
> - gdbarch_byte_order (gdbarch),
> - p->v.expr.value);
> + size_t n = this_size;
> + if (n > c->addr_size - source_offset)
> + n = c->addr_size - source_offset;
As the strict sanity checks are not included this expression may be an
exploitable memory corruption by overflown N in the case of: DW_OP_piece size
larger than CU address size and value_offset (still in the scope of this
DW_OP_piece size) also larger than CU address size. Suggesting something
like:
# size_t n = this_size;
# if (n > c->addr_size - source_offset)
# n = c->addr_size >= source_offset ? c->addr_size - source_offset : 0;
> case DWARF_VALUE_LITERAL:
> {
> - size_t n = p->size;
> - if (n > p->v.literal.length)
> - n = p->v.literal.length;
> - memcpy (contents + offset, p->v.literal.data, n);
> + if (this_size > p->v.literal.length - source_offset)
> + this_size = p->v.literal.length - source_offset;
again some:
# if (this_size > p->v.literal.length - source_offset)
# this_size = p->v.literal.length >= source_offset
# ? p->v.literal.length - source_offset : 0;
(DWARF_VALUE_STACK now does not modify THIS_SIZE while DWARF_VALUE_LITERAL
modifies it - thus corrupting OFFSET - but both only in the cases of invalid
DWARF I was suggesting to error() anyway so it probably does not matter.)
> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
> + return -1
> +}
> +
> +clean_restart ${testfile}.x
pitpick: Therefore it could use prepare_for_testing now.
Thanks,
Jan
next prev parent reply other threads:[~2010-05-14 22:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-13 17:09 Tom Tromey
2010-05-13 20:54 ` Tom Tromey
2010-05-14 12:20 ` Jan Kratochvil
2010-05-14 17:54 ` Tom Tromey
2010-05-14 20:14 ` Jan Kratochvil
2010-05-14 20:02 ` Tom Tromey
2010-05-14 20:19 ` Jan Kratochvil
2010-05-14 21:27 ` Tom Tromey
2010-05-14 22:35 ` Jan Kratochvil [this message]
2010-05-21 19:41 ` Tom Tromey
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=20100514220057.GA31601@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@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