From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jMnLLI/PH2fTlx0AWB0awg (envelope-from ) for ; Mon, 28 Oct 2024 13:53:19 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=yahoo.de header.i=@yahoo.de header.a=rsa-sha256 header.s=s2048 header.b=ctilsWbu; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 97C911E56E; Mon, 28 Oct 2024 13:53:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BF1CD1E37A for ; Mon, 28 Oct 2024 13:53:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66C673858CD1 for ; Mon, 28 Oct 2024 17:53:17 +0000 (GMT) Received: from sonic311-31.consmr.mail.ir2.yahoo.com (sonic311-31.consmr.mail.ir2.yahoo.com [77.238.176.163]) by sourceware.org (Postfix) with ESMTPS id 023E73858D20 for ; Mon, 28 Oct 2024 17:52:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 023E73858D20 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=yahoo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yahoo.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 023E73858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=77.238.176.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137979; cv=none; b=cLsMSy8x6poGxMpI7aKlWdJY9VPV+uP2gjsXPfbRmeFnl4F3rVIFc/fWQlMAs+AYBCckEWuAIchG6PK//AmFjTxPxB5+YOVuGeQXsuIT0H+ZhjvckoEX6+G8FGF0wGqy2gGjtxM9xK9JDIq33N1c1b75ccyMUQ1a1YpaSznKv+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137979; c=relaxed/simple; bh=U25bMD/m49oN//x/UmG291yMSjM6iO54wQUeWulcwFg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GRqOY+1BaGmn/wFKC3ST6HAndkg82Lb/obdfpdwMwaGAzpqgTyLis14ZOWSoIF1RwIUrivJ7kUnqYu0CK+FB92hoLyKvq6MtnPVo/gz8Sa2HmjdlDHRv0yXxb3W9YoR8yHQXqEZy/gJ82eG+HsWJfUwN+lEo3fAhyLnQdwYnDTQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1730137976; bh=jmX18Db3PUEQ8RdcZxo6fSnyfNrp4igR7VM9GaMWb1Y=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=ctilsWbuvG/79oBlcTM9XY6oigknaWMHT7ybSGQSSvr23dPffhLo/Fp5H4BD0zErO9VPT+Zh54s/T68VaDADhzhXirKy0rd1KnSVVr97VdtMkd/OKJeW3KEaGj4p1nimH2ElHRiT/ZHLIGes8U+6+o+TBvY38LKn1D82SXQsDn5qtUjmRiJn5Zx5fx/Lbs5kTw0es38sQbT5qtY9RurzOGXagkiFuS77sYM4j6bQAyo5OD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vaDVk4tIUqcEFEy40vJxWcLet5fEIrpD2Uh7.KkTUpcR bkBxen5jnTK8jCkQXRu0JK62oL2rn0JFFUiaLbYKXE1Owuj9rPF.si5JXWPG1bLPmfWPLYuKZO2b 3zM8dVSA2aj5D1PZLIUwk6dcRJqIEA_dne5rYz1qYiG0S_psWUq68CxfBmtJx44spjWF1UQCp6vY UHnU7qYfLl8AI8eP5nzSDfAPimBU2_.kIUJirT_UZHQ709r2ZOdrbNnuaauHk9FlkS16ZejYH1YT xqQh5PrBaZ.S8p4WbFPURVqysYxj1sJ3X6jws3patHOzqqpauADSav1EIMfx7eawqagGZizPK08i KeeDht0639HsWj4PBv05o_Agu8zlyy98XnCiugKpubWxPh_Qs60ASSKXIjA0Vgosw0QM5Z8WQlsC wheJn6gBnwj7m7MpbUN_E.iWrs.yjB5rKrphLJQLBxBzFRQduvdr9RS8Y_N4nOcA6MIFlo0UTDeG NCIxR5_j2MVcTrjGeOGczHYlfsmeH4kxZKd1BMzH6KqtTQMM9CTy7c4ERAxXoqmM8lhe19SxqmtQ aWwGh67jnYY_ILbZeCuqckqckUHknjFmt2V9j7gKS4573eEC2QV4gnG.vATZ7Qc7Rg5N2ePk_AIG bmFNxfpKlHsBPve8knRwkHdgo92W3PPHvQl8titbQLTjEtVMquv34kRZlBKkEC8QqW.Y0Gx77euS K37VLg.lweQFOYFHoepHBJpGttPH60LaxLCANJUpIug-- X-Sonic-MF: X-Sonic-ID: 8acd7232-9e90-4db2-a805-876e0f115dbe Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ir2.yahoo.com with HTTP; Mon, 28 Oct 2024 17:52:56 +0000 Received: by hermes--production-ir2-c694d79d9-rpm9f (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 24007a2e764b44c57ee9316fb5ed66b5; Mon, 28 Oct 2024 17:52:53 +0000 (UTC) From: Hannes Domani To: gdb-patches@sourceware.org Subject: [PATCH] Fix size of register buffer Date: Mon, 28 Oct 2024 18:52:39 +0100 Message-Id: <20241028175239.314-1-ssbssa@yahoo.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 241028-4, 10/28/2024), Outbound message X-Antivirus-Status: Clean References: <20241028175239.314-1-ssbssa.ref@yahoo.de> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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) C:/gdb/src/gdb.git/gdb/regcache.c:874 #4 0x7ff7927e3c85 in regcache::cooked_write(int, gdb::array_view) 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. --- gdb/amd64-windows-tdep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 555e225219d..70390fcaf22 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -208,7 +208,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); -- 2.35.1