Skip to content

Commit 02cd260

Browse files
authored
Update LibAFL concolic (#1634)
* concolic upd * more * working * clippy * rev * fix * remove cur_input * rev * gitignore
1 parent c9403cb commit 02cd260

File tree

8 files changed

+41
-5
lines changed

8 files changed

+41
-5
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vendor
2222

2323
.cur_input
2424
.cur_input_*
25+
cur_input
2526
.venv
2627

2728
crashes
@@ -60,3 +61,8 @@ libafl_nyx/QEMU-Nyx
6061
libafl_nyx/packer
6162

6263
.z3-trace
64+
65+
# No gdb history
66+
.gdb_history
67+
# No llvm IR
68+
*.ll

fuzzers/libfuzzer_stb_image_concolic/Makefile.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ clear = true
5151
script='''
5252
cd fuzzer
5353
cargo clean
54-
cd ../runtime
54+
cd ..
55+
cd ./runtime
5556
cargo clean
56-
'''
57+
cd ..
58+
cargo clean
59+
'''

fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ struct Opt {
6060
concolic: bool,
6161
}
6262

63+
use std::fs;
6364
pub fn main() {
6465
// Registry the metadata types used in this fuzzer
6566
// Needed only on no_std
6667
// unsafe { RegistryBuilder::register::<Tokens>(); }
6768

6869
let opt = Opt::parse();
69-
70+
let _ = fs::remove_file("cur_input");
7071
println!(
7172
"Workdir: {:?}",
7273
env::current_dir().unwrap().to_string_lossy().to_string()

libafl/src/observers/concolic/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ pub enum SymExpr {
252252
a: SymExprRef,
253253
b: SymExprRef,
254254
},
255-
255+
FloatNeg {
256+
op: SymExprRef,
257+
},
256258
FloatAbs {
257259
op: SymExprRef,
258260
},
@@ -277,6 +279,11 @@ pub enum SymExpr {
277279
b: SymExprRef,
278280
},
279281

282+
Ite {
283+
cond: SymExprRef,
284+
a: SymExprRef,
285+
b: SymExprRef,
286+
},
280287
Sext {
281288
op: SymExprRef,
282289
bits: u8,

libafl/src/observers/concolic/serialization_format.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl<R: Read> MessageFileReader<R> {
110110

111111
/// This transforms the given message from it's serialized form into its in-memory form, making relative references
112112
/// absolute and counting the `SymExprRef`s.
113+
#[allow(clippy::too_many_lines)]
113114
fn transform_message(&mut self, message: &mut SymExpr) -> SymExprRef {
114115
let ret = self.current_id;
115116
match message {
@@ -125,6 +126,7 @@ impl<R: Read> MessageFileReader<R> {
125126
}
126127
SymExpr::Neg { op }
127128
| SymExpr::FloatAbs { op }
129+
| SymExpr::FloatNeg { op }
128130
| SymExpr::Not { op }
129131
| SymExpr::Sext { op, .. }
130132
| SymExpr::Zext { op, .. }
@@ -204,6 +206,12 @@ impl<R: Read> MessageFileReader<R> {
204206
}
205207
}
206208
SymExpr::Call { .. } | SymExpr::Return { .. } | SymExpr::BasicBlock { .. } => {}
209+
SymExpr::Ite { cond, a, b } => {
210+
*cond = self.make_absolute(*cond);
211+
*a = self.make_absolute(*a);
212+
*b = self.make_absolute(*b);
213+
self.current_id += 1;
214+
}
207215
}
208216
SymExprRef::new(ret).unwrap()
209217
}
@@ -291,6 +299,7 @@ impl<W: Write + Seek> MessageFileWriter<W> {
291299
}
292300
SymExpr::Neg { op }
293301
| SymExpr::FloatAbs { op }
302+
| SymExpr::FloatNeg { op }
294303
| SymExpr::Not { op }
295304
| SymExpr::Sext { op, .. }
296305
| SymExpr::Zext { op, .. }
@@ -370,6 +379,11 @@ impl<W: Write + Seek> MessageFileWriter<W> {
370379
}
371380
}
372381
SymExpr::Call { .. } | SymExpr::Return { .. } | SymExpr::BasicBlock { .. } => {}
382+
SymExpr::Ite { cond, a, b } => {
383+
*cond = self.make_relative(*cond);
384+
*a = self.make_relative(*a);
385+
*b = self.make_relative(*b);
386+
}
373387
}
374388
self.serialization_options
375389
.serialize_into(&mut self.writer, &message)?;

libafl_concolic/symcc_libafl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/// The URL of the `LibAFL` `SymCC` fork.
66
pub const SYMCC_REPO_URL: &str = "https://github.com/AFLplusplus/symcc.git";
77
/// The commit of the `LibAFL` `SymCC` fork.
8-
pub const SYMCC_REPO_COMMIT: &str = "2a3229da6101596af220f20fef5085e59537abcb";
8+
pub const SYMCC_REPO_COMMIT: &str = "6909c3f2b98c6e14a25bee0fc6eb29c598250e35";
99

1010
#[cfg(feature = "clone")]
1111
mod clone {

libafl_concolic/symcc_runtime/src/filter.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,7 @@ impl Filter for NoFloat {
240240
fn build_fp_rem(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
241241
false
242242
}
243+
fn build_fp_neg(&mut self, _a: RSymExpr) -> bool {
244+
false
245+
}
243246
}

libafl_concolic/symcc_runtime/src/tracing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl Runtime for TracingRuntime {
127127
binary_expression_builder!(build_fp_rem, FloatRem);
128128

129129
unary_expression_builder!(build_fp_abs, FloatAbs);
130+
unary_expression_builder!(build_fp_neg, FloatNeg);
130131

131132
unary_expression_builder!(build_not, Not);
132133
binary_expression_builder!(build_equal, Equal);
@@ -135,6 +136,7 @@ impl Runtime for TracingRuntime {
135136
binary_expression_builder!(build_bool_or, BoolOr);
136137
binary_expression_builder!(build_bool_xor, BoolXor);
137138

139+
expression_builder!(build_ite(cond: RSymExpr, a: RSymExpr, b: RSymExpr) => Ite);
138140
expression_builder!(build_sext(op: RSymExpr, bits: u8) => Sext);
139141
expression_builder!(build_zext(op: RSymExpr, bits: u8) => Zext);
140142
expression_builder!(build_trunc(op: RSymExpr, bits: u8) => Trunc);

0 commit comments

Comments
 (0)