[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-11-10 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

--- Comment #6 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f7502dfe3f99d09fba2fc49f806ccc6b0a18c06d

commit f7502dfe3f99d09fba2fc49f806ccc6b0a18c06d
Author: Alan Modra 
Date:   Fri Nov 11 13:43:42 2022 +1030

PR28834, PR26946 sanity checking section size

This patch provides a new function to sanity check section sizes.
It's mostly extracted from what we had in bfd_get_full_section_contents
but also handles compressed debug sections.
Improvements are:
- section file offset is taken into account,
- added checks that a compressed section can be read from file.

The function is then used when handling multiple .debug_* sections
that need to be read into a single buffer, to sanity check sizes
before allocating the buffer.

PR 26946, PR 28834
* Makefile.am (LIBBFD_H_FILES): Add section.c.
* compress.c (bfd_get_full_section_contents): Move section size
sanity checks..
* section.c (_bfd_section_size_insane): ..to here.  New function.
* dwarf2.c (read_section): Use _bfd_section_size_insane.
(_bfd_dwarf2_slurp_debug_info): Likewise.
* Makefile.in: Regenerate.
* libbfd.h: Regenerate.

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-02 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

--- Comment #4 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_38-branch branch has been updated by Nick Clifton
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=203c99c9b9a9c58cce472a1bd4315e3f79b440b7

commit 203c99c9b9a9c58cce472a1bd4315e3f79b440b7
Author: Nick Clifton 
Date:   Wed Feb 2 17:07:31 2022 +

Stop the BFD library from complaining that dwarf debug string sections are
too big.

PR 28834
* dwarf2.c (read_section): Change the heuristic that checks for
overlarge dwarf debug info sections.

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-02 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

Nick Clifton  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #5 from Nick Clifton  ---
Hi Joel,

  Well the 10x fix is easy to implement, and should be safe, so I have
  gone ahead and applied it.

Cheers
  Nick

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-02 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

--- Comment #3 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Nick Clifton :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41ba8b76ccc5bb01507beb3b49df039264bcf34a

commit 41ba8b76ccc5bb01507beb3b49df039264bcf34a
Author: Nick Clifton 
Date:   Wed Feb 2 17:06:22 2022 +

Stop the BFD library complaining about compressed dwarf debug string
sections being too big.

PR 28834
* dwarf2.c (read_section): Change the heuristic that checks for
overlarge dwarf debug info sections.

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-01 Thread joelhock at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

--- Comment #2 from Joel Hock  ---
I can't upload the binary, but the uncompressed size (b6e3fb5 in the output
below) is correct.  This output is from a different, but similar, binary than
what was generating the original error message I posted:

$ readelf -t mybinary
  [Nr] Name
   Type  Address  OffsetLink
   Size  EntSize  Info  Align
   Flags
...
  [38] .debug_str
   PROGBITS   07259234  0
   01a18720 0001  0 1
   [0830]: MERGE, STRINGS, COMPRESSED
   ZLIB, 0b6e3fb5, 1

A 10x heuristic would have worked in this case, fwiw.

Joel

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-01 Thread guillaume at morinfr dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

Guillaume Morin  changed:

   What|Removed |Added

 CC||guillaume at morinfr dot org

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-01 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

Nick Clifton  changed:

   What|Removed |Added

 CC||nickc at redhat dot com

--- Comment #1 from Nick Clifton  ---
Hi Joel,

  Hmmm, compressed strings would indeed cause this of problem.

  Could you upload the test binary that you are using ?

  Compressed sections include a field giving their uncompressed size, so it may
be possible to make use of that.  But a malicious actor could create a corrupt
.zdebug_str section with a ridiculously large "real section size" field and
then try to trick the application into allocating a huge amount of memory

  Maybe a simpler solution would be change the heuristic that produces the
error message so that it only complains if the .debug_str section is more than
10x the size of the file ?  Just how efficient can (zlib based) text
compression get these days ?

Cheers
  Nick

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


[Bug binutils/28834] incorrect detection of "DWARF error: section .debug_str is larger than its filesize"

2022-02-01 Thread hector.oron at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28834

HectorOron  changed:

   What|Removed |Added

 CC||hector.oron at gmail dot com

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