Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Commit db3516b

Browse files
author
Yao Qi
committed
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 <[email protected]> * aarch64-tdep.c (aarch64_extract_return_value): Change array buf's length to V_REGISTER_SIZE.
1 parent 8e80f9d commit db3516b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

gdb/ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-11-16 Yao Qi <[email protected]>
2+
3+
* aarch64-tdep.c (aarch64_extract_return_value): Change array
4+
buf's length to V_REGISTER_SIZE.
5+
16
2015-11-16 Yao Qi <[email protected]>
27

38
* aarch64-tdep.c (pass_in_x_or_stack): Change argument type

gdb/aarch64-tdep.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
16201620
for (i = 0; i < elements; i++)
16211621
{
16221622
int regno = AARCH64_V0_REGNUM + i;
1623-
bfd_byte buf[X_REGISTER_SIZE];
1623+
bfd_byte buf[V_REGISTER_SIZE];
16241624

16251625
if (aarch64_debug)
16261626
{

0 commit comments

Comments
 (0)