[PATCH] libdwfl: Read no more than required to parse dynamic sections
gavin@matician.com
gavin@matician.com
Tue Nov 29 06:26:53 GMT 2022
From: Gavin Li <gavin@matician.com>
Since size checking has been moved to dwfl_elf_phdr_memory_callback(),
there is no longer a need for dwfl_segment_report_module() to enforce
the same. Reading beyond the end of the dynamic section actually causes
issues when passing the data to elfXX_xlatetom() because it is possible
that src->d_size is not a multiple of recsize (for ELF_T_DYN, recsize is
16 while the minimum required alignment is 8), causing elfXX_xlatetom()
to return ELF_E_INVALID_DATA.
Signed-off-by: Gavin Li <gavin@matician.com>
---
libdwfl/dwfl_segment_report_module.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 287fc002..08aca0eb 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -821,12 +821,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
&& ! read_portion (&read_state, &dyn_data, &dyn_data_size,
start, segment, dyn_vaddr, dyn_filesz))
{
- /* dyn_data_size will be zero if we got everything from the initial
- buffer, otherwise it will be the size of the new buffer that
- could be read. */
- if (dyn_data_size != 0)
- dyn_filesz = dyn_data_size;
-
if ((dyn_filesz / dyn_entsize) == 0
|| dyn_filesz > (SIZE_MAX / dyn_entsize))
goto out;
--
2.38.1
More information about the Elfutils-devel
mailing list