public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug libelf/28666] New: memmove() reads out-of-range in elf32_xlatetom
@ 2021-12-07 12:53 netfirewall at gmail dot com
  2021-12-07 14:14 ` [Bug libelf/28666] " evvers at ya dot ru
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: netfirewall at gmail dot com @ 2021-12-07 12:53 UTC (permalink / raw)
  To: elfutils-devel

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

            Bug ID: 28666
           Summary: memmove() reads out-of-range in elf32_xlatetom
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libelf
          Assignee: unassigned at sourceware dot org
          Reporter: netfirewall at gmail dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Created attachment 13829
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13829&action=edit
poc1

Hi,

A memmove() reads out-of-range was triggered when we were fuzzing the elfutils.
The same issue can be triggered in the release version 0.186 and the upstream
version.

We fuzzed with a modified oss-fuzz, so it can be reproduced with oss-fuzz
steup. Here are the steps to reproduce (poc1 is attached):

> 1. git clone https://github.com/google/oss-fuzz.git
> 2. cd oss-fuzz
> 3. python3 infra/helper.py build_fuzzers --engine libfuzzer --sanitizer address elfutils
> 4. python3 infra/helper.py reproduce elfutils fuzz-dwfl-core ./poc1

The same payload also crashes the release 0.186 (commit
983e86fd89e8bf02f2d27ba5dce5bf078af4ceda). To reproduce on 0.186, edit
oss-fuzz/projects/elfutils/Dockerfile as below, and follow the same steps
above.

> FROM gcr.io/oss-fuzz-base/base-builder
> RUN apt-get update && \
>     apt-get install -y pkg-config make autoconf autopoint zlib1g-dev flex bison gawk
> RUN git clone git://sourceware.org/git/elfutils.git
> WORKDIR elfutils
> RUN git checkout 983e86fd89e8bf02f2d27ba5dce5bf078af4ceda
> COPY build.sh *.c *.zip $SRC/

Here is the ASAN dump (upstream, commit
66f704ae705a489d35cd03aa9687e192a844d766):

> ==13==ERROR: AddressSanitizer: unknown-crash on address 0x7fab2f62e000 at pc 0x00000052487f bp 0x7ffe9c2ec120 sp 0x7ffe9c2eb8e8[35/1970]
> READ of size 1790976 at 0x7fab2f62e000 thread T0                                                                                        
> SCARINESS: 16 (multi-byte-read-unknown-crash)                                                                                           
>     #0 0x52487e in __asan_memmove /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:30:3                       
>     #1 0x63ca73 in memmove /usr/include/x86_64-linux-gnu/bits/string_fortified.h:40:10                                                  
>     #2 0x63ca73 in elf32_xlatetom /src/elfutils/libelf/elf32_xlatetom.c:96:2                                                            
>     #3 0x5fc040 in dwfl_link_map_report /src/elfutils/libdwfl/link_map.c:895:12                                                         
>     #4 0x56631a in dwfl_core_file_report /src/elfutils/libdwfl/core-file.c:548:16                                                       
>     #5 0x55e4e0 in LLVMFuzzerTestOneInput /src/fuzz-dwfl-core.c:52:6                                                                    
>     #6 0x456cb3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp                             
>     #7 0x4425b2 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver
> .cpp:324:6                                                                                                                              
>     #8 0x44807a in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp                
>     #9 0x470f62 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10                                                   
>     #10 0x7fab304800b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)                                                   
>     #11 0x41f83d in _start (/out/fuzz-dwfl-core+0x41f83d)                                                                               
>                                                                                                                                         
> DEDUP_TOKEN: __asan_memmove--memmove--elf32_xlatetom                                                                                    
> Address 0x7fab2f62e000 is a wild pointer inside of access range of size 0x0000001b5400.                                                 
> SUMMARY: AddressSanitizer: unknown-crash /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:30:3 in __asan_memmo
> ve                                                                                                                                      
> Shadow bytes around the buggy address:                                                                                                  
>   0x0ff5e5ebdbb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                       
>   0x0ff5e5ebdbc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                       
>   0x0ff5e5ebdbd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                       
>   0x0ff5e5ebdbe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                       
>   0x0ff5e5ebdbf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                       
> =>0x0ff5e5ebdc00:[fe]fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe                                                                       
>   0x0ff5e5ebdc10: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe                                                                       
>   0x0ff5e5ebdc20: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
>   0x0ff5e5ebdc30: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
>   0x0ff5e5ebdc40: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
>   0x0ff5e5ebdc50: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
> 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

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

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

end of thread, other threads:[~2021-12-09 20:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 12:53 [Bug libelf/28666] New: memmove() reads out-of-range in elf32_xlatetom netfirewall at gmail dot com
2021-12-07 14:14 ` [Bug libelf/28666] " evvers at ya dot ru
2021-12-07 14:50 ` mark at klomp dot org
2021-12-08 13:45 ` mark at klomp dot org
2021-12-08 17:25 ` evvers at ya dot ru
2021-12-08 20:28 ` evvers at ya dot ru
2021-12-08 20:37 ` evvers at ya dot ru
2021-12-09 19:08 ` mark at klomp dot org
2021-12-09 19:22 ` evvers at ya dot ru
2021-12-09 20:23 ` mark at klomp dot org

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