[PATCH] Add config/compile as installed by automake 1.14
by Josh Stone
Signed-off-by: Josh Stone <jistone(a)redhat.com>
---
.gitignore | 1 +
ChangeLog | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/.gitignore b/.gitignore
index 1eda00b80774..8e33bb9b5114 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ config.h.in
config.log
config.status
config/ar-lib
+config/compile
config/config.guess
config/config.sub
config/depcomp
diff --git a/ChangeLog b/ChangeLog
index 8eeaa08e49d7..451e228536af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-12-15 Josh Stone <jistone(a)redhat.com>
+
+ * .gitignore: Add config/compile as installed by automake 1.14.
+
2014-11-27 Mark Wielaard <mjw(a)redhat.com>
* configure.ac: Add --disable-textrelcheck.
--
2.1.0
9 years, 4 months
[PATCH] readelf: Warn, don't assert, if loclist or rangelist offset is too big.
by Mark Wielaard
We use a couple of bits to keep track of the addr size, dwarf size and
warning given for a loclist or rangelist offset. Normally offset won't
be that big and will fit in 61-bits easily. But if not, don't assert,
but just warn we don't handle such large offsets.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 6 ++++++
src/readelf.c | 45 +++++++++++++++++++++++++++++----------------
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 08f9ee4..bb3e84f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (notice_listptr): Return false if offset doesn't fit
+ in 61-bits.
+ (attr_callback): Warn if loclist or rangelist offset doesn't fit.
+
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_ops): Don't assert when addr_size or ref_size
is not 4 or 8, just report invalid data.
diff --git a/src/readelf.c b/src/readelf.c
index aa85d73..e9a356d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4426,7 +4426,8 @@ reset_listptr (struct listptr_table *table)
table->n = table->alloc = 0;
}
-static void
+/* Returns false if offset doesn't fit. See struct listptr. */
+static bool
notice_listptr (enum section_e section, struct listptr_table *table,
uint_fast8_t address_size, uint_fast8_t offset_size,
struct Dwarf_CU *cu, Dwarf_Off offset)
@@ -4452,8 +4453,14 @@ notice_listptr (enum section_e section, struct listptr_table *table,
.offset = offset,
.cu = cu
};
- assert (p->offset == offset);
+
+ if (p->offset != offset)
+ {
+ table->n--;
+ return false;
+ }
}
+ return true;
}
static void
@@ -5849,23 +5856,29 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
case DW_AT_GNU_call_site_data_value:
case DW_AT_GNU_call_site_target:
case DW_AT_GNU_call_site_target_clobbered:
- notice_listptr (section_loc, &known_loclistptr,
- cbargs->addrsize, cbargs->offset_size,
- cbargs->cu, num);
- if (!cbargs->silent)
- printf (" %*s%-20s (%s) location list [%6" PRIxMAX "]\n",
- (int) (level * 2), "", dwarf_attr_name (attr),
- dwarf_form_name (form), (uintmax_t) num);
+ {
+ bool nlpt = notice_listptr (section_loc, &known_loclistptr,
+ cbargs->addrsize, cbargs->offset_size,
+ cbargs->cu, num);
+ if (!cbargs->silent)
+ printf (" %*s%-20s (%s) location list [%6" PRIxMAX "]%s\n",
+ (int) (level * 2), "", dwarf_attr_name (attr),
+ dwarf_form_name (form), (uintmax_t) num,
+ nlpt ? "" : " <WARNING offset too big>");
+ }
return DWARF_CB_OK;
case DW_AT_ranges:
- notice_listptr (section_ranges, &known_rangelistptr,
- cbargs->addrsize, cbargs->offset_size,
- cbargs->cu, num);
- if (!cbargs->silent)
- printf (" %*s%-20s (%s) range list [%6" PRIxMAX "]\n",
- (int) (level * 2), "", dwarf_attr_name (attr),
- dwarf_form_name (form), (uintmax_t) num);
+ {
+ bool nlpt = notice_listptr (section_ranges, &known_rangelistptr,
+ cbargs->addrsize, cbargs->offset_size,
+ cbargs->cu, num);
+ if (!cbargs->silent)
+ printf (" %*s%-20s (%s) range list [%6" PRIxMAX "]%s\n",
+ (int) (level * 2), "", dwarf_attr_name (attr),
+ dwarf_form_name (form), (uintmax_t) num,
+ nlpt ? "" : " <WARNING offset too big>");
+ }
return DWARF_CB_OK;
case DW_AT_language:
--
1.8.3.1
9 years, 4 months
[PATCH] readelf: Don't assert when addr_size or ref_size is not 4 or 8 in print_ops.
by Mark Wielaard
Just report invalid data and continue.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 23 ++++++++---------------
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 182c9cd..08f9ee4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_ops): Don't assert when addr_size or ref_size
+ is not 4 or 8, just report invalid data.
+
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_gdb_index_section): Add more bounds checks.
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index 41239bc..aa85d73 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -3981,11 +3981,10 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
NEED (addrsize);
if (addrsize == 4)
addr = read_4ubyte_unaligned (dbg, data);
+ else if (addrsize == 8)
+ addr = read_8ubyte_unaligned (dbg, data);
else
- {
- assert (addrsize == 8);
- addr = read_8ubyte_unaligned (dbg, data);
- }
+ goto invalid;
data += addrsize;
CONSUME (addrsize);
@@ -3999,16 +3998,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
case DW_OP_call_ref:
/* Offset operand. */
- if (ref_size == 0)
+ if (ref_size != 4 && ref_size != 8)
goto invalid; /* Cannot be used in CFA. */
NEED (ref_size);
if (ref_size == 4)
addr = read_4ubyte_unaligned (dbg, data);
else
- {
- assert (ref_size == 8);
- addr = read_8ubyte_unaligned (dbg, data);
- }
+ addr = read_8ubyte_unaligned (dbg, data);
data += ref_size;
CONSUME (ref_size);
@@ -4206,16 +4202,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
case DW_OP_GNU_implicit_pointer:
/* DIE offset operand. */
start = data;
- NEED (ref_size + 1);
- if (ref_size == 0)
+ NEED (ref_size);
+ if (ref_size != 4 && ref_size != 8)
goto invalid; /* Cannot be used in CFA. */
if (ref_size == 4)
addr = read_4ubyte_unaligned (dbg, data);
else
- {
- assert (ref_size == 8);
- addr = read_8ubyte_unaligned (dbg, data);
- }
+ addr = read_8ubyte_unaligned (dbg, data);
data += ref_size;
/* Byte offset operand. */
NEED (1);
--
1.8.3.1
9 years, 4 months
[PATCH] libdw: dwarf_getpubnames set error to DWARF_E_NO_ENTRY for zero entries.
by Mark Wielaard
realloc in get_offsets will return NULL otherwise and dwarf_getpubnames
might think there was no issue and try to use that NULL pointer.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdw/ChangeLog | 2 +-
libdw/dwarf_getpubnames.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 93651df..2aa878b 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,7 +1,7 @@
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
* dwarf_getpubnames.c (get_offsets): Make sure whole unit fall inside
- section data.
+ section data. Set error to DWARF_E_NO_ENTRY if cnt is zero.
(dwarf_getpubnames): Make sure section data contains string zero
terminator.
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index c8b9f9f..9fbfcbf 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -125,7 +125,7 @@ get_offsets (Dwarf *dbg)
readp += len;
}
- if (mem == NULL)
+ if (mem == NULL || cnt == 0)
{
__libdw_seterrno (DWARF_E_NO_ENTRY);
return -1;
--
1.8.3.1
9 years, 4 months
[PATCH] readelf: Add more bounds checks to print_gdb_index_section.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/readelf.c | 8 +++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index a193f40..182c9cd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_gdb_index_section): Add more bounds checks.
+
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_debug_line_section): Check there is enough room
for DW_LNE_set_address argument. Make sure there is enough room
for the the initial unit_length.
diff --git a/src/readelf.c b/src/readelf.c
index cd8ba86..41239bc 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -8048,21 +8048,23 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
if (name != 0 || vector != 0)
{
const unsigned char *sym = data->d_buf + const_off + name;
- if (unlikely (sym > dataend))
+ if (unlikely (sym > dataend
+ || memchr (sym, '\0', dataend - sym) == NULL))
goto invalid_data;
printf (" [%4zu] symbol: %s, CUs: ", n, sym);
const unsigned char *readcus = data->d_buf + const_off + vector;
- if (unlikely (readcus + 8 > dataend))
+ if (unlikely (readcus + 4 > dataend))
goto invalid_data;
-
uint32_t cus = read_4ubyte_unaligned (dbg, readcus);
while (cus--)
{
uint32_t cu_kind, cu, kind;
bool is_static;
readcus += 4;
+ if (unlikely (readcus + 4 > dataend))
+ goto invalid_data;
cu_kind = read_4ubyte_unaligned (dbg, readcus);
cu = cu_kind & ((1 << 24) - 1);
kind = (cu_kind >> 28) & 7;
--
1.8.3.1
9 years, 4 months
[PATCH] libdw: Add bounds checking to dwarf_getpubnames.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdw/ChangeLog | 7 +++++++
libdw/dwarf_getpubnames.c | 16 +++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 0543740..93651df 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,10 @@
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
+ * dwarf_getpubnames.c (get_offsets): Make sure whole unit fall inside
+ section data.
+ (dwarf_getpubnames): Make sure section data contains string zero
+ terminator.
+
2014-12-14 Mark Wielaard <mjw(a)redhat.com>
* cfi.c (execute_cfi): Add program bounds checks.
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index 12728a3..c8b9f9f 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -88,9 +88,11 @@ get_offsets (Dwarf *dbg)
/* Now we know the offset of the first offset/name pair. */
mem[cnt].set_start = readp + 2 + 2 * len_bytes - startp;
mem[cnt].address_len = len_bytes;
- if (mem[cnt].set_start >= dbg->sectiondata[IDX_debug_pubnames]->d_size)
+ size_t max_size = dbg->sectiondata[IDX_debug_pubnames]->d_size;
+ if (mem[cnt].set_start >= max_size
+ || len - (2 + 2 * len_bytes) > max_size - mem[cnt].set_start)
/* Something wrong, the first entry is beyond the end of
- the section. */
+ the section. Or the length of the whole unit is too big. */
break;
/* Read the version. It better be two for now. */
@@ -184,6 +186,8 @@ dwarf_getpubnames (dbg, callback, arg, offset)
unsigned char *startp
= (unsigned char *) dbg->sectiondata[IDX_debug_pubnames]->d_buf;
+ unsigned char *endp
+ = startp + dbg->sectiondata[IDX_debug_pubnames]->d_size;
unsigned char *readp = startp + offset;
while (1)
{
@@ -208,7 +212,13 @@ dwarf_getpubnames (dbg, callback, arg, offset)
gl.die_offset += dbg->pubnames_sets[cnt].cu_offset;
gl.name = (char *) readp;
- readp = (unsigned char *) rawmemchr (gl.name, '\0') + 1;
+ readp = (unsigned char *) memchr (gl.name, '\0', endp - readp);
+ if (unlikely (readp == NULL))
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return -1l;
+ }
+ readp++;
/* We found name and DIE offset. Report it. */
if (callback (dbg, &gl, arg) != DWARF_CB_OK)
--
1.8.3.1
9 years, 4 months
[PATCH] readelf: Make sure there is enough room for reading .debug_line unit_length.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 3 ++-
src/readelf.c | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 7247ea9..a193f40 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,8 @@
2014-12-15 Mark Wielaard <mjw(a)redhat.com>
* readelf.c (print_debug_line_section): Check there is enough room
- for DW_LNE_set_address argument.
+ for DW_LNE_set_address argument. Make sure there is enough room
+ for the the initial unit_length.
2014-12-14 Mark Wielaard <mjw(a)redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index faaa6d1..cd8ba86 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6333,6 +6333,8 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
printf (gettext ("\nTable at offset %Zu:\n"), start_offset);
+ if (unlikely (linep + 4 > lineendp))
+ goto invalid_data;
Dwarf_Word unit_length = read_4ubyte_unaligned_inc (dbg, linep);
unsigned int length = 4;
if (unlikely (unit_length == 0xffffffff))
--
1.8.3.1
9 years, 4 months
[PATCH] readelf: Check there is enough room for the DW_LNE_set_address argument
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/src/ChangeLog b/src/ChangeLog
index a4f42e4..7247ea9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
+ * readelf.c (print_debug_line_section): Check there is enough room
+ for DW_LNE_set_address argument.
+
2014-12-14 Mark Wielaard <mjw(a)redhat.com>
* elflint.c (check_attributes): Call get_uleb128 with end pointer.
diff --git a/src/readelf.c b/src/readelf.c
index 51ce020..faaa6d1 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6609,6 +6609,8 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
case DW_LNE_set_address:
op_index = 0;
+ if (unlikely ((size_t) (lineendp - linep) < address_size))
+ goto invalid_unit;
if (address_size == 4)
address = read_4ubyte_unaligned_inc (dbg, linep);
else
--
1.8.3.1
9 years, 4 months
[PATCH] libelf: Clear any garbage left in the ar name table.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libelf/ChangeLog | 5 +++++
libelf/elf_begin.c | 8 ++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index cf168e7..7406509 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-15 Mark Wielaard <mjw(a)redhat.com>
+
+ * elf_begin.c (read_long_names): Clear any garbage left in the
+ name table.
+
2014-12-11 Mark Wielaard <mjw(a)redhat.com>
* elf_begin.c (file_read_elf): Correct ELF64 section offset check.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 7fb5fa5..c24a364 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -734,10 +734,14 @@ read_long_names (Elf *elf)
runp = newp;
while (1)
{
+ char *startp = runp;
runp = (char *) memchr (runp, '/', newp + len - runp);
if (runp == NULL)
- /* This was the last entry. */
- break;
+ {
+ /* This was the last entry. Clear any left overs. */
+ memset (startp, '\0', newp + len - startp);
+ break;
+ }
/* NUL-terminate the string. */
*runp = '\0';
--
1.8.3.1
9 years, 4 months
[PATCH] readelf: Check TType base offset and Action table are sane in exception table.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 0ae7e46..cc6bf13 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2014-12-11 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_debug_exception_table): Check TType base offset
+ and Action table are sane.
+
+2014-12-11 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_debug_frame_section): Check number of augmentation
chars to print.
diff --git a/src/readelf.c b/src/readelf.c
index 31a0e0a..fb0440d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7710,7 +7710,8 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
unsigned int ttype_base_offset;
get_uleb128 (ttype_base_offset, readp);
printf (" TType base offset: %#x\n", ttype_base_offset);
- ttype_base = readp + ttype_base_offset;
+ if (dataend - readp > ttype_base_offset)
+ ttype_base = readp + ttype_base_offset;
}
if (unlikely (readp + 1 > dataend))
@@ -7757,6 +7758,12 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
{
puts ("\n Action table:");
+ if (dataend - action_table < max_action + 1)
+ {
+ fputs (gettext (" <INVALID DATA>\n"), stdout);
+ return;
+ }
+
const unsigned char *const action_table_end
= action_table + max_action + 1;
@@ -7784,7 +7791,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
while (readp < action_table_end);
}
- if (max_ar_filter > 0)
+ if (max_ar_filter > 0 && ttype_base != NULL)
{
puts ("\n TType table:");
--
1.8.3.1
9 years, 4 months