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

Fix Out-of-bounds read in the function modifyRPath #419

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

xiaoxiaoafeifei
Copy link

@xiaoxiaoafeifei xiaoxiaoafeifei commented Oct 26, 2022

Hi:
Out-of-bounds read exists in the function modifyRPath, I fixed this issue in this PR

  1. Here's ASAN log:
root@iZ2vcadn43p7fjzbhl6zqwZ:~/patchelf_0# /usr/local/bin/patchelf --shrink-rpath sample00900 
AddressSanitizer:DEADLYSIGNAL
=================================================================
==60417==ERROR: AddressSanitizer: SEGV on unknown address 0x626200001e58 (pc 0x557356cd43e7 bp 0x7ffeea76e550 sp 0x7ffeea76dfa0 T0)
==60417==The signal is caused by a READ memory access.
    #0 0x557356cd43e6 in ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, unsigned long, unsigned long, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, unsigned short>::modifyRPath(ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, unsigned long, unsigned long, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, unsigned short>::RPathOp, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) /root/patchelf_0/src/patchelf.cc:1376
    #1 0x557356b6ba6c in patchElf2<ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, long unsigned int, long unsigned int, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, short unsigned int> > /root/patchelf_0/src/patchelf.cc:1865
    #2 0x557356b6ba6c in patchElf /root/patchelf_0/src/patchelf.cc:1907
    #3 0x557356b6ba6c in mainWrapped(int, char**) /root/patchelf_0/src/patchelf.cc:2089
    #4 0x557356b56ee5 in main /root/patchelf_0/src/patchelf.cc:2097
    #5 0x7ff86c8b6082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)
    #6 0x557356b57bdd in _start (/usr/local/bin/patchelf+0x225bdd)
  1. Steps to Reproduce
    ./configure --with-asan --with-ubsan
    make & make install
    /usr/local/bin/patchelf --shrink-rpath sample00900

sample00900.zip

@xiaoxiaoafeifei xiaoxiaoafeifei changed the title Out-of-bounds read exists in the function modifyRPath Fix Out-of-bounds read exists in the function modifyRPath Oct 26, 2022
@xiaoxiaoafeifei xiaoxiaoafeifei changed the title Fix Out-of-bounds read exists in the function modifyRPath Fix Out-of-bounds read in the function modifyRPath Oct 26, 2022
@Mic92
Copy link
Member

Mic92 commented Oct 26, 2022

bors merge

@Mic92 Mic92 merged commit b751eeb into NixOS:master Oct 26, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants