hal-fuzz icon indicating copy to clipboard operation
hal-fuzz copied to clipboard

WARNING: You just tried to use a timer, and timers are not enabled! Try adding `use_timers: True` and `use_nvic: True` to your firmware's YAML file.

Open dierye opened this issue 2 years ago • 1 comments

I got this error when run 'test_st_plc.sh', but I'm sure that use_timers: True and use_nvic: True was added in the file st_plc.yaml. Is that normal ?

Loading fuzz from: ./tests/st-plc/inputs/input1
Executing until a crash
WARNING: You just tried to use a timer, and timers are not enabled! Try adding `use_timers: True` and `use_nvic: True` to your firmware's YAML file.
Traceback (most recent call last):
  File "/home/halfuzz/hal-fuzz/hal_fuzz/hal_fuzz/handlers/__init__.py", line 61, in func_hook_handler
    hook(uc)
  File "/home/halfuzz/hal-fuzz/hal_fuzz/hal_fuzz/handlers/stm32f4_hal/stm32f4_wifi.py", line 26, in wifi_init
    Timer.start_timer(hex(tim1), wifi_timer_rate, 45)
  File "/home/halfuzz/hal-fuzz/hal_fuzz/hal_fuzz/models/timer.py", line 105, in start_timer
    internal_ind = native.add_timer(timer_rate, isr_num=timer_func_irq)
  File "/home/halfuzz/hal-fuzz/hal_fuzz/hal_fuzz/native.py", line 221, in add_timer
    sys.exit(1)
SystemExit: 1
Exiting via os._exit

dierye avatar Aug 17 '22 11:08 dierye

I encountered the very same issue, for another example. I looked into the issue, and my suspicion that this check is inverted:

    if timer_cb_wrapper is not None or timer_cb_user_data is not None:
        print("WARNING: You just tried to use a timer, and timers are not enabled! Try adding `use_timers: True` and `use_nvic: True` to your firmware's YAML file.")
        sys.exit(1)

(https://github.com/ucsb-seclab/hal-fuzz/blob/master/hal_fuzz/hal_fuzz/native.py#L219)

I think the logic should be:

if timer_cb_wrapper is None or timer_cb_user_data is None:

Inverting this check accordingly made HALucinator at least run for my usecase, but it would be great to have confirmation by the maintainers before supplying a PR.

mariusmue avatar Jan 29 '23 09:01 mariusmue