Skip to content

fileinfo crashes in fileformat::ElfFormat::loadInfoFromDynamicTables() #89

Closed
@bansan85

Description

fileinfo crashes while loading dynamic table.
Found with fuzzer after a dozen of second.

Input

loadDynamicTable.zip

fileinfo loadDynamicTable

output

backtrace:

#0  __memmove_sse2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:356
#1  0x0000555555caa806 in std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<char> (__result=<optimized out>, __last=<optimized out>, 
    __first=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/stl_algobase.h:368
#2  std::__copy_move_a<false, char const*, char*> (__result=<optimized out>, __last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/stl_algobase.h:386
#3  std::__copy_move_a2<false, char const*, char*> (__result=<optimized out>, __last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/stl_algobase.h:424
#4  std::copy<char const*, char*> (__result=<optimized out>, __last=0x230 <error: Cannot access memory at address 0x230>, 
    __first=0x200 <error: Cannot access memory at address 0x200>) at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/stl_algobase.h:456
#5  ELFIO::section_impl<ELFIO::Elf64_Shdr>::set_data (this=0x5555576786b0, raw_data=0x200 <error: Cannot access memory at address 0x200>, size=48)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/deps/elfio/include/elfio/elfio_section.hpp:173
#6  0x0000555555c8d6fe in fileformat::ElfFormat::addStringTable (this=this@entry=0x555557670510, dynamicSection=dynamicSection@entry=0x555557678540, 
    table=...) at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:1160
#7  0x0000555555c9eeb0 in fileformat::ElfFormat::loadInfoFromDynamicTables (this=this@entry=0x555557670510, noOfTables=noOfTables@entry=1)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:1949
#8  0x0000555555c9fe3f in fileformat::ElfFormat::loadInfoFromDynamicSegment (this=this@entry=0x555557670510)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:2010
#9  0x0000555555ca0740 in fileformat::ElfFormat::initStructures (this=this@entry=0x555557670510)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:1089
#10 0x0000555555ca26e8 in fileformat::ElfFormat::initStructures (this=0x555557670510)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:1074
#11 fileformat::ElfFormat::ElfFormat (this=0x555557670510, pathToFile=..., loadFlags=<optimized out>)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileformat/file_format/elf/elf_format.cpp:1031
#12 0x000055555599169a in fileinfo::ElfWrapper::ElfWrapper (this=0x555557670510, pathToFile=..., loadFlags=fileformat::NONE)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileinfo/file_wrapper/elf_wrapper.cpp:18
#13 0x0000555555668c47 in __gnu_cxx::new_allocator<fileinfo::ElfWrapper>::construct<fileinfo::ElfWrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (this=<optimized out>, __p=0x555557670510)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/ext/new_allocator.h:136
#14 std::allocator_traits<std::allocator<fileinfo::ElfWrapper> >::construct<fileinfo::ElfWrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=..., __p=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/alloc_traits.h:475
#15 std::_Sp_counted_ptr_inplace<fileinfo::ElfWrapper, std::allocator<fileinfo::ElfWrapper>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=..., this=0x555557670500)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr_base.h:526
#16 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<fileinfo::ElfWrapper, std::allocator<fileinfo::ElfWrapper>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=..., this=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr_base.h:637
#17 std::__shared_ptr<fileinfo::ElfWrapper, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<fileinfo::ElfWrapper>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=..., __tag=..., this=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr_base.h:1295
#18 std::shared_ptr<fileinfo::ElfWrapper>::shared_ptr<std::allocator<fileinfo::ElfWrapper>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=..., __tag=..., this=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr.h:344
#19 std::allocate_shared<fileinfo::ElfWrapper, std::allocator<fileinfo::ElfWrapper>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> (__a=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr.h:691
#20 std::make_shared<fileinfo::ElfWrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fileformat::LoadFlags&> ()
    at /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/shared_ptr.h:707
#21 fileinfo::ElfDetector::ElfDetector (this=0x555557670160, pathToInputFile=..., finfo=..., searchPar=..., loadFlags=fileformat::NONE)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileinfo/file_detector/elf_detector.cpp:399
#22 0x0000555555646125 in fileinfo::createFileDetector (pathToInputFile=..., fileFormat=<optimized out>, finfo=..., searchPar=..., loadFlags=fileformat::NONE)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileinfo/file_detector/detector_factory.cpp:38
#23 0x000055555560a593 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/legarrec/info/programmation/retdec/deps/fileformat/src/fileinfo/fileinfo.cpp:395

From master (8c4b23d)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions