Issue 56489
Summary LLDB crashes when loading core file due to divide-by-zero in ObjectFileELF::ParseSymbolTable()
Labels lldb
Assignees
Reporter Enna1
    @Cossack9989 found a crash when fuzzing lldb.

This crash is cause by SIGFPE. a divide-by-zero bug occured if `symtab_hdr->sh_entsize` equals 0
https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp#L2350

A simple workaround approach is to add a non-zero check like this:
```patch
    if (ReadSectionData(symtab, symtab_data) &&
        ReadSectionData(strtab, strtab_data)) {
+      if (symtab_hdr->sh_entsize == 0)
+       return 0;
      size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;

      return ParseSymbols(symbol_table, start_id, section_list, num_symbols,
                          symtab_data, strtab_data);
    }
```
I'm not sure if this is the correct approach to fix this.

This can be reproduced with the attached bundle, [lldb-sigfpe.zip](https://github.com/llvm/llvm-project/files/9091047/lldb-sigfpe.zip), with ELF file and core file.
```
$ lldb -c corefile test
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to