Implement AFL persistent exit for mips #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for the AFL_QEMU_PERSISTENT_EXITS environment variable inside MIPS programs. The code mostly is taken from the other architecture's
cpu_loop.c
files.I've further added a test to see if the system call number is
TARGET_NR_exit
.The embedded target I've used AFL++ on does not use the more common
exit_group
system call.exit()
in uclibc uses the exit system call. See theuclibc-ng
version 1.0.6 source here:https://elixir.bootlin.com/uclibc-ng/v1.0.6/source/libc/sysdeps/linux/common/_exit.c#L28
I've tested this functionality by writing a C program that calls
exit(0)
at the end of itsmain()
function. When you run afl-fuzz, it correctly recognizes the end of the loop and restarts.You can also run qemu with
AFL_QEMU_PERSISTENT_ADDR
andAFL_QEMU_PERSISTENT_EXITS
set directly. QEMU returns to the starting point when the program callsexit(0)
.This is a small C program, inspired by
test-instr.c
that you can use to verify the behavior: