diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2017-04-05 11:12:58 -0700 |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2017-04-05 11:14:04 -0700 |
commit | 7a7833ee0ac287beba23f4a1f50f23928e2a5427 (patch) | |
tree | 6e3b521b048ff01be62a207444677ca6d0a619a6 /include | |
parent | 982e93495123635a463b1828e197cd0f027770cb (diff) | |
download | libunwind-7a7833ee0ac287beba23f4a1f50f23928e2a5427.tar.gz |
ppc: return UNW_INVALID instead of assert on unaligned addresses
In src/ppc64/Gstep.c, we use fetch32 to fetch instruction from the
inferior process. In UNW_REMOTE case, fetch32 asserts that the
address we are fetching from is aligned.
But if the inferior is corrupt, we can get unaligned IP, and hit the assert.
Attached patch removes the assert, and makes fetch32 (and fetch16)
return -UNW_EINVAL instead.
Diffstat (limited to 'include')
-rw-r--r-- | include/remote.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/remote.h b/include/remote.h index 6fdf64c1..d8daeec7 100644 --- a/include/remote.h +++ b/include/remote.h @@ -74,7 +74,8 @@ fetch16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; int ret; - assert ((off & 0x1) == 0); + if ((off & 0x1) == 0) + return -UNW_EINVAL; *addr += 2; @@ -96,7 +97,8 @@ fetch32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; int ret; - assert ((off & 0x3) == 0); + if ((off & 0x3) == 0) + return -UNW_EINVAL; *addr += 4; |