Fix issues with unaligned memory bus rd/wr. Improve fuzzing.

This commit is contained in:
Toby Jaffey 2025-12-14 18:35:00 +00:00
parent 5fb03b7d66
commit e5fd17aff6
5 changed files with 70 additions and 15 deletions

View file

@ -1,6 +1,6 @@
TOPDIR=../..
all:
afl-clang-fast -g3 -fsanitize=address,undefined -Wall -DUVM32_MEMORY_SIZE=8388608 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-fuzz ${TOPDIR}/uvm32/uvm32.c fuzz.c
afl-clang-fast -g3 -fsanitize=address,undefined -Wall -DUVM32_MEMORY_SIZE=4096 -I${TOPDIR}/uvm32 -I${TOPDIR}/common -o host-fuzz ${TOPDIR}/uvm32/uvm32.c fuzz.c
afl-fuzz -i${TOPDIR}/precompiled -oo ./host-fuzz
clean:

View file

@ -9,14 +9,19 @@ __AFL_FUZZ_INIT();
int main(int argc, char *argv[]) {
__AFL_INIT();
uvm32_state_t vmst;
uvm32_evt_t evt;
uvm32_init(&vmst);
unsigned char *rom = __AFL_FUZZ_TESTCASE_BUF;
while (__AFL_LOOP(10000)) {
uvm32_load(&vmst, rom, __AFL_FUZZ_TESTCASE_LEN);
uvm32_run(&vmst, &evt, 1000);
uvm32_state_t *vmst = malloc(sizeof(uvm32_state_t));
while (__AFL_LOOP(100000)) {
memset(vmst, 0x00, sizeof(uvm32_state_t));
uvm32_init(vmst);
unsigned char *rom = __AFL_FUZZ_TESTCASE_BUF;
uvm32_load(vmst, rom, __AFL_FUZZ_TESTCASE_LEN);
memset(&evt, 0x00, sizeof(evt));
for (int i=0;i<10;i++) {
uvm32_run(vmst, &evt, 1000);
}
}
return 0;