OSDN Git Service

target/s390x/arch_dump: Fix memory corruption in s390x_write_elf64_notes()
authorThomas Huth <thuth@redhat.com>
Tue, 14 Feb 2023 14:10:56 +0000 (15:10 +0100)
committerThomas Huth <thuth@redhat.com>
Mon, 27 Feb 2023 08:15:38 +0000 (09:15 +0100)
commiteb60026120081430d554c9cabaa36c4ac271fce0
treee52a6e5393cd45c43968d5aa74159eaee2c8a41e
parentecba64689596614112b662d0579d097fa5cfd5d5
target/s390x/arch_dump: Fix memory corruption in s390x_write_elf64_notes()

"note_size" can be smaller than sizeof(note), so unconditionally calling
memset(notep, 0, sizeof(note)) could cause a memory corruption here in
case notep has been allocated dynamically, thus let's use note_size as
length argument for memset() instead.

Reported-by: Sebastian Mitterle <smitterl@redhat.com>
Fixes: 113d8f4e95 ("s390x: pv: Add dump support")
Message-Id: <20230214141056.680969-1-thuth@redhat.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
target/s390x/arch_dump.c