google / AFL

american fuzzy lop - a security-oriented fuzzer
https://lcamtuf.coredump.cx/afl/
Apache License 2.0
3.68k stars 633 forks source link

afl-fuzz: Incorrectly detecting CPU frequency scaling governor #50

Open willmcpherson2 opened 4 years ago

willmcpherson2 commented 4 years ago

AFL version: 2.56b Command: afl-fuzz -i fuzz/ -o findings ./lang @@ OS: Manjaro Linux CPU: Intel Core i5-2400S CPU @ 2.50GHz

On running afl-fuzz I got this message:

Whoops, your system uses on-demand CPU frequency scaling, adjusted
between 1562 and 3222 MHz. Unfortunately, the scaling algorithm in the
kernel is imperfect and can miss the short-lived processes spawned by
afl-fuzz. To keep things moving, run these commands as root:

cd /sys/devices/system/cpu
echo performance | tee cpu*/cpufreq/scaling_governor

You can later go back to the original state by replacing 'performance' with
'ondemand'. If you don't want to change the settings, set AFL_SKIP_CPUFREQ
to make afl-fuzz skip this check - but expect some performance drop.

I followed the directions and fuzzed my program. But when I tried to revert the scaling governors, I got:

[root@will-mac cpu]# echo ondemand | tee cpu*/cpufreq/scaling_governor
ondemand
tee: cpu0/cpufreq/scaling_governor: Invalid argument
tee: cpu1/cpufreq/scaling_governor: Invalid argument
tee: cpu2/cpufreq/scaling_governor: Invalid argument
tee: cpu3/cpufreq/scaling_governor: Invalid argument

After some digging it seems that Sandy Bridge CPUs do not use ondemand. Arch Wiki Forum post I was able to successfully use powersave.

Perhaps the message printed by check_cpu_governor could include the existing value in /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor rather than always printing "on-demand". I would be happy to patch this myself if it is an acceptable solution.

willmcpherson2 commented 4 years ago

@NikParam42 How does that relate to the CPU frequency scaling governor?