public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30667] New: gdb global buffer overflow in process_coff_symbol
@ 2023-07-23 16:16 mengda2020 at iscas dot ac.cn
  0 siblings, 0 replies; only message in thread
From: mengda2020 at iscas dot ac.cn @ 2023-07-23 16:16 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30667

            Bug ID: 30667
           Summary: gdb global buffer overflow in process_coff_symbol
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: mengda2020 at iscas dot ac.cn
  Target Milestone: ---

Created attachment 14999
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14999&action=edit
PoC file

Hello, GDB developers!
I found a global buffer overflow bug in process_coff_symbol in
gdb/coffread.c:1571.

Please confirm.
Thanks!



Test Environment
Ubuntu 20.04, 64 bit gdb (version: v13.0.50.20220805-git)

How to trigger
Compile the program with AddressSanitizer
Run command $ ./gdb --batch-silent $PoC 
Details
ASAN report
$./gdb --batch-silent $PoC
```
=================================================================
==2453180==ERROR: AddressSanitizer: global-buffer-overflow on address
0x000002e3ed15 at pc 0x000000447f76 bp 0x7ffc55469f40 sp 0x7ffc55469700
READ of size 1 at 0x000002e3ed15 thread T0
    #0 0x447f75 in strlen
(/home/root/Binutils/binutils_aflpp/gdb/batch-silent/gdb_3/gdb+0x447f75)
    #1 0x625ba5 in std::char_traits<char>::length(char const*)
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/char_traits.h:371:9
    #2 0x578cc9 in gdb::basic_string_view<char, std::char_traits<char>
>::basic_string_view(char const*)
/home/root/Binutils/binutils_aflpp/gdb/./../gdbsupport/gdb_string_view.h:108:39
    #3 0xb290bd in process_coff_symbol(coff_symbol*, internal_auxent*,
objfile*) /home/root/Binutils/binutils_aflpp/gdb/coffread.c:1571:31
    #4 0xb2604b in coff_symtab_read(minimal_symbol_reader&, long, unsigned int,
objfile*) /home/root/Binutils/binutils_aflpp/gdb/coffread.c:1183:4
    #5 0xb1d5ea in coff_read_minsyms(long, unsigned int, objfile*)
/home/root/Binutils/binutils_aflpp/gdb/coffread.c:554:7
    #6 0xb1abd0 in coff_symfile_read(objfile*, enum_flags<symfile_add_flag>)
/home/root/Binutils/binutils_aflpp/gdb/coffread.c:702:3
    #7 0x1bf6a0e in read_symbols(objfile*, enum_flags<symfile_add_flag>)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:772:3
    #8 0x1c19531 in syms_from_objfile_1(objfile*, std::vector<other_sections,
std::allocator<other_sections> >*, enum_flags<symfile_add_flag>)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:968:3
    #9 0x1c180fd in syms_from_objfile(objfile*, std::vector<other_sections,
std::allocator<other_sections> >*, enum_flags<symfile_add_flag>)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:985:3
    #10 0x1be663c in symbol_file_add_with_addrs(bfd*, char const*,
enum_flags<symfile_add_flag>, std::vector<other_sections,
std::allocator<other_sections> >*, enum_flags<objfile_flag>, objfile*)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:1088:3
    #11 0x1be70b3 in symbol_file_add_from_bfd(bfd*, char const*,
enum_flags<symfile_add_flag>, std::vector<other_sections,
std::allocator<other_sections> >*, enum_flags<objfile_flag>, objfile*)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:1168:10
    #12 0x1be7459 in symbol_file_add(char const*, enum_flags<symfile_add_flag>,
std::vector<other_sections, std::allocator<other_sections> >*,
enum_flags<objfile_flag>)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:1181:10
    #13 0x1be873e in symbol_file_add_main_1(char const*,
enum_flags<symfile_add_flag>, enum_flags<objfile_flag>, unsigned long)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:1205:29
    #14 0x1be82ea in symbol_file_add_main(char const*,
enum_flags<symfile_add_flag>)
/home/root/Binutils/binutils_aflpp/gdb/symfile.c:1196:3
    #15 0x15c8b73 in symbol_file_add_main_adapter(char const*, int)
/home/root/Binutils/binutils_aflpp/gdb/main.c:540:3
    #16 0x15c6d2c in catch_command_errors(void (*)(char const*, int), char
const*, int, bool) /home/root/Binutils/binutils_aflpp/gdb/main.c:513:7
    #17 0x15c433a in captured_main_1(captured_main_args*)
/home/root/Binutils/binutils_aflpp/gdb/main.c:1212:8
    #18 0x15be28d in captured_main(void*)
/home/root/Binutils/binutils_aflpp/gdb/main.c:1319:3
    #19 0x15be058 in gdb_main(captured_main_args*)
/home/root/Binutils/binutils_aflpp/gdb/main.c:1344:7
    #20 0x4e4f12 in main /home/root/Binutils/binutils_aflpp/gdb/gdb.c:32:10
    #21 0x7f4f1097e082 in __libc_start_main
/build/glibc-5hggjy/glibc-2.31/csu/../csu/libc-start.c:308:16
    #22 0x433ebd in _start
(/home/root/Binutils/binutils_aflpp/gdb/batch-silent/gdb_3/gdb+0x433ebd)

0x000002e3ed15 is located 43 bytes to the left of global variable '<string
literal>' defined in './libbfd.h:2673:3' (0x2e3ed40) of size 21
  '<string literal>' is ascii string 'BFD_RELOC_CR16_IMM20'
0x000002e3ed15 is located 0 bytes to the right of global variable '<string
literal>' defined in './libbfd.h:2672:3' (0x2e3ed00) of size 21
  '<string literal>' is ascii string 'BFD_RELOC_CR16_IMM16'
SUMMARY: AddressSanitizer: global-buffer-overflow
(/home/root/Binutils/binutils_aflpp/gdb/batch-silent/gdb_3/gdb+0x447f75) in
strlen
Shadow bytes around the buggy address:
  0x0000805bfd50: 00 00 00 f9 f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9
  0x0000805bfd60: 00 00 00 01 f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9
  0x0000805bfd70: 00 00 00 f9 f9 f9 f9 f9 00 00 00 01 f9 f9 f9 f9
  0x0000805bfd80: 00 00 05 f9 f9 f9 f9 f9 00 00 05 f9 f9 f9 f9 f9
  0x0000805bfd90: 00 00 04 f9 f9 f9 f9 f9 00 00 04 f9 f9 f9 f9 f9
=>0x0000805bfda0: 00 00[05]f9 f9 f9 f9 f9 00 00 05 f9 f9 f9 f9 f9
  0x0000805bfdb0: 00 00 05 f9 f9 f9 f9 f9 00 00 05 f9 f9 f9 f9 f9
  0x0000805bfdc0: 00 00 06 f9 f9 f9 f9 f9 00 00 05 f9 f9 f9 f9 f9
  0x0000805bfdd0: 00 00 05 f9 f9 f9 f9 f9 00 00 06 f9 f9 f9 f9 f9
  0x0000805bfde0: 00 00 06 f9 f9 f9 f9 f9 00 00 06 f9 f9 f9 f9 f9
  0x0000805bfdf0: 00 00 07 f9 f9 f9 f9 f9 00 00 07 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==2453180==ABORTING
```

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-23 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-23 16:16 [Bug gdb/30667] New: gdb global buffer overflow in process_coff_symbol mengda2020 at iscas dot ac.cn

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