public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: Read no more than required to parse dynamic sections
@ 2022-11-29  6:26 gavin
  2022-11-29 15:25 ` Mark Wielaard
  0 siblings, 1 reply; 6+ messages in thread
From: gavin @ 2022-11-29  6:26 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard, Gavin Li

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-13 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  6:26 [PATCH] libdwfl: Read no more than required to parse dynamic sections gavin
2022-11-29 15:25 ` Mark Wielaard
2022-11-29 21:48   ` Gavin Li
2022-11-30 23:14     ` Mark Wielaard
2022-12-01 21:13       ` Gavin Li
2022-12-13 16:49         ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).