Blame SOURCES/kvm-target-s390x-arch_dump-Fix-memory-corruption-in-s390.patch

ed5979
From b330bf0a2ad5af73d3c62997f7f0fa5b61f1796b Mon Sep 17 00:00:00 2001
ed5979
From: Thomas Huth <thuth@redhat.com>
ed5979
Date: Tue, 14 Feb 2023 14:48:37 +0100
ed5979
Subject: [PATCH 8/8] target/s390x/arch_dump: Fix memory corruption in
ed5979
 s390x_write_elf64_notes()
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Thomas Huth <thuth@redhat.com>
ed5979
RH-MergeRequest: 152: Fix memory corruption in s390x_write_elf64_notes()
ed5979
RH-Bugzilla: 2168172
ed5979
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ed5979
RH-Acked-by: David Hildenbrand <david@redhat.com>
ed5979
RH-Acked-by: Cédric Le Goater <clg@redhat.com>
ed5979
RH-Commit: [1/1] 37a2c997b2c8b7524e0b6299891bf3ea7c9a46d0 (thuth/qemu-kvm-cs9)
ed5979
ed5979
Bugzilla: https://bugzilla.redhat.com/2168172
ed5979
Upstream-Status: Posted (and reviewed, but not merged yet)
ed5979
ed5979
"note_size" can be smaller than sizeof(note), so unconditionally calling
ed5979
memset(notep, 0, sizeof(note)) could cause a memory corruption here in
ed5979
case notep has been allocated dynamically, thus let's use note_size as
ed5979
length argument for memset() instead.
ed5979
ed5979
Fixes: 113d8f4e95 ("s390x: pv: Add dump support")
ed5979
Message-Id: <20230214141056.680969-1-thuth@redhat.com>
ed5979
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
ed5979
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
ed5979
Signed-off-by: Thomas Huth <thuth@redhat.com>
ed5979
---
ed5979
 target/s390x/arch_dump.c | 2 +-
ed5979
 1 file changed, 1 insertion(+), 1 deletion(-)
ed5979
ed5979
diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c
ed5979
index a2329141e8..a7c44ba49d 100644
ed5979
--- a/target/s390x/arch_dump.c
ed5979
+++ b/target/s390x/arch_dump.c
ed5979
@@ -248,7 +248,7 @@ static int s390x_write_elf64_notes(const char *note_name,
ed5979
             notep = g_malloc(note_size);
ed5979
         }
ed5979
 
ed5979
-        memset(notep, 0, sizeof(note));
ed5979
+        memset(notep, 0, note_size);
ed5979
 
ed5979
         /* Setup note header data */
ed5979
         notep->hdr.n_descsz = cpu_to_be32(content_size);
ed5979
-- 
ed5979
2.31.1
ed5979