Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hw/misc/npcm_clk: fix buffer-overflow
Regression introduced by cf76c4 (hw/misc: Add nr_regs and cold_reset_values to NPCM CLK) cold_reset_values has a different size, depending on device used (NPCM7xx vs NPCM8xx). However, s->regs has a fixed size, which matches NPCM8xx. Thus, when initializing a NPCM7xx, we go past cold_reset_values ending. Report by asan: ==2066==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55d68a3e97f0 at pc 0x7fcaf2b2d14b bp 0x7ffff0cc3890 sp 0x7ffff0cc3040 READ of size 196 at 0x55d68a3e97f0 thread T0 #0 0x7fcaf2b2d14a in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827 qemu#1 0x55d688447e0d in memcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29 qemu#2 0x55d688447e0d in npcm_clk_enter_reset ../hw/misc/npcm_clk.c:968 qemu#3 0x55d6899b7213 in resettable_phase_enter ../hw/core/resettable.c:136 qemu#4 0x55d6899a1ef7 in bus_reset_child_foreach ../hw/core/bus.c:97 qemu#5 0x55d6899b717d in resettable_child_foreach ../hw/core/resettable.c:92 qemu#6 0x55d6899b717d in resettable_phase_enter ../hw/core/resettable.c:129 qemu#7 0x55d6899b4ead in resettable_container_child_foreach ../hw/core/resetcontainer.c:54 qemu#8 0x55d6899b717d in resettable_child_foreach ../hw/core/resettable.c:92 qemu#9 0x55d6899b717d in resettable_phase_enter ../hw/core/resettable.c:129 qemu#10 0x55d6899b7bfa in resettable_assert_reset ../hw/core/resettable.c:55 qemu#11 0x55d6899b8666 in resettable_reset ../hw/core/resettable.c:45 qemu#12 0x55d688d15cd2 in qemu_system_reset ../system/runstate.c:527 qemu#13 0x55d687fc5edd in qdev_machine_creation_done ../hw/core/machine.c:1738 qemu#14 0x55d688d209bd in qemu_machine_creation_done ../system/vl.c:2779 qemu#15 0x55d688d209bd in qmp_x_exit_preconfig ../system/vl.c:2807 qemu#16 0x55d688d281fb in qemu_init ../system/vl.c:3838 qemu#17 0x55d687ceab12 in main ../system/main.c:68 qemu#18 0x7fcaef006249 (/lib/x86_64-linux-gnu/libc.so.6+0x27249) qemu#19 0x7fcaef006304 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27304) qemu#20 0x55d687cf0010 in _start (/home/runner/work/qemu-ci/qemu-ci/build/qemu-system-arm+0x371c010) 0x55d68a3e97f0 is located 0 bytes to the right of global variable 'npcm7xx_cold_reset_values' defined in '../hw/misc/npcm_clk.c:134:23' (0x55d68a3e9780) of size 112 Impacted tests: Summary of Failures: check: 2/747 qemu:qtest+qtest-aarch64 / qtest-aarch64/qom-test ERROR 9.28s killed by signal 6 SIGABRT 4/747 qemu:qtest+qtest-arm / qtest-arm/qom-test ERROR 7.82s killed by signal 6 SIGABRT 32/747 qemu:qtest+qtest-aarch64 / qtest-aarch64/device-introspect-test ERROR 10.91s killed by signal 6 SIGABRT 35/747 qemu:qtest+qtest-arm / qtest-arm/device-introspect-test ERROR 11.33s killed by signal 6 SIGABRT 114/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_pwm-test ERROR 0.98s killed by signal 6 SIGABRT 115/747 qemu:qtest+qtest-aarch64 / qtest-aarch64/test-hmp ERROR 2.95s killed by signal 6 SIGABRT 117/747 qemu:qtest+qtest-arm / qtest-arm/test-hmp ERROR 2.54s killed by signal 6 SIGABRT 151/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_watchdog_timer-test ERROR 0.96s killed by signal 6 SIGABRT 247/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_adc-test ERROR 0.96s killed by signal 6 SIGABRT 248/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_gpio-test ERROR 1.05s killed by signal 6 SIGABRT 249/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_rng-test ERROR 0.97s killed by signal 6 SIGABRT 250/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_sdhci-test ERROR 0.97s killed by signal 6 SIGABRT 251/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_smbus-test ERROR 0.89s killed by signal 6 SIGABRT 252/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_timer-test ERROR 1.09s killed by signal 6 SIGABRT 253/747 qemu:qtest+qtest-arm / qtest-arm/npcm_gmac-test ERROR 1.12s killed by signal 6 SIGABRT 255/747 qemu:qtest+qtest-arm / qtest-arm/npcm7xx_emc-test ERROR 1.05s killed by signal 6 SIGABRT check-functional: 22/203 qemu:func-thorough+func-arm-thorough+thorough / func-arm-arm_quanta_gsj ERROR 0.79s exit status 1 38/203 qemu:func-quick+func-aarch64 / func-aarch64-migration ERROR 1.97s exit status 1 45/203 qemu:func-quick+func-arm / func-arm-migration ERROR 1.90s exit status 1 Signed-off-by: Pierrick Bouvier <[email protected]>
- Loading branch information