Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer overflow loading rom with higan #104

Open
ghost opened this issue Oct 11, 2017 · 0 comments
Open

buffer overflow loading rom with higan #104

ghost opened this issue Oct 11, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 11, 2017

@Themaister,

First attempt to load a game with the new core gave me this heap overflow error.

[INFO] CRC32: 0x124d8e4d .
[INFO] Environ SET_PIXEL_FORMAT: XRGB8888.
[WARN] SYSTEM DIR is empty, assume CONTENT DIR /home/bp/roms/No-Intro/SNES/Aladdin (USA).zip
[INFO] Environ SYSTEM_DIRECTORY: "/home/bp/roms/No-Intro/SNES/".
[libretro INFO] Icarus writes file: game.sfc.
[libretro INFO] Icarus successfully read: game.sfc.
[libretro INFO] Icarus writes file: manifest.bml.
[libretro INFO] Icarus writes file: program.rom.
[libretro INFO] Icarus writes file: msu1.rom.
[libretro INFO] Using base path: /home/bp/saves/saves/higan (Super Famicom Accuracy)/Aladdin (USA). for game data.
[libretro INFO] Accessing data from 0: manifest.bml (required: yes)
[libretro INFO] Accessing data from 0: ipl.rom (required: yes)
[libretro INFO] Loading game for ID: 1 using option Auto.
[libretro INFO] Accessing data from 1: manifest.bml (required: yes)
[libretro INFO] Reading imported file: manifest.bml.
=================================================================
==16494==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x613000000700 at pc 0x7fe77b9ad8d0 bp 0x7ffc3362c990 sp 0x7ffc3362c138
READ of size 389 at 0x613000000700 thread T0
    #0 0x7fe77b9ad8cf in __interceptor_strlen /build/gcc-multilib/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:225
    #1 0x7fe769493db0 in nall::stringify<char const*>::size() const ../nall/string/cast.hpp:203
    #2 0x7fe7694eb5e7 in nall::string& nall::string::_append<char const*>(nall::stringify<char const*> const&) ../nall/string/core.hpp:69
    #3 0x7fe7695073a9 in nall::string& nall::string::append<char const*, unsigned int>(char const* const&, unsigned int&&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x16073a9)
    #4 0x7fe7694e80c9 in nall::string::string<char const*, unsigned int>(char const*&&, unsigned int&&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x15e80c9)
    #5 0x7fe76947d97a in Program::open(unsigned int, nall::string, nall::vfs::file::mode, bool) target-libretro/libretro.cpp:240
    #6 0x7fe7696787f2 in SuperFamicom::Cartridge::load() sfc/cartridge/cartridge.cpp:37
    #7 0x7fe7695d504d in SuperFamicom::System::load(Emulator::Interface*) sfc/system/system.cpp:63
    #8 0x7fe7695af1a0 in SuperFamicom::Interface::load(unsigned int) sfc/interface/interface.cpp:174
    #9 0x7fe76948848b in retro_load_game target-libretro/libretro.cpp:638
    #10 0x562d7273ac24 in core_load_game /home/bp/RetroArch-bp/RetroArch/core_impl.c:289
    #11 0x562d7276d662 in content_file_load tasks/task_content.c:614
    #12 0x562d7276f38f in content_file_init tasks/task_content.c:795
    #13 0x562d72775bca in content_init tasks/task_content.c:1801
    #14 0x562d727517e5 in event_init_content /home/bp/RetroArch-bp/RetroArch/command.c:1220
    #15 0x562d72751be5 in command_event_init_core /home/bp/RetroArch-bp/RetroArch/command.c:1278
    #16 0x562d72755383 in command_event /home/bp/RetroArch-bp/RetroArch/command.c:2154
    #17 0x562d7273f4af in retroarch_main_init /home/bp/RetroArch-bp/RetroArch/retroarch.c:1271
    #18 0x562d7276b5b4 in content_load tasks/task_content.c:276
    #19 0x562d7276fc65 in task_load_content tasks/task_content.c:862
    #20 0x562d72774617 in task_load_content_callback tasks/task_content.c:1533
    #21 0x562d7277492b in task_push_load_content_from_cli tasks/task_content.c:1596
    #22 0x562d72736fb9 in rarch_main frontend/frontend.c:115
    #23 0x562d727371a9 in main frontend/frontend.c:151
    #24 0x7fe774cf44c9 in __libc_start_main (/usr/lib/libc.so.6+0x204c9)
    #25 0x562d7272b559 in _start (/home/bp/RetroArch-bp/RetroArch/retroarch+0x8d7559)

