summaryrefslogtreecommitdiffstats
path: root/tests/qtest/intel-hda-test.c
diff options
context:
space:
mode:
authorPeter Maydell2022-03-22 21:45:30 +0100
committerPeter Maydell2022-03-22 21:45:30 +0100
commitb7a3a705b644495b7b578e94e0e9dedf93c4f661 (patch)
tree2ccf1c628400111f5b0f5069c3452534756e87e8 /tests/qtest/intel-hda-test.c
parentMerge tag 'fixes-pull-request' of gitlab.com:marcandre.lureau/qemu into staging (diff)
parenttests/qtest/fuzz-sdcard-test: Add reproducer for OSS-Fuzz (Issue 29225) (diff)
downloadqemu-b7a3a705b644495b7b578e94e0e9dedf93c4f661.tar.gz
qemu-b7a3a705b644495b7b578e94e0e9dedf93c4f661.tar.xz
qemu-b7a3a705b644495b7b578e94e0e9dedf93c4f661.zip
Merge tag 'pull-request-2022-03-21' of https://gitlab.com/thuth/qemu into staging
* Fix stack-overflow due to recursive DMA in intel-hda (CVE-2021-3611) * Fix heap overflow due to recursive DMA in sdhci code # gpg: Signature made Mon 21 Mar 2022 16:14:36 GMT # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full] # gpg: aka "Thomas Huth <thuth@redhat.com>" [full] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2022-03-21' of https://gitlab.com/thuth/qemu: tests/qtest/fuzz-sdcard-test: Add reproducer for OSS-Fuzz (Issue 29225) hw/sd/sdhci: Prohibit DMA accesses to devices hw/sd/sdhci: Honor failed DMA transactions tests/qtest/intel-hda-test: Add reproducer for issue #542 hw/audio/intel-hda: Restrict DMA engine to memories (not MMIO devices) hw/audio/intel-hda: Do not ignore DMA overrun errors softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR softmmu/physmem: Simplify flatview_write and address_space_access_valid Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qtest/intel-hda-test.c')
-rw-r--r--tests/qtest/intel-hda-test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/qtest/intel-hda-test.c b/tests/qtest/intel-hda-test.c
index fc25ccc33c..a58c98e4d1 100644
--- a/tests/qtest/intel-hda-test.c
+++ b/tests/qtest/intel-hda-test.c
@@ -29,11 +29,45 @@ static void ich9_test(void)
qtest_end();
}
+/*
+ * https://gitlab.com/qemu-project/qemu/-/issues/542
+ * Used to trigger:
+ * AddressSanitizer: stack-overflow
+ */
+static void test_issue542_ich6(void)
+{
+ QTestState *s;
+
+ s = qtest_init("-nographic -nodefaults -M pc-q35-6.2 "
+ "-device intel-hda,id=" HDA_ID CODEC_DEVICES);
+
+ qtest_outl(s, 0xcf8, 0x80000804);
+ qtest_outw(s, 0xcfc, 0x06);
+ qtest_bufwrite(s, 0xff0d060f, "\x03", 1);
+ qtest_bufwrite(s, 0x0, "\x12", 1);
+ qtest_bufwrite(s, 0x2, "\x2a", 1);
+ qtest_writeb(s, 0x0, 0x12);
+ qtest_writeb(s, 0x2, 0x2a);
+ qtest_outl(s, 0xcf8, 0x80000811);
+ qtest_outl(s, 0xcfc, 0x006a4400);
+ qtest_bufwrite(s, 0x6a44005a, "\x01", 1);
+ qtest_bufwrite(s, 0x6a44005c, "\x02", 1);
+ qtest_bufwrite(s, 0x6a442050, "\x00\x00\x44\x6a", 4);
+ qtest_bufwrite(s, 0x6a44204a, "\x01", 1);
+ qtest_bufwrite(s, 0x6a44204c, "\x02", 1);
+ qtest_bufwrite(s, 0x6a44005c, "\x02", 1);
+ qtest_bufwrite(s, 0x6a442050, "\x00\x00\x44\x6a", 4);
+ qtest_bufwrite(s, 0x6a44204a, "\x01", 1);
+ qtest_bufwrite(s, 0x6a44204c, "\x02", 1);
+ qtest_quit(s);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
qtest_add_func("/intel-hda/ich6", ich6_test);
qtest_add_func("/intel-hda/ich9", ich9_test);
+ qtest_add_func("/intel-hda/fuzz/issue542", test_issue542_ich6);
return g_test_run();
}