134 Commits

Author SHA1 Message Date
9bbc5e7c78 Merge branch 'fret_141' into fret_153 2025-07-28 12:03:09 +00:00
WorksButNotTested
1355bd5294
Improve CI (#3258)
* Improve CI

* Fix markup errors

* Remove unnecessary matrix parameters

* Rename matrix jobs to tidy up the UI

* Allow the docker cache to be updated

* Fix cache name

* Share some caches

* Rename tools
2025-05-22 16:08:35 +02:00
WorksButNotTested
b5ab6bad1c
Allow QEMU location and version to be specified in environment (#3226)
* Allow QEMU location and version to be specified in environment

* Rename things

* Change remote to url
2025-05-16 11:34:18 +02:00
Romain Malmain
c9b0dc216f
LibAFL QEMU update to v10.0.0 (#3181)
* update qemu hash

* clippy, fmt

* update

* Revert "Update hashbrown requirement from 0.14.5 to 0.15.3 (#3184)" (#3186)

This reverts commit 4448799dc2205e4cb1753b8b8d91b4f6d299365d.

* update qemu

* fix systemmode

* update qemu

* update qemu

* update qemu with fix

* debug

* cargo hack

* FMT

---------

Co-authored-by: Dongjia Zhang <tokazerkje@outlook.com>
2025-05-12 16:58:11 +02:00
Konstantinos Kanavouras
50e1239de9
Remove unneeded workaround for bindgen not supporting f16 types (#3166) 2025-04-24 18:33:12 +02:00
Dongjia "toka" Zhang
373fe03633
Use HashMap to manage ClientStat, Fix #3133 (#3142)
* fix

* lol

* lol

* clp fixer

* clp fixer

* revert cargo.toml
2025-04-08 19:06:20 +02:00
Marco C.
a7d735c1de
Add IntelPT tracing module to libafl_qemu systemmode with KVM (#2774)
* intelpt module
2025-04-08 10:10:39 +02:00
Romain Malmain
184b69be8e
Update QEMU syshook ret value (#3092)
* update syshook ret value
2025-03-31 15:51:01 +02:00
Romain Malmain
58607dc333
Update QEMU to v9.2.2 (#3088)
* update qemu to v9.2.2

* alignment field has been removed
2025-03-25 14:34:44 +01:00
Romain Malmain
d5ddc1359e
Fix qemu snapshot module unmap (#3084)
* fix qemu usermode snapshot unmap

* fix phys addr computation for qemu. some cleanup.
2025-03-18 10:31:16 +01:00
Romain Malmain
a613676675
Fix LibAFL QEMU race condition between main loop and a vcpu (#3072) 2025-03-18 09:43:00 +01:00
Romain Malmain
d67296f34e
Soft recovery from crashes in libafl qemu usermode (#3073)
* soft recovery from crashes in qemu

* regen bindings for clippy

* configurable crash behaviour
2025-03-14 16:56:03 +01:00
Dominik Maier
ce5fd435ea
Move all unnecessary std uses to core,alloc (#3027)
* Move all unnecessary std uses to core,alloc

* More

* more fix

* more

* more

* Remove libafl-fuzz grimoire

* more

* more

* more cleanup

* remove bins

* fix

* more fix
2025-02-27 14:32:37 +01:00
Dominik Maier
c7207dceb0
Rust 2024 edition (#3022)
* Rust 2024 edition

* gen = generalized

* Fixes

* more fix

* More fix

* even more fix

* fix libfuzzer

* ignore clippy lint

* even more

* fix docs?

* more?

* More pub more better

* win

* docs

* more

* More

* doc stuff?

* counter_maps->counters_maps

* libafl qemu fixes for rust 2024

* fix?

* fmt

* unsafe lint

* final fixes

* fmt

* working?

* not working

* unused import

* win?

* update libafl qemu hash

* fmt

* fix

* unused imports

* fix

* fix

* more foix

* less edition

* fix

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-02-27 00:12:29 +01:00
Romain Malmain
cb471a9282
Move to just (binary_only / full_system) (#2949)
* just port for binary only / systemmode fuzzers

* introduce just libraries, with pre-initialized variables and common recipes

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-13 12:42:38 +01:00
Romain Malmain
8398f8f99a
Qemu signal refactoring (#2920)
* qemu signal refactoring

* udpate qemu

* clippy, moving things around

* update bindings

* nostd

* cfg

* fmt

* nostd

* clippy

* fmt

* aaa

* windowsssssss

* systemmode

* reimport fix

* remove llmp from replay mode

* lol

* fixer

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-04 14:43:26 +01:00
Romain Malmain
b320a8dbab
Add PC to QEMU's read / write callbacks + logger module (#2896)
* Logger module (only read/write for now)

* add pc to rw callbacks

* regen bindings
2025-01-27 15:01:20 +01:00
Romain Malmain
d8460d14a2
More Nyx hypercalls supported in libafl qemu. add tests for filters. (#2825)
* more nyx hypercalls implemented, among them:
- panic hypercall
- range filtering hypercall

* fixed some nyx hypercalls behavior.

* added generic read / write to qemu memory

* port linux kernel example to also have nyx API, add better filtering as well.

* make nyx api structs volatile to avoid optimization issues

* Introduce a method create a Vec in place, using a closure.

* use new vec_init function in relevant places.

* removed unused unsafe keywork

* add more allocated memory r/w callbacks

* add more safety notes

* move emulator hooks to separate struct

* update QEMU version
2025-01-13 17:32:23 +01:00
Dongjia "toka" Zhang
aa0391ef8d
No Uses* from executor (#2766)
* first step

* wip

* lol

* making progress, slowly

* add

* a bit more

* progress

* 80%done

* 90% done

* done from linux

* Hello from windows

* 1

* 2

* 3

* 4

* 5

* 6

* 7

* Hello from windows

* 9

* 10

* 11

* 11

* 12

* 13

* aa

* fixer

* a

* oops

---------

Co-authored-by: Your Name <you@example.com>
2025-01-11 15:25:15 +01:00
Romain Malmain
17336dcf57
Nyx hypercall API support for LibAFL QEMU (#2801)
* Nyx hypercall API support

* fix linux kernel fuzzer

* hash_me -> hash_64_fast

* fix multiple bug in kernel harness

* do not check libmozjpeg's C files format.
2025-01-06 16:58:57 +01:00
Romain Malmain
7c8708d4b1
Refactor of Qemu configuration (#2707)
* Qemu config refactoring.

* QEMU error refactoring.

* Single QEMU init function.

* Light refactor of EmulatorModules.

* Qemu is now a parameter to EmulatorModule callbacks and most function hooks.

* EmulatorModules is initialized before QEMU is initialized.

* refactor asan and asanguest modules to avoid custom init of QEMU and use the module interface instead.

* asan fixed size accesses working with generics.

* use pre_syscall_* and post_syscall_* everywhere for consistency.

* adapt qemu_launcher example to fully work with Emulator, since Qemu must now be initialized by Emulator.

* start writing Emulator / EmulatorBuilder / QemuConfig doc.

* fix broken intel pt doc.
2025-01-06 15:04:40 +01:00
Valentin Huber
25386bfb5f
Use #[expect(…)] instead of #[allow(…)], remove unnecessary allows (#2784)
* Use expect instead of allow, remove unnecessary allows

* Remove more whitelist lint warnings

* tranisitioning more subprojects

* Re-add some necessary allows

* Re-add more required allows

* Some more windows clippy fixes

* Re-add more whitelist items for expect

* More clippy whitelist fun

* Reset changes to generated files

* Reset generated files to correct version

* Move libafl_concolic to expect instead of allow

* Move libafl_frida to expect from allow

* Move libafl_libfuzzer to expect from allow

* Remove more whitelist items for macOS

* Fix unknown clippy allow

* Remove more unnecessary allow statements

* moving fuzzers

* Remove mistakenly added subdirs

* fixing imports

* Remove more unnecessary whitelisted lints

* Fix test for /home/ubuntu/LibAFL/fuzzers/inprocess/libfuzzer_libpng_accounting

* More clippy improvements for libafl_qemu

* fmt

* Some pedantic options

* Fix more stuff

* Remove Little-CMS again

* Add note to static_mut_refs

* Reset the changed testing routine since it is unnecessary
2024-12-20 16:55:35 +01:00
cube0x8
e46cf8a851
LibAFL_QEMU: Fix incorrect handling of brk syscall when shrinking the heap (#2776)
* added libafl_get_initial_brk API to properly handle brk growing and shrinking

* cargo fmt

* updated qemu revision

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-12-19 10:40:16 +01:00
a13dca6f39 abstract SystemTraceData 2024-12-16 16:00:18 +01:00
1430532b38 fix build 2024-12-04 13:03:38 +01:00
Dominik Maier
b3d73b2919
Fix tui monitor for example fuzzers (#2699)
* Fix tui monitor for example fuzzers

* New clippy lint

* fix
2024-11-16 08:28:11 +01:00
Marco C.
f3aa88b400
Use version.workspace (#2682) 2024-11-12 15:45:35 +01:00
Dominik Maier
8617fa6603
Introduce workspace (again) (#2673)
* Trying to redo workspace deps again after #2672

* unused

* clippy
2024-11-09 19:11:01 +01:00
Dongjia "toka" Zhang
e0c5304e32
Don't use workspace dependencies (#2652)
* rev

* postcard

* serde

* fmt

* a

* dependabot

* postcard again

* hashbrown

* upd

* add

* serde?
2024-11-04 17:47:40 +01:00
Romain Malmain
6d55626a48
libafl_qemu: update qemu to v9.1.1 (#2636)
* update qemu to v9.1.1

* adapting stuff to qemu 9.1

* fix for new qemu gen_callN and x86 decoder

* remove outdated qemu configuration option
2024-10-31 17:54:37 +01:00
saibotk
83c87acd5b
libafl_qemu: Add RISCV support (#2367)
* libafl_qemu: Add RISCV support

Adds the following targets (as features):
- riscv32
- riscv64

Added `RISCVCPU` and `CPURISCVState` to the bindings allow list.

Added riscv.rs to the arch module, with all necessary functions and
registers implemented and mapped.
The registers are the same as the ones found in qemus gdbstub xml found
after a build.

Additionally we added all syscall numbers for riscv 64 bit (already
supported by the `syscall_numbers` crate) and also added the missing
ones for riscv 32 bit. We compared both lists and their differences /
equalities with a simple python script and generated a list of the
missing ones, to be complete.
We might PR those to the `syscall_numbers` crate later on.

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-10-30 10:33:03 +01:00
Romain Malmain
d96d833760
Support on_crash & on_timeout callbacks for libafl_qemu modules (#2620)
* support (unsafe) on_crash / on_timeout callbacks for modules

* use libc types in bindgen
2024-10-21 17:59:04 +02:00
Romain Malmain
d48a7d508d
Centralize clippy lints in workspace (#2606)
* centralize clippy definition

* fmt

* add update bindings script

* add a checked and unchecked version of memory read to qemu stuff

also, a lot of clippy thing

* update binding position

* rm old script, new one is a bit better

* update doc

* macos clippy

* adapt fuzzers

* windows clippy

* fix fuzzer

* windows clippy

* remove old allowed clippy

* remove some allowed clippy

* use default features for serde_json in gramatron

* better error handler for failed rw to memory
2024-10-15 13:31:01 +02:00
Romain Malmain
18fb6a4197
[libafl-qemu-bridge] fix rpath regex for Ubuntu (#2609) 2024-10-11 18:56:51 +02:00
Dongjia "toka" Zhang
c12c6f31e2
Change fuzzbench_qemu fuzzer (#2520)
* change fuzzbench_qemu

* real test

* fix qemu crash hook

* update bindings

* fix fork executor, reduce trait bound overhead

* make EdgeModule depend on observer to get ptrs.

* do not make EdgeCoverageModule::new public

* map observer as builder call

* adapt examples with new edge coverage module builder.

* TMP: everyone is a variable length map observer

* reuse profile path script

* fix absolute paths

* remove some dependencies to make pipeline faster

* compile-time builder initialization check

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-10-08 15:18:13 +02:00
Romain Malmain
1fbb18cb99
Versioning unification, dependencies update, logging optimization (#2560)
* versioning unification: use x.y.z format everywhere

* do not compile low-level logs (< info level) by default in fuzzers

* update dependencies to the latest versions

* add members to workspace.

* use workspace for common dependencies

* add vscode native support

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-10-07 12:03:29 +02:00
Dominik Maier
82110472d6
Mark unsafe functions unsafe, as Ferris intended (#2559)
* Mark unsafe functions unsafe, as Ferris inteded

* More

* more safety?

* more fix

* actually safe

* More cleanup

* More fix

* more unsafe

* fix imports

* more unsafe

* fixes

* bring back the memories
2024-09-28 16:46:39 +02:00
Romain Malmain
c944a70056
Linux kernel fuzzing example (#2496)
* linux kernel (x509_cert) and process fuzzing example

* rework filters

* update to latest qemu

* working for process and kernel fuzzing

* new i2s mutator for binary only fuzzers

* refactoring modules with new filtering interface

* add state as parameter of harness

* hide unused global in usermode

* Script for stub bindings generation

* do not try to check whether it is worth generating the bindings, always
  generate when the env variable is on.

* add taplo to fmt_all.sh

* Moved fuzzers (again) in a target-centric way.

* fix rust 2024 warnings.

* new libafl_qemu harness structure.

* rename qemu_systemmode into qemu_baremetal

* fix qemu baremetal makefile

* fix formatter

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-09-26 14:29:33 +02:00
Dominik Maier
e2cc78f274
Better documentation headers (clippy) (#2501)
* Better documentation headers (clippy)

* more doc

* more fixes

* Even more

* more

* even more

* concrete

* fmt

* even more more

* tiny typo

* more

* more

* More

* more

* more docs?

* more docs
2024-08-26 16:31:22 +02:00
Romain Malmain
4b87d7f4eb
Custom QEMU emulator typed builder + ExitHandler / Commands refactoring (#2486)
* Add a custom typed builder for Emulator

* Unify qemu_init for usermode and systemmode

* Remove env from qemu init args (it is unused in QEMU in practice)

* expose thread hooks to systemmode

* rename qemu_config to config

* Replace ExitHandler by EmulatorDriver

* Reorder generics alphabetically for Qemu{,Fork}Executor

* Moved snapshot manager to Emulator to continue centralizing mains objects in the same structure

* Reimplementation of CommandManager working with enums instead of tables

* Macro has been adapted to do this work automatically

* Moved snapshot stuff to dedicated module

* Removed many Rc<RefCell<...>>, now useless with the removal of vtables

* Builder given by Emulator via `Emulator::builder`. Reduced trait bound overhead
2024-08-21 16:36:45 +02:00
Romain Malmain
6979032ad9
Qemu generics cleanup (#2484)
* cleanup generics

* remove most extern C

* update qemu to latest revision

* executor trait bounds minimization
2024-08-14 12:55:43 +02:00
Romain Malmain
13ba32ed2a
Unify qemu executor (#2483)
* Remove stateless qemu executor

* All harnesses take a reference to an emulator as parameter now

* harness takes an emulator as first parameter, and input as second parameter (opposite of previous definition)

* bump libafl qemu dependencies to the latest version
2024-08-13 19:44:10 +02:00
Romain Malmain
00806b177d
Qemu native hooks refactoring (#2480)
* qemu native hooks refactoring (companion patch of qemu-libafl-bridge#82)

* update stubs
2024-08-13 18:40:51 +02:00
Romain Malmain
723f4a1cb0
Fix various QEMU bugs (#2475)
* Update LibAFL QEMU to the latest version (V9.0.2 update, important bug fixes, ... - check the dedicated repo for more info)
* fix bug in hook execution, causing first execution hooks to be run multiple times.
2024-08-05 23:48:35 +02:00
Dominik Maier
8fb80c3f3a
libafl_qemu: Continue build with outdated LLVM, ignore TUI race conditions (#2461)
* libafl_qemu: Continue build with outdated LLVM

* Ignore race condition

* ignore more race conditions, remove useless clones

* fix fixes
2024-07-30 14:48:17 +02:00
Mrmaxmeier
afbdc02c54
Format all tomls with taplo fmt (#2436)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-07-26 10:03:10 +02:00
Dongjia "toka" Zhang
f6151f4507
0.13.2 (#2423)
* 0132

* fix
2024-07-19 23:00:37 +02:00
Romain Malmain
c96ea616fe
Qemu helpers & hooks refactoring (#2267)
* Helper is now called Module.

* Emulator now contains hooks state.

* Emulator is managed by QemuExecutor.

* QEMU hooks have been completely refactored on the rust side.

* Generics cleanup.
2024-07-17 11:46:42 +02:00
Dominik Maier
d4101a671c
Make language clearer (#2383) 2024-07-12 13:04:49 +02:00
Dongjia "toka" Zhang
2565fa8bf5
Delete Makefile.toml from Multi machine exmaple (#2379)
* delete

* aa
2024-07-11 14:51:18 +02:00