public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* RE: Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
@ 2005-05-13 15:37 Cuthbertson, Reva D.
  2005-05-13 15:40 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Cuthbertson, Reva D. @ 2005-05-13 15:37 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Yes, I ran into the problem.  I tried changing the declaration of the
"size" field in dwarf2_loclist_baton and dwarf2_locexpr_baton in
dwarf2loc.h to be an unsigned integer instead and that seemed to fix the
problem I encountered.  Do you think this a reasonable solution?

Thanks!

Reva Cuthbertson
reva.cuthbertson@hp.com

-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@false.org] 
Sent: Friday, May 13, 2005 8:26 AM
To: Cuthbertson, Reva D.
Cc: gdb@sources.redhat.com
Subject: Re: Is it possible to overflow baton->size in
dwarf_mark_symbols_computed() in dwarf2read.c?

On Fri, May 13, 2005 at 08:18:47AM -0700, Cuthbertson, Reva D. wrote:
> Hello,
> 
> I had a question regarding the following assignment in
> dwarf2_mark_symbol_computed() in dwarf2read.c:
> 
> baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr);
> 
> The field "loc_size" in dwarf2_per_objfile is declared to be an
unsigned
> integer and attr.u.unsnd (expansion of DW_UNSND (attr)) is declared to
> be an unsigned long but the "size" field in dwarf2_loclist_baton and
> dwarf2_locexpr_baton defined in dwarf2loc.h is defined to be an
unsigned
> short.  Is it possible to overflow baton->size with the above
> calculation?

Yes, this seems possible.  Size is used for overflow checking only at
this point; saturating at USHORT_MAX seems reasonable.

Have you encountered this problem?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
  2005-05-13 15:37 Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c? Cuthbertson, Reva D.
@ 2005-05-13 15:40 ` Daniel Jacobowitz
  2005-05-16 20:28   ` Jim Blandy
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2005-05-13 15:40 UTC (permalink / raw)
  To: Cuthbertson, Reva D.; +Cc: gdb

On Fri, May 13, 2005 at 08:37:41AM -0700, Cuthbertson, Reva D. wrote:
> Yes, I ran into the problem.  I tried changing the declaration of the
> "size" field in dwarf2_loclist_baton and dwarf2_locexpr_baton in
> dwarf2loc.h to be an unsigned integer instead and that seemed to fix the
> problem I encountered.  Do you think this a reasonable solution?

No.  It should saturate instead; it only needs to be longer than any
supported location list/expression, and 64k is entirely reasonable for
that.  Int would waste a lot of memory.

Could you try that?  Something like if (expression < 65536) ->size =
expression; else size = 65535;


-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
  2005-05-13 15:40 ` Daniel Jacobowitz
@ 2005-05-16 20:28   ` Jim Blandy
  0 siblings, 0 replies; 6+ messages in thread
From: Jim Blandy @ 2005-05-16 20:28 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Cuthbertson, Reva D., gdb


Daniel Jacobowitz <drow@false.org> writes:
> No.  It should saturate instead; it only needs to be longer than any
> supported location list/expression, and 64k is entirely reasonable for
> that.  Int would waste a lot of memory.

Both those structures are twelve bytes long anyway.  Their 'size'
fields are followed by two bytes of padding on IA-32.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
@ 2005-05-13 16:00 Cuthbertson, Reva D.
  0 siblings, 0 replies; 6+ messages in thread
From: Cuthbertson, Reva D. @ 2005-05-13 16:00 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Your suggestion worked.

Thanks so much!

Reva Cuthbertson
reva.cuthbertson@hp.com

-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@false.org] 
Sent: Friday, May 13, 2005 8:40 AM
To: Cuthbertson, Reva D.
Cc: gdb@sources.redhat.com
Subject: Re: Is it possible to overflow baton->size in
dwarf_mark_symbols_computed() in dwarf2read.c?

On Fri, May 13, 2005 at 08:37:41AM -0700, Cuthbertson, Reva D. wrote:
> Yes, I ran into the problem.  I tried changing the declaration of the
> "size" field in dwarf2_loclist_baton and dwarf2_locexpr_baton in
> dwarf2loc.h to be an unsigned integer instead and that seemed to fix
the
> problem I encountered.  Do you think this a reasonable solution?

No.  It should saturate instead; it only needs to be longer than any
supported location list/expression, and 64k is entirely reasonable for
that.  Int would waste a lot of memory.

Could you try that?  Something like if (expression < 65536) ->size =
expression; else size = 65535;


-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
  2005-05-13 15:19 Cuthbertson, Reva D.
@ 2005-05-13 15:25 ` Daniel Jacobowitz
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2005-05-13 15:25 UTC (permalink / raw)
  To: Cuthbertson, Reva D.; +Cc: gdb

On Fri, May 13, 2005 at 08:18:47AM -0700, Cuthbertson, Reva D. wrote:
> Hello,
> 
> I had a question regarding the following assignment in
> dwarf2_mark_symbol_computed() in dwarf2read.c:
> 
> baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr);
> 
> The field "loc_size" in dwarf2_per_objfile is declared to be an unsigned
> integer and attr.u.unsnd (expansion of DW_UNSND (attr)) is declared to
> be an unsigned long but the "size" field in dwarf2_loclist_baton and
> dwarf2_locexpr_baton defined in dwarf2loc.h is defined to be an unsigned
> short.  Is it possible to overflow baton->size with the above
> calculation?

Yes, this seems possible.  Size is used for overflow checking only at
this point; saturating at USHORT_MAX seems reasonable.

Have you encountered this problem?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c?
@ 2005-05-13 15:19 Cuthbertson, Reva D.
  2005-05-13 15:25 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Cuthbertson, Reva D. @ 2005-05-13 15:19 UTC (permalink / raw)
  To: gdb

Hello,

I had a question regarding the following assignment in
dwarf2_mark_symbol_computed() in dwarf2read.c:

baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr);

The field "loc_size" in dwarf2_per_objfile is declared to be an unsigned
integer and attr.u.unsnd (expansion of DW_UNSND (attr)) is declared to
be an unsigned long but the "size" field in dwarf2_loclist_baton and
dwarf2_locexpr_baton defined in dwarf2loc.h is defined to be an unsigned
short.  Is it possible to overflow baton->size with the above
calculation?

If it is possible, then in find_location_expression() in dwarf2loc.c,
there may be a problem processing a location list entry as baton->size
is used to 
determine the end of that location list entry.  I think this overflow
could
happen for a program with a large .debug_loc section.

Do you believe that this is a problem?

Thanks!

Reva Cuthbertson
reva.cuthbertson@hp.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-05-16 20:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-13 15:37 Is it possible to overflow baton->size in dwarf_mark_symbols_computed() in dwarf2read.c? Cuthbertson, Reva D.
2005-05-13 15:40 ` Daniel Jacobowitz
2005-05-16 20:28   ` Jim Blandy
  -- strict thread matches above, loose matches on Subject: below --
2005-05-13 16:00 Cuthbertson, Reva D.
2005-05-13 15:19 Cuthbertson, Reva D.
2005-05-13 15:25 ` Daniel Jacobowitz

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).