-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tmp] rudimentary support for rustc fuzzing
If you happen to stumble across this, here's how to build rustc with AFL instrumentation and make it work with this commit: 1. Run 'cargo install afl'. This will compile AFL and the LLVM plugins needed to build rust with AFL instrumentation. 2. Clone <https://github.com/rust-lang/rust>. 3. Set LIBRARY_PATH="$(realpath ~/.local/share/afl.rs/rustc-*/afl.rs-*/afl-llvm-rt" 4. Set RUSTFLAGS="-C llvm-args=-sanitizer-coverage-level=3 \ -C llvm-args=-sanitizer-coverage-trace-pc-guard \ -C passes=sancov \ -l afl-llvm-rt \ -L $(realpath ~/.local/share/afl.rs/rustc-*/afl.rs-*/afl-llvm-rt)" 5. Build rustc: ./x.py build 6. Test that it works: cargo afl showmap -o trace.txt -m 1024 -- build/x86_64-unknown-linux-gnu/stage2/bin/rustc --emit asm input.rs cat trace.txt 7. Clone <https://github.com/rust-fuzz/afl.rs>. This will give you the AFL version that you need to build this fuzzer against (edit make.sh here to point to afl.rs/afl-*/). 8. Edit main.cc to point /home/vegard/... paths to your own rustc/etc. 9. Run: mkdir output/ stderr/ 10. Run: bash make.sh && ./main
- Loading branch information
Showing
3 changed files
with
266 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
"[] fn [x][]([]) -> [][u32] { []; []; []; []; [0] } [] fn main() { []; []; []; []; [] }" | ||
"[] fn [x][]([]) -> [] [{}]" | ||
"[]; []" | ||
"[] { [] } []" | ||
"[] ([]) []" | ||
"[x]x" | ||
"[1]0" | ||
"0" | ||
"1" | ||
"false" | ||
"true" | ||
"'x'" | ||
"\[[]\]" | ||
"[1], [2]" | ||
"[1]; [2]" | ||
"[1] + [2]" | ||
"let x" | ||
"let [x] = [5]" | ||
"let [x]x = [x]" | ||
"let ([x], [y]) = ([1], [2])" | ||
"let [x]: [i32] = [5]" | ||
"[x] = [10]" | ||
"let [mut] [x] = [5]" | ||
"i32" | ||
"[x]: [i32]" | ||
"\"foo\"" | ||
"println!(\"!\")" | ||
"println!(\"{}\", [x]);" | ||
"return [x]" | ||
"!" | ||
"[x].[len]()" | ||
"x\[[0]\]" | ||
"[0]..[1]" | ||
"[0]," | ||
"[x].[0]" | ||
"[i32] { [x] }" | ||
"if [x] [==] [5] { [] } else { [] }" | ||
"loop { [] }" | ||
"while [true] { [] }" | ||
"[x] % [5] [==] [0]" | ||
"for ([x] = [0]; [x] [<] [10]; [x++]) { [] }" | ||
"for [x] in [0]..[10] { [] }" | ||
"[x].enumerate()" | ||
"break" | ||
"continue" | ||
"'[L]: []" | ||
"break '[L]" | ||
"continue '[L]" | ||
"[] []" | ||
"#[]\[allow(unused_variables)\]" | ||
"#[]\[allow(unreachable_code)\]" | ||
"#[]\[allow(dead_code)\]" | ||
"!" | ||
"let [x] = vec!\[[]\];" | ||
"match [x].get([7]) { [] }" | ||
"Some([x]) => [0]" | ||
"None => [0]" | ||
"mut [x]" | ||
"&[] [mut] [x]" | ||
"" | ||
"bool" | ||
"Vec<[i32]>" | ||
"|[x]| [x]" | ||
"*x" | ||
"&x" | ||
"[x].[as_str]([])" | ||
"'[a]" | ||
"<[]>" | ||
"<'[a]>" | ||
"&'a [u32]" | ||
"str" | ||
"'[a]" | ||
"impl" | ||
"impl<'[a]> [Foo]<'[a]> { [] }" | ||
"[Foo] { [] }" | ||
"[x]: [x]" | ||
"[x].[x]([])" | ||
"static" | ||
"[] use [std]::[cell]::[Cell]" | ||
"[] struct [Foo] [] { [] }" | ||
"assert_eq!([1], [1])" | ||
"#\[derive(Debug)\]" | ||
"[] struct [Foo]([])" | ||
"[] enum [Foo] [] { [] }" | ||
"[x]::[x]" | ||
"String" | ||
"[_] => [0]," | ||
"['a'] ... ['z']" | ||
"[x] @ [0] => 0," | ||
"[x] | [0] => 0," | ||
"const" | ||
"Vec::new()" | ||
"Vec::<[bool]>::new()" | ||
"[x] * [x]" | ||
"f64" | ||
"3.14159216" | ||
"assert!([1])" | ||
"b\"whatever\"" | ||
"#\[derive([Debug])\]" | ||
"impl [Drop] for [Foo] { [] }" | ||
"Debug" | ||
"Drop" | ||
"Foo" | ||
"*[mut] ([])" | ||
"fn[](*[mut] ([]))" | ||
"unsafe []" | ||
"unsafe { [] }" | ||
"Clone" | ||
"&[x] as &[Clone]" | ||
"|[x]| { [] }" | ||
"|[x]: [i32]| { [] }" | ||
"move |[x]: [i32]| { [] }" | ||
"move" | ||
"<[Foo] as [Foo]>" | ||
"\[[u8]; [10]\]" | ||
"[] pub" | ||
"macro_rules! [vec] { ( $( $[x]:[expr] ),* ) => { [] } }" | ||
"macro_rules! [x] { [] }" | ||
"$( [] )*" | ||
"$[x]" | ||
"{{ [] }}" | ||
"item" | ||
"block" | ||
"stmt" | ||
"pat" | ||
"expr" | ||
"ty" | ||
"ident" | ||
"path" | ||
"tt" | ||
"meta" | ||
"None?" | ||
"Some([x])?" | ||
"Some([x])" | ||
"![true]" | ||
"-[x]" | ||
"[] mod [math] [{}]" | ||
"#\[path = [\"x\"]\]" | ||
"#!\[crate_name = [\"x\"]\]" | ||
"#!\[crate_type = [\"lib\"]\] []" | ||
"extern crate [std]" | ||
"extern crate [std] as [std]" | ||
"#\[link([name] = [\"x\"])" | ||
"#\[cfg([test])\]" | ||
"#\[[test]\]" | ||
"#\[cfg(target_os=[\"linux\"])\]" | ||
"#\[[crate_name]=[\"x\"]\]" | ||
"#\[[plugin]([x])\]" | ||
"crate_type" | ||
"feature" | ||
"no_builtins" | ||
"no_main" | ||
"no_start" | ||
"no_std" | ||
"plugin" | ||
"recursion_limit" | ||
"main" | ||
"plugin_registrar" | ||
"start" | ||
"should_panic" | ||
"cold" | ||
"thread_local" | ||
"link_args" | ||
"link" | ||
"linked_from" | ||
"link_name" | ||
"linkage" | ||
"repr" | ||
"macro_use" | ||
"macro_reexport" | ||
"macro_export" | ||
"no_link" | ||
"export_name" | ||
"link_section" | ||
"no_mangle" | ||
"simd" | ||
"unsafe_destructor_blind_to_params" | ||
"unsafe_no_drop_flag" | ||
"doc" | ||
"rustc_on_unimplemented" | ||
"debug_assertions" | ||
"target_arch" | ||
"target_endian" | ||
"target_env" | ||
"target_family" | ||
"target_os" | ||
"target_pointer_width" | ||
"target_vendor" | ||
"unix" | ||
"windows" | ||
"allow" | ||
"deny" | ||
"forbid" | ||
"warn" | ||
"lang" | ||
"inline" | ||
"inline(always)" | ||
"inline(never)" | ||
"derive([PartialEq], [Clone])" | ||
"feature" | ||
"advanced_slice_patterns" | ||
"slice_patterns" | ||
"asm" | ||
"asm!" | ||
"asm!([\"nop\"])" | ||
"asm!(\"xor %eax, %eax\" : [] : [] : [\"eax\"])" | ||
"asm!(\"in %dx, %al\" : \"={[al]}\"([x]) : \"{[dx]}\"([x]))" | ||
"[panic]!([])" | ||
"panic" | ||
"file" | ||
"line" | ||
"debug_assert" | ||
"array" | ||
"bool" | ||
"char" | ||
"f32" | ||
"f64" | ||
"fn" | ||
"i8" | ||
"i16" | ||
"i32" | ||
"i64" | ||
"isize" | ||
"pointer" | ||
"reference" | ||
"slice" | ||
"str" | ||
"tuple" | ||
"u8" | ||
"u16" | ||
"u32" | ||
"u64" | ||
"unit" | ||
"usize" | ||
"i128" | ||
"u128" | ||
"never" |