* Hongxu Chen <
leftco...@gmail.com>, 2018-05-17, 03:43:
>- In AFL, the shared memory is attached with "shmget" rather than
>"mmap". It seems that mmap is more recommended while shmget is more
>widely supported. So why AFL chooses the former (AFL indeed also uses
>mmap for tracking mutated bytes but that's for another purpose)?
If you want to share memory across execve(), you need not only mmap(),
but also shm_open(), and the latter is just awful. For AFL purposes,
shmget()+shmat() is a much nicer API.
BTW, there's a comment in afl-as.h that seems to imply that the
instrumentation uses both shmget() and shmat(), whereas it uses only the
latter. Michal, you may want to fix that.
>And can we expect "mmap" to bring slowdown or boost performance
>compared to current implementation?
I wouldn't expect any noticeable difference.
>- AFL handles "timeout" with a relatively complicated code flow, while
>there is an alternative by using "select" syscall
One difficulty is that if there's no forkserver, afl-fuzz has to wait
for the child to terminate. This not supported directly by select().
>the problem we can see is that from Linux's manual, SA_RESTART does not
>work with "select", therefore there may be some portability issues
>compared to current implementation.
POSIX says: "If SA_RESTART has been set for the interrupting signal, it
is implementation‐defined whether the function restarts or returns with
EINTR."
All in all, I'm skeptical if using select() will actually make the code
simpler.
--
Jakub Wilk