507 Commits

Author SHA1 Message Date
Dongjia "toka" Zhang
89342b22c2
Revert #2935 (#3031)
* revert

* null check

* no std
2025-02-28 20:09:01 +01:00
Romain Malmain
e864bc28b1
Abort on triple fault for in process executors, refactor AddressFilter and PageFilter (#3026)
* abort on triple fault in generic inprocess signal handler

* refactor qemu filters

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-02-28 15:44:22 +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
WorksButNotTested
7121defff9
Update dockerfile (#3020)
* Fix just

* Update dockerfile

* Changes to test all architectures for qemu-user fuzzers

* Update version of QEMU

* Fix qemu on aarch64

* Fix qemu on i386

---------

Co-authored-by: Your Name <you@example.com>
2025-02-24 16:13:34 +01:00
Celian G.
40c0a8c57c
Improved calling convention support for x86, x86_64, arm and aarch64 for libafl-qemu (#3013)
* Improved calling convention support for x86, x86_64, arm and aarch64

* fix

* fix write_function_arguments

* fix argument_error

* follow clippy advice

* last change?

* fix guestaddr issue

* add code block for cargo-fmt

* default to default convention

* fix mistake

* add pub

* fix

* changes after review

* last change?

---------

Co-authored-by: celian <cglenaz>
2025-02-21 18:04:45 +01:00
Dominik Maier
7c83be2408
Add auto format to settings.json.default, format documentation and macros (#3019)
* Add auto format to settings.json.default

* Add more nightly rustfmt features
2025-02-21 13:31:31 +01:00
WorksButNotTested
f5a01ee20d
Asan guest fix (#2986)
* Check for initialization of libgasan.so on first_exec

---------

Co-authored-by: Your Name <you@example.com>
2025-02-17 17:06:42 +01:00
forky2
a30cce1d88
Fixes #2966 and #2967: Ensure DRCOV unique IDs and max 4GiB ranges. (#2968)
* Fixes #2966 and #2967: Ensure DRCOV unique IDs and max 4GiB ranges.

* Formatter.
2025-02-17 14:51:15 +01:00
Marco C.
47f7978b91
Bump Libipt 0.3, add HW breakpoint support (#2984)
* Decode with callback

* WIP restore intelpt module

* Fix build_target if target_dir doesn't exist

* WIP itelpt qemu/kvm example: bootloader

* qemu config refactoring

* Fix intel_pt_command_executor target dir

* * QEMU error refactoring*
* back to one QEMU init function
* other small things

* update test

* Bump libipt

* waitpid_filtered to ignore SIGWINCH

* Fix warnings unused manifest key: *.version

* Add export_raw feature to libafl_intelpt

* derive Debug for IntelPTHook

* Clippy

* Light refactor of EmulatorModules

* qemu is now a parameter to EmulatorModule callbacks and most function hooks.
* EmulatorModules is initialized before QEMU is initialized.

* Update target program ELF offsets

* fmt

* * asan fixed size accesses working with generics
* continue to propagate qemu argument as hook first parameter
* use pre_syscall* and post_syscall* everywhere
* fix some clippy stuff

* fmt

* Add comment to KVM pt_mode check

* refactor

* Add intel_pt_export_raw feature in libafl

* fix fuzzers

* * refactor asan and asanguest modules to avoid custom init of QEMU and use the module interface instead.
* adapt qemu_launcher example to fully work with emulator, since qemu must now be initialized by emulator.

* fmt

* clippy

* fix qemu_coverage

* fmt

* forgot qemu args in launcher

* map_error instead of unwrap

* use correct args

* Update to new libafl_qemu

* adapt api

* borrow checker friendly join_split_trace

and copy trace before deocde to prevent decoding failures

* testing stuff

* Set ip_filters (also) with builder

* Move trace to file

* Store a pt_builder in module

enable the setting of filters and other pt settings

* baby_bootloader target

* Best bootloader ever

* new builder?

* use closure for qemu config from emulator builder.

* better format

* clippy + fmt

* Fix build target

Create target directory if doesn't exist

* Remove filter on speculatively exec blocks

since also committed blocks can have this flag

* Add current ip_filters getter

* Fix possibile infinite loop in trace decode

* HW breakpoint + snapshot

* add snapshot and exit at first objective

* prefer raw pointers to slice_from_raw_parts_mut

since the latter is highly unsafe and allows more potentially dangerous reordering

* Add cpu option to QEMU config

* Add cpu option and minor improvements

* fix cargo run causing recompile

* no default devices

* windows clippy fix

* Exclude intel_pt feature from CI as all systemmode feats

* Add qemu_intel_pt_bootloader to CI

* Fix NopPageFilter

* Fix qemu_config

* Restore HW breakpoints

* Lints

* return Result for hw bp set/remove

* mark join_split_trace as unsafe

* Put the qcow2 in a tmpfs ramdisk

10x exec/sec

* Post merge fixes

* Try out libipt 0.3 alpha

* Try out libipt 0.3 alpha also in hook

* Clippy

* New libipt

* Post merge fixes

* Bump libipt

* Drive cache None

* Post merge fixes

* Use SectionInfo from libipt

* No slice::from_raw_parts_mut, just use raw pointer

* Cache the decoder builder

* Update qemu-bridge

* Add qemu -append param

* Move linux specific code to a mod, less #[cfg]s

* Add qemu initrd config

* Add qemu monitor tcp

* Add not enough ip filters message

* Fix wrong must_use

* Prevent possible infinite loop in block decoding in debug mode

* Clippy

* fix CI?

* Revert, keep libipt 0.3 and hw bp

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Marco Cavenati <marco@lenovo300e>
2025-02-17 14:50:07 +01:00
dimeko
94d6c51363
chore: adds check for riscv64 and riscv32 archs (#2993) 2025-02-17 13:03:09 +01:00
Dongjia "toka" Zhang
8b49d81406
Better addr2line (#2989)
* better addr2line

* delete unused

* more

* fixer?

* lol

* class

* mm

* take care of non pie binary or pie binary

* user mode only
2025-02-16 19:18:09 +01:00
Dongjia "toka" Zhang
c53e51584b
Separate addr2line code from asan module (#2980) 2025-02-13 17:56:17 +01:00
Dongjia "toka" Zhang
b067435862
Align addresses before calling qemu.unmap in Snapshot module (#2978)
* alignment

* a
2025-02-13 14:17:48 +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
Dongjia "toka" Zhang
33db263260
Fix brk() handling for snapshot module (#2970)
* drop grown address

* this clippy lint literally makes 0 sense!

* i hate you rust

* mm

* don't use drop! add comments for why alignment is not necessary
2025-02-13 11:33:24 +01:00
Dongjia "toka" Zhang
0736c56647
Add getter method to QemuMappingsViewer (#2973) 2025-02-12 18:34:24 +01:00
Dongjia "toka" Zhang
cb3abf27a3
Add a functionality to see the current qemu mappings. (#2971)
* add

* a

* take qemu

* fix for fuzzers
2025-02-12 16:56:36 +01:00
WorksButNotTested
739156cb23
Add SnapshotModule to qemu_launcher (#2887)
* Add SnapshotModule to qemu_launcher

---------

Co-authored-by: Your Name <you@example.com>
2025-02-11 18:42:20 +01:00
dependabot[bot]
e5ae6c361f
Update strum requirement from 0.26.3 to 0.27.0 (#2959)
Updates the requirements on [strum](https://github.com/Peternator7/strum) to permit the latest version.
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/compare/v0.26.3...v0.27.0)

---
updated-dependencies:
- dependency-name: strum
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-10 21:22:43 +01:00
dependabot[bot]
5ebb3913d8
Update strum_macros requirement from 0.26.4 to 0.27.0 (#2961)
---
updated-dependencies:
- dependency-name: strum_macros
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-10 18:24:42 +01:00
EvianZhang
075fb0daa2
Fix clippy (#2954) 2025-02-08 13:10:55 +01:00
Celian G.
64554d68bb
Small improvements for Qemu (#2938)
* Remove uneeded Executor trait from handlers functions + set inproc_qemu_crash_handler to pub

* Add some documentation for QemuHooks

---------

Co-authored-by: celian <cglenaz>
2025-02-07 13:28:11 +01:00
dependabot[bot]
0573bbb159
Update capstone requirement from 0.12.0 to 0.13.0 (#2930)
Updates the requirements on [capstone](https://github.com/capstone-rust/capstone-rs) to permit the latest version.
- [Release notes](https://github.com/capstone-rust/capstone-rs/releases)
- [Changelog](https://github.com/capstone-rust/capstone-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/capstone-rust/capstone-rs/compare/capstone-v0.12.0...capstone-v0.13.0)

---
updated-dependencies:
- dependency-name: capstone
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-05 15:25:57 +01:00
Dongjia "toka" Zhang
c09feeba4e
Don't write pointers to the crash handlers at every execution (#2935)
* make it safe

* aa

* forgot to put it back

* stateful

* comment

* lol

* aa

* aa

* aa

* win

* lol

* lol

* a

* a

* i hate rust

---------

Co-authored-by: Your Name <you@example.com>
2025-02-05 14:00:09 +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
Dongjia "toka" Zhang
defb475d28
Fix EdgeCoverageModuleBuilder (#2931) 2025-02-04 14:34:11 +01:00
Dominik Maier
5bd6a6f754
Revert "QASan: remove chunk_struct (#2899)" (#2928)
This reverts commit ba0da5121b54c89d5ad3c06189959afbbeb64d23.
2025-02-03 14:47:13 +01:00
Dongjia "toka" Zhang
6648bc90d2
Collect envs in AsanModuleBuilder::default() (#2921)
* collect envs in AsanModuleBuilder::default

* migration

* fmt
2025-02-01 09:57:29 +01:00
Dominik Maier
84702d12a8
Make sure EM and Z remain consistent in InProcessExecutor (#2873)
* Make sure EM and Z remain consistent in InProcessExecutor

* first make them compile

* a

* hah

* fix intel pt

* decouple fuzzer from em

* lol

* 3

* fix tcp

* fix

* fix

* fix

* fixer

* std

* fixer

* plz

* plzplzplz

* plzplzplzplz

* mm

* more

* symbol

* a

* a

* mm

* mmm

* mmmm

* mmmmm

* ff

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-02-01 08:23:40 +01:00
Romain Malmain
75feedd1a0
Add builder and tests for QASAN (#2898)
* Add tests for QASAN from aflplusplus

* refactor asan module to use the builder pattern

* move injection tests to the new tests directory
2025-01-31 15:43:50 +01:00
Dongjia "toka" Zhang
d8df9b4910
Fix Clippy (#2913)
* clp

* lol

* this is false positive

* a

* clippy all

* aa
2025-01-30 11:17:01 +01:00
Romain Malmain
ba0da5121b
QASan: remove chunk_struct (#2899) 2025-01-28 01:46:09 +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
1addbd04b9
Expose qemu's image_info for qemu usermode (#2889)
* image info for qemu usermode

* must use

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-01-24 20:05:38 +01:00
Romain Malmain
4083f0ba73
Fix drcov path parsing (#2884)
* fix drcov path parsing

* refactoring of drcov tool

* add the possibility to sort addresses in drcov tools

* more aggressive clippy. it now catches more warnings as errors than before

* reduce the number of unfixable warnings displayed.
2025-01-24 18:21:51 +01:00
Romain Malmain
d9e8b59cb6
Fix qemu cov (#2875)
* fix drcov module hooks setup
2025-01-22 14:05:25 +01:00
Dongjia "toka" Zhang
6ee26a8afa
Decouple address_filters() from EmulatorModuleTuple into HasAddressFilters (#2869)
* 1

* fixe
2025-01-20 17:44:44 +01:00
Romain Malmain
8089b18d34
Remove ShMemProvider bound from struct definitions (#2861)
* No more ShMemProvider bound constraint in struct definition whenever possible

* Introduce StdShMem

* Update CONTRIBUTING.md
2025-01-20 17:25:55 +01:00
Romain Malmain
f8ad61e14a
Remove Input associated type (#2854)
* Completely remove Input as an associated type in multiple traits

* Unify usage of Input as generic instead 

* Remove many unused bounds, in particular HasCorpus

* fix multiple generic ordering

* update and fix CONTRIBUTING.md

* update MIGRATION

* use the same generic input type for new / with_max_iterations to make typing easier in most cases.

* Restore libafl_libfuzzer test in CI
2025-01-17 14:53:51 +01:00
h1k0
d4add04f87
Add comments for EmulatorModule trait (#2842)
* Add comments for EmulatorModule trait

---------

Co-authored-by: h1k0 <h1k0naka@outlook.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-01-16 17:49:22 +01:00
Dongjia "toka" Zhang
435ca021cc
No uses for EventManager (#2831)
* the first step of the last step

* wip

* 99% done

* 99.9% done

* 99.99

* Hello from windows

* aaa

* 99.999

* aa

* 1

* 2

* 3

* 4

* 5

* plz

* plzplzplz

---------

Co-authored-by: Your Name <you@example.com>
2025-01-15 16:56:40 +01:00
Romain Malmain
a45e44764f
Remove UsesInput from libafl qemu (#2832)
* remove UsesInput from libafl_qemu

* Insert I bound instead of ugly Corpus::Input stuff

* Uses a C generic for Commands

* adapt nyx api to new generics

* add qemu linux fuzzers to CI for building.
2025-01-14 10:24:28 +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
cube0x8
1a9e25145d
Fix snapshot reset function when brk shrunk below the snapshotted value (#2812)
* added change_brk function for correctly handling SYS_brk

* we need to update h.brk with the new brk_val

* map back pages if brk shrunk below the snapshotted value

* fmt and clippy

* use GuestAddr instead of u64

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-01-09 00:30:39 +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
Dominik Maier
d39ded5b29
Fix and/or mute more clippy lints, deprecation warnings in Pyo3 (#2805) 2025-01-03 15:17:46 +01:00
Dominik Maier
deb76555b7
New year new clippy (#2797)
* New year new clippy

* More clipy

* fix
2025-01-01 20:57:43 +01:00