s3team / Squirrel

MIT License
184 stars 54 forks source link

share memory in server #9

Closed ace-shifu closed 1 year ago

ace-shifu commented 2 years ago

Do we need to establish shared memory in Mysql server?

mariadb-RoelVandePaar commented 2 years ago

Yes. First compile the binary with instrumentation (afl-clang-fast and afl-clang-fast++ -or- afl-clang-lto and afl-clang-lto++), then start AFL (Squirrel) and set export __AFL_SHM_ID=x to the value shown by/at the start of afl-fuzz.c (only if the code was changed to do so, see this example): before & in the same terminal where you will start mysqld. The instrumentation of mysqld will kick in when it seens this variable. You may also need to set AFL_MAP_SIZE and finally you need to set to LD_LIBRARY_PATH to the ./lib path of your mysql basedir, but this before & in the same terminal as where you start afl-fuzz (it's a option for Squirrel, not for mysqld, unlike the others discussed here). Note: it is not easy to get squirrel to work standalone, but it can be done. Also see my tickets in main AFL repo for some additional info.

mariadb-RoelVandePaar commented 2 years ago

Btw, I found that afl-clang-fast and afl-clang-fast++ are better choices than lto, at least ftm in terms of build reliability etc.