[RFC] libdw: checked fixed-width reads for DWARF section parsing
Karan Kurani
karankurani3k@gmail.com
Fri Jul 24 15:32:04 GMT 2026
Hi Mark, Sayed,
Following up on the RFC discussion, I have prepared the first small
implementation stage and attached the two patches:
0001-libdw-Add-checked-initial-length-readers.patch
0002-libdw-Use-checked-reads-for-DWARF5-initial-lengths.patch
The first patch adds boolean-returning checked 4-byte and 8-byte
incrementing readers. If the complete value is unavailable, the helpers
return false without modifying either the cursor or the result.
The second patch applies these readers to the DWARF32 and DWARF64
initial-length fields in .debug_str_offsets, .debug_rnglists and
.debug_loclists. The existing version, unit-extent and table validation
remains in place.
The series is intentionally limited to this coherent initial-length
family. It also avoids local availability expressions that can form
dataend - 4 or dataend - 8 before establishing that the section contains
that many bytes.
Following Mark's RFC feedback, the core uses boolean-returning static
inline functions and the work is split into two small patches. There are
no public API or ABI changes.
Validation against upstream commit
fb5473ac7368bbbbc2ea9d86241bd6c882e3fcb5:
- full make check: 253 PASS, 8 SKIP, 0 FAIL
- focused and parser tests clean under ASan and UBSan
- 1,610 baseline/patched valid-input comparisons with no differences
- abidiff reported no ABI differences
Comments and suggestions are welcome.
Thanks,
Karan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20260724/ef5d61a0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libdw-Add-checked-initial-length-readers.patch
Type: application/octet-stream
Size: 6236 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20260724/ef5d61a0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-libdw-Use-checked-reads-for-DWARF5-initial-lengths.patch
Type: application/octet-stream
Size: 4234 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20260724/ef5d61a0/attachment-0001.obj>
More information about the Elfutils-devel
mailing list