This is my fuzz.cfg file with firmware ELFs in the intended paths.
The firmware was able to be processed by qemu but AFL immediately bails out with the following logs -
cd /home/ritvik/fuzzing/nucleo-f429zi_nsh/1
./run_fw.py 0 ./inputs/seed
['/home/ritvik/qemu/precompiled_bin/qemu-system-gnuarmeclipse', '-nographic', '-board', 'STM32F429I-Discovery', '-mcu', 'STM32F429ZI', '-image', '/home/ritvik/fuzzing/nucleo-f429zi_nsh/1/nuttx', '-pm-stage', '3', '-aflFile', './inputs/seed', '-model-input', '/home/ritvik/fuzzing/nucleo-f429zi_nsh/1/0/peripheral_model.json']
(process:85200): GLib-WARNING **: /Host/Work/qemu/glib-2.51.0/glib/gmem.c:483: custom memory allocation vtable not supported
[0, 0] 1-th(total 1-th) unassigned mem_r *0x0
[0, 0] 2-th(total 2-th) unassigned mem_r *0x4
QEMU 2.3.50 monitor - type 'help' for more information
(qemu) QEMU 2.3.50 monitor - type 'help' for more information
(qemu) start up afl forkserver!
[8000254, 80002ae] 1-th(total 3-th) pm_r *0x40023800 gets 0x0, remains CR+SR
[8000254, 80002ae] 1-th(total 1-th) pm_w *0x40023800 = 0x1, remains CR+SR
[8000254, 80002ae] 2-th(total 2-th) pm_w *0x40023808 = 0x0, remains CR+SR
[8000254, 80002ae] 2-th(total 4-th) pm_r *0x40023800 gets 0x1, remains CR+SR
[8000254, 80002ae] 3-th(total 3-th) pm_w *0x40023800 = 0x1, remains CR+SR
[8000254, 80002ae] 4-th(total 4-th) pm_w *0x40023804 = 0x24003010, remains DR
[8000254, 80002ae] 3-th(total 5-th) pm_r *0x40023800 gets 0x1, remains CR+SR
[8000254, 80002ae] 5-th(total 5-th) pm_w *0x40023800 = 0x1, remains CR+SR
[8000254, 80002ae] 6-th(total 6-th) pm_w *0x4002380c = 0x0, remains DR
[800034c, 8000368] 4-th(total 6-th) pm_r *0x40023800 gets 0x1, remains CR+SR
[800034c, 8000368] 7-th(total 7-th) pm_w *0x40023800 = 0x10001, remains CR+SR
[8000368, 8000374] 5-th(total 7-th) pm_r *0x40023800 gets 0x20000, remains CR+SR
[800038a, 8000400] 6-th(total 8-th) pm_r *0x40023840 gets 0x0, remains CR
[800038a, 8000400] 8-th(total 8-th) pm_w *0x40023840 = 0x10000000, remains CR
[800038a, 8000400] 7-th(total 9-th) pm_r *0x40007000 gets 0x0, remains CR
[800038a, 8000400] 9-th(total 9-th) pm_w *0x40007000 = 0xc000, remains CR
[800038a, 8000400] 8-th(total 10-th) pm_r *0x40023808 gets 0x0, remains CR+SR
[800038a, 8000400] 10-th(total 10-th) pm_w *0x40023808 = 0x0, remains CR+SR
[800038a, 8000400] 9-th(total 11-th) pm_r *0x40023808 gets 0x0, remains CR+SR
[800038a, 8000400] 11-th(total 11-th) pm_w *0x40023808 = 0x8000, remains CR+SR
[800038a, 8000400] 10-th(total 12-th) pm_r *0x40023808 gets 0x8000, remains CR+SR
[8000400, 8000432] 12-th(total 12-th) pm_w *0x40023808 = 0x9400, remains CR+SR
[8000400, 8000432] 13-th(total 13-th) pm_w *0x40023804 = 0x7405408, remains DR
[8000400, 8000432] 11-th(total 13-th) pm_r *0x40023800 gets 0x10001, remains CR+SR
[8000400, 8000432] 14-th(total 14-th) pm_w *0x40023800 = 0x1010001, remains CR+SR
[8000400, 8000432] 12-th(total 14-th) pm_r *0x40023800 gets 0x1010001, remains CR+SR
[8000426, 8000432] 13-th(total 15-th) pm_r *0x40023800 gets 0x2000000, remains CR+SR
[8000432, 8000468] 15-th(total 15-th) pm_w *0x40023c00 = 0x605, remains DR
[8000432, 8000468] 14-th(total 16-th) pm_r *0x40023808 gets 0x9400, remains CR+SR
[8000432, 8000468] 16-th(total 16-th) pm_w *0x40023808 = 0x9402, remains CR+SR
[8000432, 8000468] 15-th(total 17-th) pm_r *0x40023808 gets 0x9402, remains CR+SR
[800045c, 8000468] 16-th(total 18-th) pm_r *0x40023808 gets 0x8, remains CR+SR
[80002c4, 80002e4] 17-th(total 19-th) pm_r *0x40023830 gets 0x0, remains CR
[80002c4, 80002e4] 17-th(total 17-th) pm_w *0x40023830 = 0x1ff, remains CR
[80002e8, 80002fc] 18-th(total 20-th) pm_r *0x40023834 gets 0x0, remains CR
[80002e8, 80002fc] 18-th(total 18-th) pm_w *0x40023834 = 0x0, remains CR
[8000304, 8000328] 19-th(total 21-th) pm_r *0x40023840 gets 0x10000000, remains CR
[8000304, 8000328] 19-th(total 19-th) pm_w *0x40023840 = 0x10040000, remains CR
[800032c, 8000348] 20-th(total 22-th) pm_r *0x40023844 gets 0x0, remains CR
[800032c, 8000348] 20-th(total 20-th) pm_w *0x40023844 = 0x4000, remains CR
[8001230, 800126a] 21-th(total 23-th) pm_r *0x40023840 gets 0x10040000, remains CR
[8001230, 800126a] 21-th(total 21-th) pm_w *0x40023840 = 0x10040000, remains CR
[800058e, 800060c] 22-th(total 24-th) pm_r *0x40020c24 gets 0x0, remains CR
[800058e, 800060c] 22-th(total 22-th) pm_w *0x40020c24 = 0x7, remains CR
[800058e, 800060c] 23-th(total 25-th) pm_r *0x40020c00 gets 0x0, remains CR
[800058e, 800060c] 23-th(total 23-th) pm_w *0x40020c00 = 0x20000, remains CR
[800062c, 8000668] 24-th(total 26-th) pm_r *0x40020c0c gets 0x0, remains CR
[800062c, 8000668] 24-th(total 24-th) pm_w *0x40020c0c = 0x10000, remains CR
[80006fe, 800074c] 25-th(total 27-th) pm_r *0x40020c08 gets 0x0, remains CR
[80006fe, 800074c] 25-th(total 25-th) pm_w *0x40020c08 = 0x30000, remains CR
[80006fe, 800074c] 26-th(total 28-th) pm_r *0x40020c04 gets 0x0, remains CR
[800076c, 8000786] 26-th(total 26-th) pm_w *0x40020c04 = 0x0, remains CR
[800058e, 800060c] 27-th(total 29-th) pm_r *0x40020c24 gets 0x7, remains CR
[800058e, 800060c] 27-th(total 27-th) pm_w *0x40020c24 = 0x77, remains CR
[800058e, 800060c] 28-th(total 30-th) pm_r *0x40020c00 gets 0x20000, remains CR
[800058e, 800060c] 28-th(total 28-th) pm_w *0x40020c00 = 0xa0000, remains CR
[800062c, 8000668] 29-th(total 31-th) pm_r *0x40020c0c gets 0x10000, remains CR
[800062c, 8000668] 29-th(total 29-th) pm_w *0x40020c0c = 0x50000, remains CR
[80006fe, 800074c] 30-th(total 32-th) pm_r *0x40020c08 gets 0x30000, remains CR
[80006fe, 800074c] 30-th(total 30-th) pm_w *0x40020c08 = 0xf0000, remains CR
[80006fe, 800074c] 31-th(total 33-th) pm_r *0x40020c04 gets 0x0, remains CR
[800076c, 8000786] 31-th(total 31-th) pm_w *0x40020c04 = 0x0, remains CR
[80008b8, 8000938] 32-th(total 34-th) pm_r *0x4000480c gets 0x0, remains CR
[80008b8, 8000938] 32-th(total 32-th) pm_w *0x4000480c = 0x0, remains CR
[80008b8, 8000938] 33-th(total 35-th) pm_r *0x40004810 gets 0x0, remains CR
[80008b8, 8000938] 33-th(total 33-th) pm_w *0x40004810 = 0x0, remains CR
[80008b8, 8000938] 34-th(total 36-th) pm_r *0x4000480c gets 0x0, remains CR
[80008b8, 8000938] 34-th(total 34-th) pm_w *0x4000480c = 0x0, remains CR
[80008b8, 8000938] 35-th(total 37-th) pm_r *0x40004814 gets 0x0, remains CR
[80008b8, 8000938] 35-th(total 35-th) pm_w *0x40004814 = 0x0, remains CR
[80008b8, 8000938] 36-th(total 36-th) pm_w *0x40004808 = 0x16d, remains DR
[80008b8, 8000938] 36-th(total 38-th) pm_r *0x4000480c gets 0x0, remains CR
[80008b8, 8000938] 37-th(total 37-th) pm_w *0x4000480c = 0x200c, remains CR
[8000954, 800096c] 37-th(total 39-th) pm_r *0x4000480c gets 0x200c, remains CR
[800096c, 800098a] 38-th(total 38-th) pm_w *0x4000480c = 0x200c, remains CR
[8000954, 800096c] 38-th(total 40-th) pm_r *0x40004814 gets 0x0, remains CR
[800096c, 800098a] 39-th(total 39-th) pm_w *0x40004814 = 0x0, remains CR
[8001230, 800126a] 39-th(total 41-th) pm_r *0x40023840 gets 0x10040000, remains CR
[8001230, 800126a] 40-th(total 40-th) pm_w *0x40023840 = 0x10040000, remains CR
[800058e, 800060c] 40-th(total 42-th) pm_r *0x40020c24 gets 0x77, remains CR
[800058e, 800060c] 41-th(total 41-th) pm_w *0x40020c24 = 0x77, remains CR
[800058e, 800060c] 41-th(total 43-th) pm_r *0x40020c00 gets 0xa0000, remains CR
[800058e, 800060c] 42-th(total 42-th) pm_w *0x40020c00 = 0xa0000, remains CR
[800062c, 8000668] 42-th(total 44-th) pm_r *0x40020c0c gets 0x50000, remains CR
[800062c, 8000668] 43-th(total 43-th) pm_w *0x40020c0c = 0x50000, remains CR
[80006fe, 800074c] 43-th(total 45-th) pm_r *0x40020c08 gets 0xf0000, remains CR
[80006fe, 800074c] 44-th(total 44-th) pm_w *0x40020c08 = 0xf0000, remains CR
[80006fe, 800074c] 44-th(total 46-th) pm_r *0x40020c04 gets 0x0, remains CR
[800076c, 8000786] 45-th(total 45-th) pm_w *0x40020c04 = 0x0, remains CR
[800058e, 800060c] 45-th(total 47-th) pm_r *0x40020c24 gets 0x77, remains CR
[800058e, 800060c] 46-th(total 46-th) pm_w *0x40020c24 = 0x77, remains CR
[800058e, 800060c] 46-th(total 48-th) pm_r *0x40020c00 gets 0xa0000, remains CR
[800058e, 800060c] 47-th(total 47-th) pm_w *0x40020c00 = 0xa0000, remains CR
[800062c, 8000668] 47-th(total 49-th) pm_r *0x40020c0c gets 0x50000, remains CR
[800062c, 8000668] 48-th(total 48-th) pm_w *0x40020c0c = 0x50000, remains CR
[80006fe, 800074c] 48-th(total 50-th) pm_r *0x40020c08 gets 0xf0000, remains CR
[80006fe, 800074c] 49-th(total 49-th) pm_w *0x40020c08 = 0xf0000, remains CR
[80006fe, 800074c] 49-th(total 51-th) pm_r *0x40020c04 gets 0x0, remains CR
[800076c, 8000786] 50-th(total 50-th) pm_w *0x40020c04 = 0x0, remains CR
[8000954, 800096c] 50-th(total 52-th) pm_r *0x40004810 gets 0x0, remains CR
[800096c, 800098a] 51-th(total 51-th) pm_w *0x40004810 = 0x0, remains CR
[8000954, 800096c] 51-th(total 53-th) pm_r *0x4000480c gets 0x200c, remains CR
[800096c, 800098a] 52-th(total 52-th) pm_w *0x4000480c = 0x2000, remains CR
[8000954, 800096c] 52-th(total 54-th) pm_r *0x40004814 gets 0x0, remains CR
[800096c, 800098a] 53-th(total 53-th) pm_w *0x40004814 = 0x0, remains CR
[8000954, 800096c] 53-th(total 55-th) pm_r *0x4000480c gets 0x2000, remains CR
[800096c, 800098a] 54-th(total 54-th) pm_w *0x4000480c = 0x2000, remains CR
[800096c, 800098a] 55-th(total 55-th) pm_w *0x40004808 = 0x16d, remains DR
[800096c, 800098a] 56-th(total 56-th) pm_w *0x4000480c = 0x2000, remains CR
[8000954, 800096c] 54-th(total 56-th) pm_r *0x40004810 gets 0x0, remains CR
[800096c, 800098a] 57-th(total 57-th) pm_w *0x40004810 = 0x0, remains CR
[8000954, 800096c] 55-th(total 57-th) pm_r *0x40004814 gets 0x0, remains CR
[800096c, 800098a] 58-th(total 58-th) pm_w *0x40004814 = 0x0, remains CR
[8000954, 800096c] 56-th(total 58-th) pm_r *0x4000480c gets 0x2000, remains CR
[800096c, 800098a] 59-th(total 59-th) pm_w *0x4000480c = 0x200c, remains CR
[8000850, 800086c] 60-th(total 60-th) pm_w *0x40020418 = 0x10000, remains DR
[80005d2, 800060c] 57-th(total 59-th) pm_r *0x40020400 gets 0x0, remains CR
[80005d2, 800060c] 61-th(total 61-th) pm_w *0x40020400 = 0x1, remains CR
[800062c, 8000668] 58-th(total 60-th) pm_r *0x4002040c gets 0x0, remains CR
[800062c, 8000668] 62-th(total 62-th) pm_w *0x4002040c = 0x0, remains CR
[8000682, 80006c2] 59-th(total 61-th) pm_r *0x40020420 gets 0x0, remains CR
[8000682, 80006c2] 63-th(total 63-th) pm_w *0x40020420 = 0x0, remains CR
[80006fe, 800074c] 60-th(total 62-th) pm_r *0x40020408 gets 0x0, remains CR
[80006fe, 800074c] 64-th(total 64-th) pm_w *0x40020408 = 0x2, remains CR
[80006fe, 800074c] 61-th(total 63-th) pm_r *0x40020404 gets 0x0, remains CR
[800076c, 8000786] 65-th(total 65-th) pm_w *0x40020404 = 0x0, remains CR
[8000850, 800086c] 66-th(total 66-th) pm_w *0x40020418 = 0x800000, remains DR
[80005d2, 800060c] 62-th(total 64-th) pm_r *0x40020400 gets 0x1, remains CR
[80005d2, 800060c] 67-th(total 67-th) pm_w *0x40020400 = 0x4001, remains CR
[800062c, 8000668] 63-th(total 65-th) pm_r *0x4002040c gets 0x0, remains CR
[800062c, 8000668] 68-th(total 68-th) pm_w *0x4002040c = 0x0, remains CR
[8000682, 80006c2] 64-th(total 66-th) pm_r *0x40020420 gets 0x0, remains CR
[8000682, 80006c2] 69-th(total 69-th) pm_w *0x40020420 = 0x0, remains CR
[80006fe, 800074c] 65-th(total 67-th) pm_r *0x40020408 gets 0x2, remains CR
[80006fe, 800074c] 70-th(total 70-th) pm_w *0x40020408 = 0x8002, remains CR
[80006fe, 800074c] 66-th(total 68-th) pm_r *0x40020404 gets 0x0, remains CR
[800076c, 8000786] 71-th(total 71-th) pm_w *0x40020404 = 0x0, remains CR
[8000850, 800086c] 72-th(total 72-th) pm_w *0x40020418 = 0x40000000, remains DR
[80005d2, 800060c] 67-th(total 69-th) pm_r *0x40020400 gets 0x4001, remains CR
[80005d2, 800060c] 73-th(total 73-th) pm_w *0x40020400 = 0x10004001, remains CR
[800062c, 8000668] 68-th(total 70-th) pm_r *0x4002040c gets 0x0, remains CR
[800062c, 8000668] 74-th(total 74-th) pm_w *0x4002040c = 0x0, remains CR
[8000678, 80006c2] 69-th(total 71-th) pm_r *0x40020424 gets 0x0, remains CR
[8000678, 80006c2] 75-th(total 75-th) pm_w *0x40020424 = 0x0, remains CR
[80006fe, 800074c] 70-th(total 72-th) pm_r *0x40020408 gets 0x8002, remains CR
[80006fe, 800074c] 76-th(total 76-th) pm_w *0x40020408 = 0x20008002, remains CR
[80006fe, 800074c] 71-th(total 73-th) pm_r *0x40020404 gets 0x0, remains CR
[800076c, 8000786] 77-th(total 77-th) pm_w *0x40020404 = 0x0, remains CR
[800085c, 800086c] 78-th(total 78-th) pm_w *0x40020418 = 0x80, remains DR
[8000850, 800086c] 79-th(total 79-th) pm_w *0x40020418 = 0x800000, remains DR
[800085c, 800086c] 80-th(total 80-th) pm_w *0x40020418 = 0x1, remains DR
[8000954, 800096c] 72-th(total 74-th) pm_r *0x4000480c gets 0x200c, remains CR
[800096c, 800098a] 81-th(total 81-th) pm_w *0x4000480c = 0x202c, remains CR
[8000954, 800096c] 73-th(total 75-th) pm_r *0x40004814 gets 0x0, remains CR
[800096c, 800098a] 82-th(total 82-th) pm_w *0x40004814 = 0x0, remains CR
[8000954, 800096c] 74-th(total 76-th) pm_r *0x40004800 gets 0x0, remains SR
doneWork(65) is invoked!
I observed that the input did not hang. This behaviour was also reproducible with other seeds (such as my own cfg or a random seed as well).
Just to make sure that I have setup my firmware in the intended way, here is the startup code's assembly with a call to startForkServer -
I'm unsure why AFL is hanging, maybe I'm missing some trivial configuration setup. If so, I would appreciate some pointers in this regard.
Firmware Preparation
I'm trying to fuzz a nuttx based firmware for board
STM32F429I-Discovery. For that, I added the aflCall code to the board startup file as p2im expects and compiled the firmware with the toolchain mentioned in the repository.This is my fuzz.cfg file with firmware ELFs in the intended paths.
Fuzzing
After ensuring that the
randomseed provided in the repository is present in the correct inputs folder, I ran the following commands to start fuzzing -cp ./fuzzing/nucleo-f429zi_nsh/1/fuzz.cfg . ./model_instantiation/fuzz.py -c fuzz.cfgThe firmware was able to be processed by qemu but AFL immediately bails out with the following logs -
Upon debugging with provided instructions with the following commands -
I observed that the input did not hang. This behaviour was also reproducible with other seeds (such as my own cfg or a random seed as well).
Just to make sure that I have setup my firmware in the intended way, here is the startup code's assembly with a call to
startForkServer-I'm unsure why AFL is hanging, maybe I'm missing some trivial configuration setup. If so, I would appreciate some pointers in this regard.