aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2024-10-28 17:43:09 +0100
committerHannes Domani <ssbssa@yahoo.de>2024-10-28 21:00:44 +0100
commit84786372e1c78c44f7eb1a6d098fbfdd633c0bd8 (patch)
treed36b1e45e56301dd393cba569f50431a9e4662d4 /gdb
parentf951f2dbb8f57fa6469a6935116a31004c7e373a (diff)
downloadbinutils-84786372e1c78c44f7eb1a6d098fbfdd633c0bd8.zip
binutils-84786372e1c78c44f7eb1a6d098fbfdd633c0bd8.tar.gz
binutils-84786372e1c78c44f7eb1a6d098fbfdd633c0bd8.tar.bz2
Fix size of register buffer
When calling a function with double arguments, I get this asan error: ==7920==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x0053131ece38 at pc 0x7ff79697a68f bp 0x0053131ec790 sp 0x0053131ebf40 READ of size 16 at 0x0053131ece38 thread T0 #0 0x7ff79697a68e in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long long), void const*, void const*, unsigned long long) C:/gcc/src/gcc-14.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:814 #1 0x7ff79697aebd in memcmp C:/gcc/src/gcc-14.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:845 #2 0x7ff79697aebd in memcmp C:/gcc/src/gcc-14.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:840 #3 0x7ff7927e237f in regcache::raw_write(int, gdb::array_view<unsigned char const>) C:/gdb/src/gdb.git/gdb/regcache.c:874 #4 0x7ff7927e3c85 in regcache::cooked_write(int, gdb::array_view<unsigned char const>) C:/gdb/src/gdb.git/gdb/regcache.c:914 #5 0x7ff7927e5d89 in regcache::cooked_write(int, unsigned char const*) C:/gdb/src/gdb.git/gdb/regcache.c:933 #6 0x7ff7911d5965 in amd64_windows_store_arg_in_reg C:/gdb/src/gdb.git/gdb/amd64-windows-tdep.c:216 Address 0x0053131ece38 is located in stack of thread T0 at offset 40 in frame #0 0x7ff7911d565f in amd64_windows_store_arg_in_reg C:/gdb/src/gdb.git/gdb/amd64-windows-tdep.c:208 This frame has 4 object(s): [32, 40) 'buf' (line 211) <== Memory access at offset 40 overflows this variable It's because the first 4 double arguments are passed via XMM registers, and they need a buffer of 16 bytes, even if we only use 8 bytes of them. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/amd64-windows-tdep.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 3ba2d1a..57dcc4f 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -207,7 +207,8 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache,
{
struct type *type = arg->type ();
const gdb_byte *valbuf = arg->contents ().data ();
- gdb_byte buf[8];
+ /* We only set 8 bytes, buf if it's a XMM register, 16 bytes are read. */
+ gdb_byte buf[16];
gdb_assert (type->length () <= 8);
memset (buf, 0, sizeof buf);