* [PATCH] libdw: Make sure end of next cu doesn't overflow section data size.
@ 2014-12-11 23:25 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2014-12-11 23:25 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]
An invalid or trucated debug info/type section could cause the cu endp
to point beyond the end of section data.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libdw/ChangeLog | 4 ++++
libdw/libdw_findcu.c | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8b00970..8d27b8d 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
2014-12-11 Mark Wielaard <mjw@redhat.com>
+ * libdw_findcu.c (__libdw_intern_next_unit): Sanity check offset.
+
+2014-12-11 Mark Wielaard <mjw@redhat.com>
+
* dwarf_child.c (__libdw_find_attr): Call __libdw_form_val_len with
die->cu->endp, not the abbrev endp.
* dwarf_getattrs.c (dwarf_getattrs): Likewise.
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index 3c9633e..c783ff8 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -94,6 +94,12 @@ __libdw_intern_next_unit (dbg, debug_types)
return NULL;
}
+ /* Invalid or truncated debug section data? */
+ Elf_Data *data = dbg->sectiondata[debug_types
+ ? IDX_debug_types : IDX_debug_info];
+ if (unlikely (*offsetp > data->d_size))
+ *offsetp = data->d_size;
+
/* Create an entry for this CU. */
struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libdw: Make sure end of next cu doesn't overflow section data size.
@ 2014-12-16 10:52 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2014-12-16 10:52 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
On Fri, 2014-12-12 at 00:25 +0100, Mark Wielaard wrote:
> An invalid or trucated debug info/type section could cause the cu endp
> to point beyond the end of section data.
>
> 2014-12-11 Mark Wielaard <mjw@redhat.com>
>
> + * libdw_findcu.c (__libdw_intern_next_unit): Sanity check offset.
I pushed this to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-16 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 23:25 [PATCH] libdw: Make sure end of next cu doesn't overflow section data size Mark Wielaard
2014-12-16 10:52 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).