Re: [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
On Mon, Jun 04, 2018 at 06:54:53PM +0200, Mark Wielaard wrote: > We only call printf on stdout from one thread, so we don't need internal > stdio locking for stdout. > > On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null > goes from 65 seconds to 63 seconds. Pushed to master.
Re: [PATCH] readelf: Lookup gettext "yes" and "no" only once.
On Mon, Jun 04, 2018 at 06:57:27PM +0200, Mark Wielaard wrote: > On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null > goes from 63 seconds to 57 seconds. Pushed to master.
Re: [PATCH] readelf: Don't allocate string with asprintf, but reuse buffer with sprintf.
On Mon, Jun 04, 2018 at 07:05:16PM +0200, Mark Wielaard wrote: > Since we are single threaded we can just use a static result buffer for > format_dwarf_addr as long as we make sure to print the result before > calling format_dwarf_addr again. This removes lots of malloc/free calls. > > On my machine eu-readelf -N --debug-dump=info libxul.so > goes from 57 seconds to 55 seconds. Pushed to master.
[PATCH] tests: Use error, not assert, when trying to print a non-base type DIE.
When using the varlocs test with a fuzzer using assert for internal sanity checks is great to find issues. But when encountering bad data using an assert is wrong. Just use error to show we handle the data correctly (by reporting it is bad, instead of crashing). Signed-off-by: Mark Wielaard --- tests/ChangeLog | 5 + tests/varlocs.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index a7b8da72..587e2ac9 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2018-06-06 Mark Wielaard + + * varlocs.c (print_base_type): Use error, not assert when the DIE + isn't a base type. + 2018-06-02 Mark Wielaard * test-subr.sh (self_test_files_exe): Drop shared libraries. diff --git a/tests/varlocs.c b/tests/varlocs.c index 31a1069a..2ddd3d8f 100644 --- a/tests/varlocs.c +++ b/tests/varlocs.c @@ -122,7 +122,8 @@ dwarf_form_string (unsigned int form) static void print_base_type (Dwarf_Die *base) { - assert (dwarf_tag (base) == DW_TAG_base_type); + if (dwarf_tag (base) != DW_TAG_base_type) +error (EXIT_FAILURE, 0, "not a base type"); Dwarf_Attribute encoding; Dwarf_Word enctype = 0; -- 2.17.0
[PATCH] libdw: Report error in dwarf_getlocation_die for bogus opcode offset.
Found by afl fuzzer on varlocs test. varlocs sanity checks that the given offset in the opcode corresponds to the cuoffset of the returned DIE. In case the opcode offset was bogus this might fail because we might wrap around and return a random DIE instead of reporting an error. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/dwarf_getlocation_die.c | 8 2 files changed, 13 insertions(+) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 21adeb7..b000492 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2018-06-06 Mark Wielaard + + * dwarf_getlocation_die.c (dwarf_getlocation_die): Check offset + falls inside cu data. + 2018-06-05 Mark Wielaard * dwarf_getsrclines.c (read_srclines): Explicitly set diridx to -1 diff --git a/libdw/dwarf_getlocation_die.c b/libdw/dwarf_getlocation_die.c index 00369a9..673c61c 100644 --- a/libdw/dwarf_getlocation_die.c +++ b/libdw/dwarf_getlocation_die.c @@ -59,6 +59,12 @@ dwarf_getlocation_die (Dwarf_Attribute *attr, const Dwarf_Op *op, case DW_OP_GNU_const_type: case DW_OP_call2: case DW_OP_call4: + if (op->number > (attr->cu->end - attr->cu->start)) + { + invalid_offset: + __libdw_seterrno (DWARF_E_INVALID_OFFSET); + return -1; + } dieoff = attr->cu->start + op->number; break; @@ -66,6 +72,8 @@ dwarf_getlocation_die (Dwarf_Attribute *attr, const Dwarf_Op *op, case DW_OP_GNU_regval_type: case DW_OP_deref_type: case DW_OP_GNU_deref_type: + if (op->number2 > (attr->cu->end - attr->cu->start)) + goto invalid_offset; dieoff = attr->cu->start + op->number2; break; -- 1.8.3.1