|
|
0727d3 |
From 24af433728429578e586d179e27451b7d4a46cba Mon Sep 17 00:00:00 2001
|
|
|
0727d3 |
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
|
|
|
0727d3 |
Date: Thu, 18 Nov 2021 12:57:33 +0100
|
|
|
0727d3 |
Subject: [PATCH 3/3] tests/qtest/fdc-test: Add a regression test for
|
|
|
0727d3 |
CVE-2021-3507
|
|
|
0727d3 |
MIME-Version: 1.0
|
|
|
0727d3 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0727d3 |
Content-Transfer-Encoding: 8bit
|
|
|
0727d3 |
|
|
|
0727d3 |
RH-Author: Jon Maloy <jmaloy@redhat.com>
|
|
|
0727d3 |
RH-MergeRequest: 194: hw/block/fdc: Prevent end-of-track overrun (CVE-2021-3507)
|
|
|
0727d3 |
RH-Commit: [2/2] 31ec71276b521b06d4142fffa88a3fa4d1494d92 (jmaloy/qemu-kvm)
|
|
|
0727d3 |
RH-Bugzilla: 1951521
|
|
|
0727d3 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
0727d3 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
0727d3 |
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
0727d3 |
|
|
|
0727d3 |
Add the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/339
|
|
|
0727d3 |
|
|
|
0727d3 |
Without the previous commit, when running 'make check-qtest-i386'
|
|
|
0727d3 |
with QEMU configured with '--enable-sanitizers' we get:
|
|
|
0727d3 |
|
|
|
0727d3 |
==4028352==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x619000062a00 at pc 0x5626d03c491a bp 0x7ffdb4199410 sp 0x7ffdb4198bc0
|
|
|
0727d3 |
READ of size 786432 at 0x619000062a00 thread T0
|
|
|
0727d3 |
#0 0x5626d03c4919 in __asan_memcpy (qemu-system-i386+0x1e65919)
|
|
|
0727d3 |
#1 0x5626d1c023cc in flatview_write_continue softmmu/physmem.c:2787:13
|
|
|
0727d3 |
#2 0x5626d1bf0c0f in flatview_write softmmu/physmem.c:2822:14
|
|
|
0727d3 |
#3 0x5626d1bf0798 in address_space_write softmmu/physmem.c:2914:18
|
|
|
0727d3 |
#4 0x5626d1bf0f37 in address_space_rw softmmu/physmem.c:2924:16
|
|
|
0727d3 |
#5 0x5626d1bf14c8 in cpu_physical_memory_rw softmmu/physmem.c:2933:5
|
|
|
0727d3 |
#6 0x5626d0bd5649 in cpu_physical_memory_write include/exec/cpu-common.h:82:5
|
|
|
0727d3 |
#7 0x5626d0bd0a07 in i8257_dma_write_memory hw/dma/i8257.c:452:9
|
|
|
0727d3 |
#8 0x5626d09f825d in fdctrl_transfer_handler hw/block/fdc.c:1616:13
|
|
|
0727d3 |
#9 0x5626d0a048b4 in fdctrl_start_transfer hw/block/fdc.c:1539:13
|
|
|
0727d3 |
#10 0x5626d09f4c3e in fdctrl_write_data hw/block/fdc.c:2266:13
|
|
|
0727d3 |
#11 0x5626d09f22f7 in fdctrl_write hw/block/fdc.c:829:9
|
|
|
0727d3 |
#12 0x5626d1c20bc5 in portio_write softmmu/ioport.c:207:17
|
|
|
0727d3 |
|
|
|
0727d3 |
0x619000062a00 is located 0 bytes to the right of 512-byte region [0x619000062800,0x619000062a00)
|
|
|
0727d3 |
allocated by thread T0 here:
|
|
|
0727d3 |
#0 0x5626d03c66ec in posix_memalign (qemu-system-i386+0x1e676ec)
|
|
|
0727d3 |
#1 0x5626d2b988d4 in qemu_try_memalign util/oslib-posix.c:210:11
|
|
|
0727d3 |
#2 0x5626d2b98b0c in qemu_memalign util/oslib-posix.c:226:27
|
|
|
0727d3 |
#3 0x5626d09fbaf0 in fdctrl_realize_common hw/block/fdc.c:2341:20
|
|
|
0727d3 |
#4 0x5626d0a150ed in isabus_fdc_realize hw/block/fdc-isa.c:113:5
|
|
|
0727d3 |
#5 0x5626d2367935 in device_set_realized hw/core/qdev.c:531:13
|
|
|
0727d3 |
|
|
|
0727d3 |
SUMMARY: AddressSanitizer: heap-buffer-overflow (qemu-system-i386+0x1e65919) in __asan_memcpy
|
|
|
0727d3 |
Shadow bytes around the buggy address:
|
|
|
0727d3 |
0x0c32800044f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
0727d3 |
0x0c3280004510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
0727d3 |
0x0c3280004520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
0727d3 |
0x0c3280004530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
0727d3 |
=>0x0c3280004540:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004560: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004570: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
|
|
0727d3 |
0x0c3280004590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
|
|
|
0727d3 |
Shadow byte legend (one shadow byte represents 8 application bytes):
|
|
|
0727d3 |
Addressable: 00
|
|
|
0727d3 |
Heap left redzone: fa
|
|
|
0727d3 |
Freed heap region: fd
|
|
|
0727d3 |
==4028352==ABORTING
|
|
|
0727d3 |
|
|
|
0727d3 |
[ kwolf: Added snapshot=on to prevent write file lock failure ]
|
|
|
0727d3 |
|
|
|
0727d3 |
Reported-by: Alexander Bulekov <alxndr@bu.edu>
|
|
|
0727d3 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
0727d3 |
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
|
|
|
0727d3 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0727d3 |
(cherry picked from commit 46609b90d9e3a6304def11038a76b58ff43f77bc)
|
|
|
0727d3 |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
0727d3 |
---
|
|
|
0727d3 |
tests/qtest/fdc-test.c | 21 +++++++++++++++++++++
|
|
|
0727d3 |
1 file changed, 21 insertions(+)
|
|
|
0727d3 |
|
|
|
0727d3 |
diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c
|
|
|
0727d3 |
index 8f6eee84a4..6f5850354f 100644
|
|
|
0727d3 |
--- a/tests/qtest/fdc-test.c
|
|
|
0727d3 |
+++ b/tests/qtest/fdc-test.c
|
|
|
0727d3 |
@@ -583,6 +583,26 @@ static void test_cve_2021_20196(void)
|
|
|
0727d3 |
qtest_quit(s);
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
+static void test_cve_2021_3507(void)
|
|
|
0727d3 |
+{
|
|
|
0727d3 |
+ QTestState *s;
|
|
|
0727d3 |
+
|
|
|
0727d3 |
+ s = qtest_initf("-nographic -m 32M -nodefaults "
|
|
|
0727d3 |
+ "-drive file=%s,format=raw,if=floppy,snapshot=on",
|
|
|
0727d3 |
+ test_image);
|
|
|
0727d3 |
+ qtest_outl(s, 0x9, 0x0a0206);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x1600);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0200);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0200);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_outw(s, 0x3f4, 0x0000);
|
|
|
0727d3 |
+ qtest_quit(s);
|
|
|
0727d3 |
+}
|
|
|
0727d3 |
+
|
|
|
0727d3 |
int main(int argc, char **argv)
|
|
|
0727d3 |
{
|
|
|
0727d3 |
int fd;
|
|
|
0727d3 |
@@ -614,6 +634,7 @@ int main(int argc, char **argv)
|
|
|
0727d3 |
qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19);
|
|
|
0727d3 |
qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
|
|
|
0727d3 |
qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196);
|
|
|
0727d3 |
+ qtest_add_func("/fdc/fuzz/cve_2021_3507", test_cve_2021_3507);
|
|
|
0727d3 |
|
|
|
0727d3 |
ret = g_test_run();
|
|
|
0727d3 |
|
|
|
0727d3 |
--
|
|
|
0727d3 |
2.35.3
|
|
|
0727d3 |
|