| Commit message (Collapse) | Author | Age | Files | Lines |
| |\ |
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| |\| |
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| |\|
| |
| |
| | |
Fixup futimens issues.
|
| | |
| |
| |
| |
| |
| | |
Always free the scopes returned by dwarf_getscopes () when done.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We try to handle (in-place) stripping of ar archives, but since elf_clone
doesn't really support cloning ar members and we don't handle reducing
the size of the members, moving the offsets of other members. This causes
crashes or writing garbage. Better to just admit that for now we don't
support stripping archives. Call error when we see an ELF_K_AR file.
https://bugzilla.redhat.com/show_bug.cgi?id=766156
https://lists.fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
We might jump to "out" early on error. Help gcc see that isn't an issue
by initializing dirarray to dirstack early.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
Some older gcc versions don't support -Wstack-usage. Only use it when
accepted by the compiler.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
commit c4f133 libdwfl: find_debuginfo_in_patch don't alloca/strdupa
strings of unknown size. Introduced a memory leak in the case nothing
was found. Make sure before returning all temporary strings are all
freed.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
commit be1778 libdwfl: Fix possible unbounded stack usage in cache_sections.
introduced a memory leak. The refs pointers were copied to the sortrefs
array but never freed. Only the array was freed. Also free the elements.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
elf_getdata_rawchunk might return an unaligned buffer for the requested
ELF data type. Make sure the data is also correctly aligned when using
an mmapped file. Also add some missing alignments for ELF data types
for __libelf_type_align (the missing types could also make elf_getdata
to return unaligned data).
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The gelf_xlate conversion functions work on properly aligned ELF data
types. If elf_get data needs to do conversion and ! ALLOW_UNALIGNED
and the rawdata_base isn't aligned properly for the section type, then
provide an aligned copy of the data.
Found with --enable-sanitize-undefined in run-test-archive64.sh on x86_64.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
https://bugzilla.redhat.com/show_bug.cgi?id=1139815
Signed-off-by: Yuri Chornoivan <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Yuri Chornoivan <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
We might jump to "out" early on error. Then filelist might not be set yet
and we might try to free garbage. Set it to the null_file early.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
dwfl_segment_report_module can take the NT_FILE note contents to find
the matching file for the module on the file system from the core file.
If the file exists but the build-id didn't match we would not report the
module. But we should just report the module anyway, ignore the file,
and try to match the ELF image another way.
This issue can be replicated by building and running make check in
/tmp/elfutils with run-backtrace-core-aarch64.sh since that core file
includes a NT_FILE note pointing to /tmp/elfutils/tests/backtrace-child.
Which won't match if it was just recompiled.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
In get_shnum the check was whether the Elf(32|64)_Ehdr was correctly
aligned, but to access the Shdr directly we need to check whether the
address that points to the Elf(32|64)_Shdr structure is correctly aligned.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There are various places in the code that check whether mmapped structures
are correctly aligned (or ALLOW_UNALIGNED is set). Some of these checks
are asserts. Like the one in elf(32|64)_getshdr. We should not get into
that part of the code if the shdr scn structure was cached in elf_begin
because it was mmapped in and properly aligned.
These asserts could trigger because in elf_begin.c file_read_elf ()
all alignment checks were combined. So even though only one of the ehdr,
shdr or phdr structures were not properly aligned all structures would be
copied. Also the phdr structure was not even read in elf_begin, so the
alignment check was unnecessary.
This patch splits the alignment checks and reading of ehdr and shdr
structures into separate code paths. It also drops the phdr alignment
checks in elf_begin. Those phdr checks are done in elf(32|64)_getphdr
already.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
commit c57829 introduced a memory leak by passing the path string to
strsep. strsep will change the given pointer and set it to NULL eventually.
Causing the original pointer to leak. Fix by passing a copy of the pointer
to strsep.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
We define MODVERSION to make sure the libebl backend modules match the
elfutils build when we dlopen them. Using hostname and date makes it very
hard to create reproducable builds. Define them a little more reproducable
using LIBEBL_SUBDIR, eu_version and ac_cv_build.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
The -fsanitize=undefined check need to use AC_LINK_IFELSE to make sure
libubsan is installed. When doing undefined checking we should disable
ALLOW_UNALIGNED memory accesses to catch issues where we do unaligned
accesses by accident.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
core file data isn't guaranteed to be alligned properly. Use
read_(4|8)ubyte_unaligned_noncvt to read values, types and addresses.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
When a copy needs to be made of the shdrs, allocate with malloc and free
after conversion instead of calling alloca.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
When a copy needs to be made of the phdrs, allocate with malloc and free
after conversion instead of calling alloca.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
The number of entries in the index can be large, don't use alloca to
read in temporary data, use malloc (which is freed after out).
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
When d_size is zero d_buf might be NULL.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
When size is zero the buffer src and dest buffers might be NULL.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
When d_size is zero d_buf might be NULL. last_position doesn't need to be
updated in that case.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
canonicalize_file_name is marked as taking a nonnull argument.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
Make sure the reason a test is SKIPPED is added to the test-suite.log.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Without bunzip2 make check cannot be run. To generate all files in
maintainer-mode flex and bison are needed. Otherwise check that
libdw/known-dwarf.h is already generated.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
If we are going to dereference a pointer there should be at least enough
data to hold a pointer. Found by afl-fuzz.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
If we are going to dereference a pointer there should be at least enough
data to hold a pointer. Found by afl-fuzz.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
check_module is called from dwfl_module_relocate_address and from
dwfl_module_address_section. Both could take a NULL Dwfl_Module if
an earlier error had occured. Make check_module return immediately
indicating an issue in that case.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
All library code now builds with this warning and -Werror enabled.
Add exceptions for most of the src tools (ldgeneric, readelf, nm, size,
strip, elflint, findtextrel, elfcmp objdump, ranlib, ar and unstrip).
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Limit stack usage of lines with MAX_STACK_LINES, files with MAX_STACK_LINES
and dirs with MAX_STACK_DIRS. Calculate number of dirs needed first, then
create dirarray directly, without needing the next field. Free not stack
allocated lines and files at the end.
Use preallocated stack arrays for all instead of calling alloca to help
compiler see actual stack usage.
The current stack allocation limits are 4096 lines, 1024 files in 256 dirs
per CU. For GCC 4.8 libstdc++.so has on average 512 lines per CU. With
these settings read_srclines uses max 228K of stack on x86_64.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
We cannot handle build-ids less than at least 3 or more than 64 bytes.
Very big build-ids, or very large debug search paths might have blown
up the stack.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| | |
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Don't stack allocate module name. Also fixes a latent bug (if the module
file didn't have a suffix - which is very unlikely) and an inefficiency.
We only need to substitue chars up to the suffix.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
Create a stack allocated array to hold locs. Allocate locs bigger than
the array with malloc and free them when done.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| | |
Allocate phdr and shdr unions with malloc, not alloca. Free after use.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
For modules with lots of sections cache_sections could blow up the stack
theoretically. Don't use alloca, but use malloc with explicit free.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
Normally an NT_GNU_ABI_TAG is large, just 4 words (16 bytes).
Only use stack allocated conversion buf for small (max 16 words) notes.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Help the compiler see we stack allocate a small array. Add assert to check
no machine prefix is ever larger than 16. Current maximum number is 7.
This prevents gcc warning about possible unbounded stack usage with
-Wstack-usage.
Signed-off-by: Mark Wielaard <[email protected]>
|
| | |
| |
| |
| |
| |
| |
| | |
Allocate shdr_data and scns with malloc, not alloca. Free after writing
section headers.
Signed-off-by: Mark Wielaard <[email protected]>
|