This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix stack buffer overflow in aarch64_extract_return_value
- From: Yao Qi <qiyao at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 16 Nov 2015 15:37:32 -0000
- Subject: [binutils-gdb] Fix stack buffer overflow in aarch64_extract_return_value
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db3516bbfabe710a0292f642cb83b95ea24c323a
commit db3516bbfabe710a0292f642cb83b95ea24c323a
Author: Yao Qi <yao.qi@linaro.org>
Date: Mon Nov 16 15:37:03 2015 +0000
Fix stack buffer overflow in aarch64_extract_return_value
Hi,
I build GDB with -fsanitize=address, and run testsuite. In
gdb.base/callfuncs.exp, I see the following error,
p/c fun1()
=================================================================^M
==9601==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffee858530 at pc 0x6df079 bp 0x7fffee8583a0 sp 0x7fffee858398
WRITE of size 16 at 0x7fffee858530 thread T0
#0 0x6df078 in regcache_raw_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:673
#1 0x6dfe1e in regcache_cooked_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:751
#2 0x4696a3 in aarch64_extract_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1708
#3 0x46ae57 in aarch64_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1918
We are extracting return value from V registers (128 bit), but only
allocate X_REGISTER_SIZE-byte array, which isn't sufficient. This
patch changes the array to V_REGISTER_SIZE.
gdb:
2015-11-16 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_extract_return_value): Change array
buf's length to V_REGISTER_SIZE.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/aarch64-tdep.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 30ae510..fd2ac45 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2015-11-16 Yao Qi <yao.qi@linaro.org>
+ * aarch64-tdep.c (aarch64_extract_return_value): Change array
+ buf's length to V_REGISTER_SIZE.
+
+2015-11-16 Yao Qi <yao.qi@linaro.org>
+
* aarch64-tdep.c (pass_in_x_or_stack): Change argument type
from bfd_byte * to value *. Caller updated.
(pass_in_x): Likewise.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index b025eba..de045e6 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1620,7 +1620,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
for (i = 0; i < elements; i++)
{
int regno = AARCH64_V0_REGNUM + i;
- bfd_byte buf[X_REGISTER_SIZE];
+ bfd_byte buf[V_REGISTER_SIZE];
if (aarch64_debug)
{