0x613000000700 is located 0 bytes to the right of 384-byte region [0x613000000580,0x613000000700)
allocated by thread T0 here:
    #0 0x7fe77ba3dae9 in __interceptor_malloc /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:62
    #1 0x7fe7694903a6 in nall::memory::allocate(unsigned int) ../nall/memory.hpp:46
    #2 0x7fe769503910 in nall::vector<unsigned char>::operator=(nall::vector<unsigned char> const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x1603910)
    #3 0x7fe7694e745a in nall::vector<unsigned char>::vector(nall::vector<unsigned char> const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x15e745a)
    #4 0x7fe769515213 in nall::map<nall::string, nall::vector<unsigned char> >::node_t::node_t(nall::map<nall::string, nall::vector<unsigned char> >::node_t const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x1615213)
    #5 0x7fe769515288 in nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::node_t::node_t(nall::map<nall::string, nall::vector<unsigned char> >::node_t const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x1615288)
    #6 0x7fe7695112fc in nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::insert(nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::node_t*&, nall::map<nall::string, nall::vector<unsigned char> >::node_t const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x16112fc)
    #7 0x7fe769511614 in nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::insert(nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::node_t*&, nall::map<nall::string, nall::vector<unsigned char> >::node_t const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x1611614)
    #8 0x7fe7695032f4 in nall::set<nall::map<nall::string, nall::vector<unsigned char> >::node_t>::insert(nall::map<nall::string, nall::vector<unsigned char> >::node_t const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x16032f4)
    #9 0x7fe7694e6d8e in nall::map<nall::string, nall::vector<unsigned char> >::insert(nall::string const&, nall::vector<unsigned char> const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x15e6d8e)
    #10 0x7fe7694c5f3c in LibretroIcarus::write(nall::string const&, unsigned char const*, unsigned int) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x15c5f3c)
    #11 0x7fe7694c4a00 in Icarus::write(nall::string const&, nall::string const&) (/home/bp/RetroArch-bp/higan/higan/out/higan_sfc_libretro.so+0x15c4a00)
    #12 0x7fe76944c974 in Icarus::superFamicomImport(nall::vector<unsigned char>&, nall::string) target-libretro/../../icarus/core/super-famicom.cpp:60
    #13 0x7fe769441856 in Icarus::import(nall::string) target-libretro/../../icarus/core/core.cpp:85
    #14 0x7fe769474366 in LibretroIcarus::import_rom(nall::string const&, unsigned char const*, unsigned long) target-libretro/libretro.cpp:110
    #15 0x7fe769487c72 in retro_load_game target-libretro/libretro.cpp:626
    #16 0x562d7273ac24 in core_load_game /home/bp/RetroArch-bp/RetroArch/core_impl.c:289
    #17 0x562d7276d662 in content_file_load tasks/task_content.c:614
    #18 0x562d7276f38f in content_file_init tasks/task_content.c:795
    #19 0x562d72775bca in content_init tasks/task_content.c:1801
    #20 0x562d727517e5 in event_init_content /home/bp/RetroArch-bp/RetroArch/command.c:1220
    #21 0x562d72751be5 in command_event_init_core /home/bp/RetroArch-bp/RetroArch/command.c:1278
    #22 0x562d72755383 in command_event /home/bp/RetroArch-bp/RetroArch/command.c:2154
    #23 0x562d7273f4af in retroarch_main_init /home/bp/RetroArch-bp/RetroArch/retroarch.c:1271
    #24 0x562d7276b5b4 in content_load tasks/task_content.c:276
    #25 0x562d7276fc65 in task_load_content tasks/task_content.c:862
    #26 0x562d72774617 in task_load_content_callback tasks/task_content.c:1533
    #27 0x562d7277492b in task_push_load_content_from_cli tasks/task_content.c:1596
    #28 0x562d72736fb9 in rarch_main frontend/frontend.c:115
    #29 0x562d727371a9 in main frontend/frontend.c:151

SUMMARY: AddressSanitizer: heap-buffer-overflow /build/gcc-multilib/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:225 in __interceptor_strlen
Shadow bytes around the buggy address:
  0x0c267fff8090: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff80a0: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c267fff80b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff80c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff80d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c267fff80e0:[fa]fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c267fff80f0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff8100: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff8110: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c267fff8120: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff8130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
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
==16494==ABORTING

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants