Skip to content

Commit 2930f31

Browse files
committed
Adding DW202403-001 ossfuzz id: 67490
modified: data.txt A carefully corrupted line table header can cause libdwarf to read outside of its allowed areas in a .debug_line section reading the file names part of the header. The failure to check for end-of-section following the very last byte in section has been present for many years. modified: ../src/lib/libdwarf/dwarf_line_table_reader_common.h
1 parent 18b0db9 commit 2930f31

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

bugxml/data.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
id: DW202403-001
2+
fuzzer: ossfuzz id: 67490
3+
datereported: 2024-03-18
4+
reportedby: David Korczynski
5+
vulnerability: Reads past end of line table
6+
product: libdwarf
7+
description: A carefully corrupted line table
8+
header can cause libdwarf to read outside of its
9+
allowed areas in a .debug_line section reading
10+
the file names part of the header.
11+
The failure to check for end-of-section following the
12+
very last byte in section has been present for many years.
13+
datefixed: 2024-02-19
14+
references: regressiontests/ossfuzz67490/fuzz_srcfiles-5195296927711232
15+
gitfixid:
16+
tarrelease:
17+
endrec: DW202403-001
18+
19+
120
id: DW202402-003
221
fuzzer: hongg
322
datereported: 2024-02-18

src/lib/libdwarf/dwarf_line_table_reader_common.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,16 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
911911
filename_entry_pairs[j].up_first;
912912
Dwarf_Unsigned lnform =
913913
filename_entry_pairs[j].up_second;
914+
915+
if (line_ptr >= line_ptr_end) {
916+
free(filename_entry_pairs);
917+
_dwarf_error_string(dbg, err,
918+
DW_DLE_LINE_NUMBER_HEADER_ERROR,
919+
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
920+
"file name format count too large "
921+
"to be correct. Corrupt DWARF/");
922+
return DW_DLV_ERROR;
923+
}
914924
switch (lntype) {
915925
/* The LLVM LNCT is documented in
916926
https://releases.llvm.org/9.0.0/docs
@@ -1064,8 +1074,11 @@ _dwarf_read_line_table_header(Dwarf_Debug dbg,
10641074
}
10651075
if (line_ptr > line_ptr_end) {
10661076
free(filename_entry_pairs);
1067-
_dwarf_error(dbg, err,
1068-
DW_DLE_LINE_NUMBER_HEADER_ERROR);
1077+
_dwarf_error_string(dbg, err,
1078+
DW_DLE_LINE_NUMBER_HEADER_ERROR,
1079+
"DW_DLE_LINE_NUMBER_HEADER_ERROR: "
1080+
"Reading line table header filenames "
1081+
"runs off end of section. Corrupt Dwarf");
10691082
return DW_DLV_ERROR;
10701083
}
10711084
}

0 commit comments

Comments
 (0)