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