Bugzilla component missing and another (minor) fuzzing-related bug report
by Hanno Böck
Hi,
The elfutils webpage says:
"To report bugs: please open a bugzilla report against the elfutils
component."
However it seems the redhat bugzilla doesn't have an elfutils
component. Therefore I'm reporting it here, hope that's okay.
The attached file will cause a huge malloc allocation with elfutils' nm
tool. This will crash if you try to run it with address sanitizer.
The reason is likely that nm will try to allocate space for something
based on the header value - no matter if that value makes any sense. A
sanity check that checks in such cases if the file itself is smaller
than the supposedly allocated memory could avoid that.
Address Sanitizer trace:
==29915==ERROR: AddressSanitizer failed to allocate 0xb18002000
(47647301632) bytes of LargeMmapAllocator: 12
==19508==AddressSanitizer CHECK
failed: /var/tmp/portage/sys-devel/gcc-4.9.2/work/gcc-4.9.2/libsanitizer/sanitizer_common/sanitizer_posix.cc:66
"(("unable to mmap" && 0)) != (0)" (0x0, 0x0) #0 0x7f1a5001df90
(/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x5cf90) #1
0x7f1a500221f3 in __sanitizer::CheckFailed(char const*, int, char
const*, unsigned long long, unsigned long long)
(/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x611f3) #2
0x7f1a50027041
(/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x66041) #3
0x7f1a4ffddad8
(/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x1cad8) #4
0x7f1a5001868f in malloc
(/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x5768f) #5
0x41a421 in xmalloc /f/elfutils/elfutils-0.163/lib/xmalloc.c:52 #6
0x4089a4 in show_symbols /f/elfutils/elfutils-0.163/src/nm.c:1212 #7
0x40ce47 in handle_elf /f/elfutils/elfutils-0.163/src/nm.c:1484 #8
0x4033a6 in process_file /f/elfutils/elfutils-0.163/src/nm.c:387 #9
0x4033a6 in main /f/elfutils/elfutils-0.163/src/nm.c:248 #10
0x7f1a4f2cef9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f) #11
0x40438e (/old-ram/elfutils/nm+0x40438e)
--
Hanno Böck
http://hboeck.de/
mail/jabber: hanno(a)hboeck.de
GPG: BBB51E42
7 years, 11 months
Add more files to .gitignore
by Pino Toscano
Hi,
while working on the previous patches, I noticed a number of generated
files are not part of .gitignore, so git shows them in the status
output.
Attached there is a patch for it to ignore most of them.
Thanks,
--
Pino Toscano
8 years, 2 months
Fix build and tests on non-Linux (Hurd)
by Pino Toscano
Hi,
I've worked to make elfutils from git be able to build again on
non-Linux OSes, and hopefully have all the tests passing.
My reference OS for this was GNU/Hurd, although most of the problems
and the proposed fixes apply to any other non-Linux OS.
Attached there are git commits for the issues trivial hopefully enough.
For the issues that I'm describing below, I'm happy to provide more
patches, after agreeing on the best way to fix each.
* Build
With the provided commits, most of sources (including tests) build
again.
The remaining issue is in src/strings.c, the unconditional usage of
MAP_POPULATE. which is Linux-only. A local workaround of defining it
to 0 if not already defined seemed to not cause further issues.
* Tests
Most of the tests pass, and what does not are the following:
| FAIL: run-native-test.sh
| FAIL: dwfl-bug-fd-leak
| SKIP: run-backtrace-native.sh
| SKIP: run-backtrace-data.sh
| SKIP: run-backtrace-dwarf.sh
| SKIP: run-backtrace-native-biarch.sh
| SKIP: run-backtrace-native-core.sh
| SKIP: run-backtrace-native-core-biarch.sh
| SKIP: run-backtrace-core-x86_64.sh
| SKIP: run-backtrace-core-x32.sh
| SKIP: run-backtrace-core-i386.sh
| SKIP: run-backtrace-core-ppc.sh
| SKIP: run-backtrace-core-s390x.sh
| SKIP: run-backtrace-core-s390.sh
| SKIP: run-backtrace-core-aarch64.sh
| FAIL: run-deleted.sh
| SKIP: vdsosyms
The skipped tests look correct though. Let's analyze the failing tests:
| FAIL: run-native-test.sh
| ========================
|
| SRCDIR/tests/allregs: dwfl_module_register_names: no error
allregs relies on the kernel modules handling, which is non-functional
since there are no "kernel modules" on the Hurd (microkernel with
userspace servers). I get a clearer error message about this with:
diff --git a/tests/allregs.c b/tests/allregs.c
index 901d4e8..d3d459e 100644
--- a/tests/allregs.c
+++ b/tests/allregs.c
@@ -158,6 +158,8 @@ main (int argc, char **argv)
Dwfl_Module *mod = NULL;
if (dwfl_getmodules (dwfl, &first_module, &mod, 0) < 0)
error (EXIT_FAILURE, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+ if (mod == NULL)
+ error (EXIT_FAILURE, 0, "dwfl_getmodules: module not found");
if (remaining == argc)
{
Also, if I comment out the usage of allregs from run-native-test.sh,
the test passes.
| FAIL: dwfl-bug-fd-leak
| ======================
|
| (empty)
This test actually crashes on Hurd, as the dwfl_addrmodule() at
dwfl-bug-fd-leak.c:68 returns null. This is most probably due to our
procfs emulation not showing yet filenames in /proc/$pid/maps files.
At least the patch below avoids the segfault of the test, still leaving
the failure:
diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
index 170a61a..f992b7a 100644
--- a/tests/dwfl-bug-fd-leak.c
+++ b/tests/dwfl-bug-fd-leak.c
@@ -65,7 +65,10 @@ elfutils_open (pid_t pid, Dwarf_Addr address)
}
else
{
- Elf *elf = dwfl_module_getelf (dwfl_addrmodule (dwfl, address),
&bias);
+ Dwfl_Module *module = dwfl_addrmodule (dwfl, address);
+ if (module == NULL)
+ error (2, 0, "dwfl_addrmodule: no module available for 0x%llx",
address);
+ Elf *elf = dwfl_module_getelf (module, &bias);
if (elf == NULL)
error (2, 0, "dwfl_module_getelf: %s", dwfl_errmsg (-1));
}
| FAIL: run-deleted.sh
| ====================
|
| SRCDIR/src/stack: dwfl_linux_proc_attach pid 1491: Function not
implemented
This is because dwfl_linux_proc_attach is implemented only on Linux,
returning ENOSYS everywhere else. I made the test skipped with the
following:
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
index 790b4f4..bb306c0 100644
--- a/tests/backtrace-subr.sh
+++ b/tests/backtrace-subr.sh
@@ -74,6 +74,10 @@ check_unsupported()
echo >&2 $testname: arch not supported
exit 77
fi
+ if grep -q -E ': dwfl_linux_proc_attach pid ([[:digit:]]+): Function
not implemented$' $err; then
+ echo >&2 $testname: OS not supported
+ exit 77
+ fi
}
check_native_unsupported()
but I'm not sure that would be the correct way (especially that it
relies on the string representation of ENOSYS).
As said above, I'm available for further patches.
Thanks,
--
Pino Toscano
8 years, 3 months
Typo in DWARF_ONE_KNOWN_DW_TAG commit?
by H.J. Lu
commit 7f617347794f7d57f69d08f38c00f3f6ad221a56
Author: Petr Machata <pmachata(a)redhat.com>
Date: Wed Mar 18 19:42:02 2015 +0100
Publish known-dwarf.h
- Make the macro names properly scoped (DWARF_ALL_KNOWN_* and
DWARF_ONE_KNOWN_*).
- Simplify the calling convention: don't keep track of the comment
associated with the enumerator, always use the non-_DESC
DWARF_ONE_KNOWN_* callback.
- Install known-dwarf.h alongside libdw.h and others.
Signed-off-by: Petr Machata <pmachata(a)redhat.com>
has
-#define ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
- ALL_KNOWN_DW_TAG
-#undef ONE_KNOWN_DW_TAG
+#define DWARF_ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_TAG
+#undef DWARF_ONE_KNOWN_DW_TAG
But DWARF_ONE_KNOWN_DW_TAG is defined, but never used
while DWARF_ALL_KNOWN_DW_TAG is used, but never defined.
--
H.J.
8 years, 3 months
elfutils 0.163 released
by Mark Wielaard
A new release of elfutils is available now at:
https://fedorahosted.org/releases/e/l/elfutils/0.163/
This is a bug fix only release. With one important regression fix
introduced in elfutils 0.162.
elf_update could fail to reduce the file size on disk in some cases. The
result would still be a valid ELF file, but it would contain extra data
at the end of the ELF image (from the old file). This would make it seem
like eu-strip didn't work correctly since it would not have reduced the
file size, even though the debug sections would not be available
anymore.
This release also contains an updated Polish translation.
* NEWS *
Bug fixes only, no new features.
* GIT SHORTLOG *
Mark Wielaard (17):
libebl: SHT_(INIT|FINI|PREINIT)_ARRAY are valid targets for relocation.
po/*.po: Regenerate.
libelf: Always call ftruncate before posix_fallocate to set the right size.
libdw: Detect dwarf_formudata errors in dwarf_getmacros.
libdw: Not leak memory on error in dwarf_getpubnames.
libdwfl: Check symbol section exists and has a sane entsize in find_symtab.
libelf: Check symbol section header exists before use in nlist.
strings: Handle failure of getting section name on bogus section data.
nm: Fix typo in size check to determine whether we stack allocated memory.
libdw: Make sure the default page size is big enough to hold a Dwarf.
elflint: Only check the PT_TLS phdr if it actually exists, warn otherwise.
libelf: Don't leak memory on failure paths in elf_updatefile.
readelf: Don't leak memory on failure path in handle_gnu_hash.
libdwfl: Don't leak fname if file is main file by another name in try_open.
readelf: Make sure phdr2_mem lifetime/scope equals phdr2 pointer.
findtextrel: Don't leak memory in process_file.
Prepare 0.163 release.
Piotr Drąg (2):
Updated POTFILES.in
Updated Polish translation
8 years, 3 months
[COMMITTED] Prepare 0.163 release.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
ChangeLog | 5 +
NEWS | 4 +
config/ChangeLog | 4 +
config/elfutils.spec.in | 3 +
configure.ac | 2 +-
po/ChangeLog | 4 +
po/de.po | 909 +++++++++++++++++++++++------------------------
po/es.po | 911 ++++++++++++++++++++++++------------------------
po/ja.po | 911 ++++++++++++++++++++++++------------------------
po/pl.po | 911 ++++++++++++++++++++++++------------------------
po/uk.po | 910 +++++++++++++++++++++++------------------------
11 files changed, 2318 insertions(+), 2256 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d829783..a17f522 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-19 Mark Wielaard <mjw(a)redhat.com>
+
+ * configure.ac: Set version to 0.163.
+ * NEWS: Mention 0.163 is bug fixes only.
+
2015-06-10 Mark Wielaard <mjw(a)redhat.com>
* configure.ac: Set version to 0.162.
diff --git a/NEWS b/NEWS
index 1d2db5f..e356c8f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+Version 0.163
+
+Bug fixes only, no new features.
+
Version 0.162
libdw: Install new header elfutils/known-dwarf.h.
diff --git a/config/ChangeLog b/config/ChangeLog
index 64b58e1..00f3ddc 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-19 Mark Wielaard <mjw(a)redhat.com>
+
+ * elfutils.spec.in: Update for 0.163.
+
2015-06-11 Mark Wielaard <mjw(a)redhat.com>
* elfutils.spec.in (devel): Include elfutils/known-dwarf.h and
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index ea064bc..5407f1a 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -198,6 +198,9 @@ rm -rf ${RPM_BUILD_ROOT}
%{_libdir}/libelf.a
%changelog
+* Fri Jun 19 2015 Mark Wielaard <mjw(a)redhat.com> 0.163-1
+- Bug fixes only, no new features.
+
* Wed Jun 10 2015 Mark Wielaard <mjw(a)redhat.com> 0.162-1
- libdw: Install new header elfutils/known-dwarf.h.
dwarf.h Add preliminary DWARF5 constants DW_TAG_atomic_type,
diff --git a/configure.ac b/configure.ac
index bc9ff56..9c47a68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
-AC_INIT([elfutils],[0.162],[https://bugzilla.redhat.com/],[elfutils])
+AC_INIT([elfutils],[0.163],[https://bugzilla.redhat.com/],[elfutils])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_FILES([config/Makefile])
diff --git a/po/ChangeLog b/po/ChangeLog
index df84f2c..51034e2 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-19 Mark Wielaard <mjw(a)redhat.com>
+
+ * *.po: Update for 0.163.
+
2015-06-15 Mark Wielaard <mjw(a)redhat.com>
* *.po: Regenerate.
<-- skip regenerated .po files --->
8 years, 3 months
[PATCH] findtextrel: Don't leak memory in process_file.
by Mark Wielaard
When a files do contain textrels we fail to release the segments searched
and valgrind will show:
2,560 bytes in 16 blocks are definitely lost in loss record 1 of 1
at 0x40281B5: malloc (in vgpreload_memcheck-x86-linux.so)
by 0x804AE63: process_file (findtextrel.c:322)
by 0x804909B: main (findtextrel.c:149)
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/findtextrel.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/ChangeLog b/src/ChangeLog
index c9a237a..41e7e73 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+ * findtextrel.c (process_file): Free segments after use.
+
+2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_phdr): Make sure phdr2_mem lifetime/scope equals
phdr2 pointer.
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 264a06b..6f1a4b5 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -484,6 +484,7 @@ cannot get relocation at index %d in section %zu in '%s': %s"),
if (fd2 != -1)
close (fd2);
+ free (segments);
tdestroy (knownsrcs, noop);
return result;
--
1.8.3.1
8 years, 3 months
[PATCH] readelf: Make sure phdr2_mem lifetime/scope equals phdr2 pointer.
by Mark Wielaard
We dont' want GCC to dispose or reuse phdr2_mem stack memory while phdr2
is pointing to it.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 06d67f9..c9a237a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_phdr): Make sure phdr2_mem lifetime/scope equals
+ phdr2 pointer.
+
+2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+
* elflint.c (check_symtab): Only check the PT_TLS phdr if it actually
exists.
diff --git a/src/readelf.c b/src/readelf.c
index 9afe8db..d3c2b6b 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1315,10 +1315,10 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
{
/* Determine the segment this section is part of. */
size_t cnt2;
+ GElf_Phdr phdr2_mem;
GElf_Phdr *phdr2 = NULL;
for (cnt2 = 0; cnt2 < phnum; ++cnt2)
{
- GElf_Phdr phdr2_mem;
phdr2 = gelf_getphdr (ebl->elf, cnt2, &phdr2_mem);
if (phdr2 != NULL && phdr2->p_type == PT_LOAD
--
1.8.3.1
8 years, 3 months
[PATCH] libdwfl: Don't leak fname if file is main file by another name in try_open.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/find-debuginfo.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index ca98783..5059be6 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,9 @@
2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+ * find-debuginfo.c (try_open): Free fname on all failure paths.
+
+2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+
* dwfl_module_getdwarf.c (find_symtab): Check shdr is not NULL and
sh_entsize is not zero.
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index c523354..1faa494 100644
--- a/libdwfl/find-debuginfo.c
+++ b/libdwfl/find-debuginfo.c
@@ -1,5 +1,5 @@
/* Standard find_debuginfo callback for libdwfl.
- Copyright (C) 2005-2010, 2014 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2014, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -62,6 +62,7 @@ try_open (const struct stat64 *main_stat,
&& st.st_dev == main_stat->st_dev)
{
/* This is the main file by another name. Don't look at it again. */
+ free (fname);
close (fd);
errno = ENOENT;
fd = -1;
--
1.8.3.1
8 years, 3 months
[PATCH] readelf: Don't leak memory on failure path in handle_gnu_hash.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/readelf.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 15e6fae..b548851 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-18 Mark Wielaard <mjw(a)redhat.com>
+
+ * readelf.c (handle_gnu_hash): Free lengths on invalid_data.
+
2015-06-09 Mark Wielaard <mjw(a)redhat.com>
* addr2line.c (print_dwarf_function): Always free scopes before
diff --git a/src/readelf.c b/src/readelf.c
index b4cb3a8..9afe8db 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -3092,6 +3092,7 @@ handle_sysv_hash64 (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx)
static void
handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx)
{
+ uint32_t *lengths = NULL;
Elf_Data *data = elf_getdata (scn, NULL);
if (unlikely (data == NULL))
{
@@ -3103,6 +3104,7 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx)
if (unlikely (data->d_size < 4 * sizeof (Elf32_Word)))
{
invalid_data:
+ free (lengths);
error (0, 0, gettext ("invalid data in gnu.hash section %d"),
(int) elf_ndxscn (scn));
return;
@@ -3131,7 +3133,7 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx)
if (used_buf > data->d_size)
goto invalid_data;
- uint32_t *lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t));
+ lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t));
Elf32_Word *bitmask = &((Elf32_Word *) data->d_buf)[4];
Elf32_Word *bucket = &((Elf32_Word *) data->d_buf)[4 + bitmask_words];
--
1.8.3.1
8 years, 3 months