bad/missing unwind information, which could result in libunwind
dereferencing bad pointers. This mechanism is based on msync(2) system
call and significantly reduces the chances of a bad pointer
dereference in libunwind.
The original idea was to turn this mechanism on only when necessary
i.e. libunwind didn't find proper unwind information for a IP.
There are a couple of problems in the current implementation.
* The flag is global and is modified without locking
* The flag isn't reset when starting a new unwind
The attached patch makes ->validate a per-thread setting by moving it
into struct cursor from unw_local_addr_space and resets it to false
when starting a new unwind. As a result, cursor->as_arg points to the
cursor itself instead of the ucontext (for the local case).
This was found to reduce the number of msync() system calls from an
application using libunwind significantly.
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
* src/arm/unwind_i (arm_lock, arm_local_resume): Define.
* src/ptrace/_UPT_find_proc_info.c: Handle ARM like X86 etc.
* tests/flush-cache.S (flush_cache): Add (dummy) ARM-version.
ARM does need executable stack, even on Linux...
Signed-off-by: Anderson Lizardo <anderson.lizardo@indt.org.br>
Signed-off-by: Bruna Moreira <bruna.moreira@indt.org.br>
The current pattern is too restrictive and doesn't work well on
modern glibcs.
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
* Use explicit types for XMM registers
* Support full width (128 bits) access
Signed-off-by: Andrew Cagney <cagney@redhat.com>
Signed-off-by: Arun Sharma <aruns@google.com>
as "weak". Since the elf-support is in the library anyhow, this serves
no purpose and in fact causes problem because the weak reference alone
is not enough to pull in the ELF-code from an archive file, causing to
spurious failures of get_proc_name.
On some systems executable stacks are denied. Since libunwind and the
tests don't actually need executable stacks this patch marks all
assembly files as not needing it.
The original patch comes from frysk:
2007-04-05 Jan Kratochvil <jan.kratochvil@redhat.com>
* src/hppa/getcontext.S, src/hppa/setcontext.S, src/hppa/siglongjmp.S,
src/ia64/Ginstall_cursor.S, src/ia64/Linstall_cursor.S,
src/ia64/dyn_info_list.S, src/ia64/getcontext.S, src/ia64/longjmp.S,
src/ia64/setjmp.S, src/ia64/siglongjmp.S, src/ia64/sigsetjmp.S,
src/ppc64/longjmp.S, src/ppc64/siglongjmp.S, src/x86/longjmp.S,
src/x86/siglongjmp.S, src/x86_64/longjmp.S, src/x86_64/setcontext.S,
src/x86_64/siglongjmp.S: Stack should be non-executable, for SELinux.
I added a couple more markers for new files in current libunwind.
Before this patch you would get the following on selinux enabled
systems without allow_exec_stack: error while loading shared
libraries:
libunwind.so.7: cannot enable executable stack as shared object
requires: Permission denied
After the patch that error disappears and all test results are similar
to the results on systems without executable stack protection.
routine and add address-space argument. This is needed because on
PPC64, a the function-name symbol refers to a function descriptor
(unlike, for example, on ia64, where the @fptr() operator is needed to
refer to a function descriptor). Thus, in order to look up the name
of a function, we need to dereference the function descriptor. To
make matters more "interesting", the function descriptors are normally
resolved by the dynamic linker, so we can't get their values from the
ELF file. Instead, we have to read them from the running image, hence
the need for the address-space argument.
This is so that the source file gets distributed and _ucontext_i.h is
generated properly on the target machine.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
When libunwind is linked with a C++ program that throws exceptions,
the exception that's thrown is passed in %rax. However, libc's
setcontext clears %rax, causing problems.
This patch implements a setcontext that doesn't clobber rax.
TBD: Add dwarf CFI annotations
Signed-off-by: Arun Sharma <arun.sharma@google.com>
Yes, it casts to signed, but then converts right back to
unsigned via the return type. Fixed thus.
Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
CFA should be incremented by 16 in the hope that the previous frame
may have valid unwind info.
Also increase the default frame pointer recognition heuristic from 4k
to 16k.
Signed-off-by: Andrey Veskov <Andrey.Veskov@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
Now that dwarf_find_save_locs() not just finds the save-locations but
also updates the cursor-state, document this fact (the function really
is misnamed now).
Be sure to clear pi->unwind_info when looking up the kernel table and
not needing the unwind-info. Otherwise, _UPT_put_unwind_info() may
erroneously call free() on the pointer, even though that space wasn't
malloc'd, leading to crashes..
(maps_next): After reading less than a full buffer of data, copy
remaining data to the top of the buffer so as to maintain the
invariant that all data between mi->buf and mi->buf_end is valid.
This avoids maps_next() parsing uninitialized data.
(get_initial_stack_pointers): Likewise.
(unw_init_local): Use new functions to make code more readable and add
Linux kernel support.
(Logical change 1.296)
Include "libunwind_i.h" instead of "internal.h" and "tdep.h".
Define rbs_cover_and_flush() only for the !UNW_REMOTE_ONLY case.
(ia64_is_big_endian): New macro.
(ia64_get_abi): Likewise.
(ia64_set_abi): Likewise.
(ia64_get_abi_marker): Likewise.
(Logical change 1.294)
Use ia64_get_abi_marker() instead of directly referencing c->last_abi_marker.
(linux_scratch_loc): When accessing an fp-reg, default to IA64_FPREG_LOC.
Handle more registers for the Linux interrupt-frame case.
(tdep_access_reg): Use ia64_get_abi() instead of c->as->abi.
Use ia64_is_big_endian() instead of c->as->big_endian.
(Logical change 1.294)