Skip to content

Commit 245580e

Browse files
authored
Cranelift: support fuzzing patchable_call. (#12118)
This allows the opcode for call-format instructions and verifies that we are calling it with the patchable ABI. Fixes https://oss-fuzz.com/testcase-detail/6014638929281024.
1 parent 1d73897 commit 245580e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cranelift/fuzzgen/src/function_generator.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,14 @@ fn insert_call(
117117
_args: &[Type],
118118
_rets: &[Type],
119119
) -> Result<()> {
120-
assert!(matches!(opcode, Opcode::Call | Opcode::CallIndirect));
120+
assert!(matches!(
121+
opcode,
122+
Opcode::Call | Opcode::CallIndirect | Opcode::PatchableCall
123+
));
121124
let (sig, sig_ref, func_ref) = fgen.u.choose(&fgen.resources.func_refs)?.clone();
125+
if opcode == Opcode::PatchableCall && sig.call_conv != CallConv::Patchable {
126+
return Err(arbitrary::Error::IncorrectFormat.into());
127+
}
122128

123129
insert_call_to_function(fgen, builder, opcode, &sig, sig_ref, func_ref)
124130
}

0 commit comments

Comments
 (0)