Fix Clippy on MacOS for qemu, accept some clippy::missing_transmute_annotations
suggestions (#2009)
* Fix Clippy/CI * Ignore transmute annotations in pybind * fix * more clippy * more clippy * fix fixes
This commit is contained in:
parent
fa58dff4b7
commit
ff938261df
@ -29,8 +29,7 @@ Welcome to `LibAFL`
|
|||||||
clippy::ptr_cast_constness,
|
clippy::ptr_cast_constness,
|
||||||
clippy::unsafe_derive_deserialize,
|
clippy::unsafe_derive_deserialize,
|
||||||
clippy::similar_names,
|
clippy::similar_names,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines
|
||||||
clippy::missing_transmute_annotations
|
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::ptr_cast_constness,
|
clippy::ptr_cast_constness,
|
||||||
clippy::negative_feature_names,
|
clippy::negative_feature_names,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines
|
||||||
clippy::missing_transmute_annotations
|
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -2492,6 +2492,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tell the broker to disconnect this client from it.
|
/// Tell the broker to disconnect this client from it.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
fn announce_client_exit(sender: &mut LlmpSender<SP>, client_id: u32) -> Result<(), Error> {
|
fn announce_client_exit(sender: &mut LlmpSender<SP>, client_id: u32) -> Result<(), Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let msg = sender
|
let msg = sender
|
||||||
|
@ -6,6 +6,7 @@ use alloc::vec::Vec;
|
|||||||
use core::any::type_name;
|
use core::any::type_name;
|
||||||
use core::{
|
use core::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
|
mem::transmute,
|
||||||
ptr::{addr_of, addr_of_mut},
|
ptr::{addr_of, addr_of_mut},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,10 +273,7 @@ where
|
|||||||
fn take<'a, T: 'static>(mut self) -> (Option<&'a T>, Self) {
|
fn take<'a, T: 'static>(mut self) -> (Option<&'a T>, Self) {
|
||||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||||
let r = self.0.take();
|
let r = self.0.take();
|
||||||
(
|
(unsafe { transmute::<Option<&Head>, Option<&T>>(r) }, self)
|
||||||
unsafe { core::mem::transmute::<Option<&Head>, Option<&T>>(r) },
|
|
||||||
self,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
let (r, tail) = self.1.take::<T>();
|
let (r, tail) = self.1.take::<T>();
|
||||||
(r, (self.0, tail))
|
(r, (self.0, tail))
|
||||||
@ -292,7 +290,7 @@ where
|
|||||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||||
let r = self.0.take();
|
let r = self.0.take();
|
||||||
(
|
(
|
||||||
unsafe { core::mem::transmute::<Option<&mut Head>, Option<&T>>(r) },
|
unsafe { transmute::<Option<&mut Head>, Option<&T>>(r) },
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@ -323,7 +321,7 @@ where
|
|||||||
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
if TypeId::of::<T>() == TypeId::of::<Head>() {
|
||||||
let r = self.0.take();
|
let r = self.0.take();
|
||||||
(
|
(
|
||||||
unsafe { core::mem::transmute::<Option<&mut Head>, Option<&mut T>>(r) },
|
unsafe { transmute::<Option<&mut Head>, Option<&mut T>>(r) },
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
clippy::missing_panics_doc,
|
clippy::missing_panics_doc,
|
||||||
clippy::missing_docs_in_private_items,
|
clippy::missing_docs_in_private_items,
|
||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::unreadable_literal,
|
clippy::unreadable_literal
|
||||||
clippy::missing_transmute_annotations
|
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -1533,7 +1533,10 @@ impl AsanRuntime {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
blob.as_ptr()
|
blob.as_ptr()
|
||||||
.copy_to_nonoverlapping(mapping as *mut u8, blob.len());
|
.copy_to_nonoverlapping(mapping as *mut u8, blob.len());
|
||||||
self.shadow_check_func = Some(std::mem::transmute(mapping as *mut u8));
|
self.shadow_check_func = Some(std::mem::transmute::<
|
||||||
|
*mut u8,
|
||||||
|
extern "C" fn(*const c_void, usize) -> bool,
|
||||||
|
>(mapping as *mut u8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1680,7 +1683,10 @@ impl AsanRuntime {
|
|||||||
{
|
{
|
||||||
libc::pthread_jit_write_protect_np(1);
|
libc::pthread_jit_write_protect_np(1);
|
||||||
}
|
}
|
||||||
self.shadow_check_func = Some(std::mem::transmute(mapping as *mut u8));
|
self.shadow_check_func = Some(std::mem::transmute::<
|
||||||
|
*mut u8,
|
||||||
|
extern "C" fn(*const c_void, usize) -> bool,
|
||||||
|
>(mapping as *mut u8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ impl CmpLogRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "cmplog", target_arch = "aarch64"))]
|
#[cfg(all(feature = "cmplog", target_arch = "aarch64"))]
|
||||||
#[allow(clippy::similar_names)]
|
#[allow(clippy::similar_names, clippy::type_complexity)]
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Check if the current instruction is cmplog relevant one(any opcode which sets the flags)
|
/// Check if the current instruction is cmplog relevant one(any opcode which sets the flags)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -765,7 +765,7 @@ impl CmpLogRuntime {
|
|||||||
.operands
|
.operands
|
||||||
.iter()
|
.iter()
|
||||||
.position(|item| *item == Operand::Nothing)
|
.position(|item| *item == Operand::Nothing)
|
||||||
.unwrap_or_else(|| 4);
|
.unwrap_or(4);
|
||||||
// "cmp" | "ands" | "subs" | "adds" | "negs" | "ngcs" | "sbcs" | "bics" | "cbz"
|
// "cmp" | "ands" | "subs" | "adds" | "negs" | "ngcs" | "sbcs" | "bics" | "cbz"
|
||||||
// | "cbnz" | "tbz" | "tbnz" | "adcs" - yaxpeax aliases insns (i.e., cmp -> subs)
|
// | "cbnz" | "tbz" | "tbnz" | "adcs" - yaxpeax aliases insns (i.e., cmp -> subs)
|
||||||
// We only care for compare instructions - aka instructions which set the flags
|
// We only care for compare instructions - aka instructions which set the flags
|
||||||
@ -846,14 +846,14 @@ impl CmpLogRuntime {
|
|||||||
None,
|
None,
|
||||||
)),
|
)),
|
||||||
Operand::ImmShift(imm, shift) => {
|
Operand::ImmShift(imm, shift) => {
|
||||||
Some((CmplogOperandType::Imm((imm as u64) << shift), None))
|
Some((CmplogOperandType::Imm(u64::from(imm) << shift), None))
|
||||||
} //precalculate the shift
|
} //precalculate the shift
|
||||||
Operand::RegShift(shiftstyle, amount, regsize, reg) => {
|
Operand::RegShift(shiftstyle, amount, regsize, reg) => {
|
||||||
let reg = CmplogOperandType::Regid(writer_register(reg, regsize, true));
|
let reg = CmplogOperandType::Regid(writer_register(reg, regsize, true));
|
||||||
let shift = (shiftstyle, amount);
|
let shift = (shiftstyle, amount);
|
||||||
Some((reg, Some(shift)))
|
Some((reg, Some(shift)))
|
||||||
}
|
}
|
||||||
Operand::Immediate(imm) => Some((CmplogOperandType::Imm(imm as u64), None)),
|
Operand::Immediate(imm) => Some((CmplogOperandType::Imm(u64::from(imm)), None)),
|
||||||
_ => panic!("Second argument could not be decoded"),
|
_ => panic!("Second argument could not be decoded"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,7 @@ Additional documentation is available in [the `LibAFL` book](https://aflplus.plu
|
|||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::unreadable_literal,
|
clippy::unreadable_literal,
|
||||||
clippy::ptr_cast_constness,
|
clippy::ptr_cast_constness,
|
||||||
clippy::must_use_candidate,
|
clippy::must_use_candidate
|
||||||
clippy::missing_transmute_annotations
|
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -10,6 +10,7 @@ const QEMU_URL: &str = "https://github.com/AFLplusplus/qemu-libafl-bridge";
|
|||||||
const QEMU_DIRNAME: &str = "qemu-libafl-bridge";
|
const QEMU_DIRNAME: &str = "qemu-libafl-bridge";
|
||||||
const QEMU_REVISION: &str = "821ad471430360c4eed644d07d59f0d603ef23f6";
|
const QEMU_REVISION: &str = "821ad471430360c4eed644d07d59f0d603ef23f6";
|
||||||
|
|
||||||
|
#[allow(clippy::module_name_repetitions)]
|
||||||
pub struct BuildResult {
|
pub struct BuildResult {
|
||||||
pub qemu_path: PathBuf,
|
pub qemu_path: PathBuf,
|
||||||
pub build_dir: PathBuf,
|
pub build_dir: PathBuf,
|
||||||
|
@ -14,9 +14,11 @@ __Warning__: The documentation is built by default for `x86_64` in `usermode`. T
|
|||||||
#![allow(clippy::pedantic)]
|
#![allow(clippy::pedantic)]
|
||||||
|
|
||||||
#[cfg(all(not(feature = "clippy"), target_os = "linux"))]
|
#[cfg(all(not(feature = "clippy"), target_os = "linux"))]
|
||||||
|
mod bindings {
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "clippy", target_os = "linux"))]
|
#[cfg(any(feature = "clippy", not(target_os = "linux")))]
|
||||||
mod x86_64_stub_bindings;
|
mod x86_64_stub_bindings;
|
||||||
|
|
||||||
#[cfg(emulation_mode = "usermode")]
|
#[cfg(emulation_mode = "usermode")]
|
||||||
@ -98,7 +100,11 @@ macro_rules! extern_c_checked {
|
|||||||
use core::ops::BitAnd;
|
use core::ops::BitAnd;
|
||||||
use std::{ffi::c_void, slice::from_raw_parts, str::from_utf8_unchecked};
|
use std::{ffi::c_void, slice::from_raw_parts, str::from_utf8_unchecked};
|
||||||
|
|
||||||
#[cfg(all(feature = "clippy", target_os = "linux"))]
|
#[cfg(all(not(feature = "clippy"), target_os = "linux"))]
|
||||||
|
pub use bindings::*;
|
||||||
|
#[cfg(feature = "python")]
|
||||||
|
use pyo3::{pyclass, pymethods, IntoPy, PyObject, Python};
|
||||||
|
#[cfg(any(feature = "clippy", not(target_os = "linux")))]
|
||||||
pub use x86_64_stub_bindings::*;
|
pub use x86_64_stub_bindings::*;
|
||||||
|
|
||||||
pub type CPUStatePtr = *mut crate::CPUState;
|
pub type CPUStatePtr = *mut crate::CPUState;
|
||||||
|
@ -625,25 +625,25 @@ pub struct HookData(u64);
|
|||||||
|
|
||||||
impl<T> From<Pin<&mut T>> for HookData {
|
impl<T> From<Pin<&mut T>> for HookData {
|
||||||
fn from(value: Pin<&mut T>) -> Self {
|
fn from(value: Pin<&mut T>) -> Self {
|
||||||
unsafe { HookData(core::mem::transmute(value)) }
|
unsafe { HookData(transmute::<Pin<&mut T>, u64>(value)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<Pin<&T>> for HookData {
|
impl<T> From<Pin<&T>> for HookData {
|
||||||
fn from(value: Pin<&T>) -> Self {
|
fn from(value: Pin<&T>) -> Self {
|
||||||
unsafe { HookData(core::mem::transmute(value)) }
|
unsafe { HookData(transmute::<Pin<&T>, u64>(value)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<&'static mut T> for HookData {
|
impl<T> From<&'static mut T> for HookData {
|
||||||
fn from(value: &'static mut T) -> Self {
|
fn from(value: &'static mut T) -> Self {
|
||||||
unsafe { HookData(core::mem::transmute(value)) }
|
unsafe { HookData(transmute::<&mut T, u64>(value)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<&'static T> for HookData {
|
impl<T> From<&'static T> for HookData {
|
||||||
fn from(value: &'static T) -> Self {
|
fn from(value: &'static T) -> Self {
|
||||||
unsafe { HookData(core::mem::transmute(value)) }
|
unsafe { HookData(transmute::<&T, u64>(value)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
fn post_run(&self) -> Result<QemuExitReason, QemuExitReasonError> {
|
fn post_run(&self) -> Result<QemuExitReason, QemuExitReasonError> {
|
||||||
let exit_reason = unsafe { libafl_get_exit_reason() };
|
let exit_reason = unsafe { libafl_get_exit_reason() };
|
||||||
if exit_reason.is_null() {
|
if exit_reason.is_null() {
|
||||||
@ -1068,6 +1068,7 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO set T lifetime to be like Emulator
|
// TODO set T lifetime to be like Emulator
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn set_hook<T: Into<HookData>>(
|
pub fn set_hook<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1077,7 +1078,7 @@ impl Qemu {
|
|||||||
) -> InstructionHookId {
|
) -> InstructionHookId {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let callback: extern "C" fn(u64, GuestAddr) = core::mem::transmute(callback);
|
let callback: extern "C" fn(u64, GuestAddr) = transmute(callback);
|
||||||
let num = libafl_qemu_sys::libafl_qemu_set_hook(
|
let num = libafl_qemu_sys::libafl_qemu_set_hook(
|
||||||
addr.into(),
|
addr.into(),
|
||||||
Some(callback),
|
Some(callback),
|
||||||
@ -1100,6 +1101,7 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_edge_hooks<T: Into<HookData>>(
|
pub fn add_edge_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1108,14 +1110,14 @@ impl Qemu {
|
|||||||
) -> EdgeHookId {
|
) -> EdgeHookId {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let gen: Option<extern "C" fn(u64, GuestAddr, GuestAddr) -> u64> =
|
let gen: Option<extern "C" fn(u64, GuestAddr, GuestAddr) -> u64> = transmute(gen);
|
||||||
core::mem::transmute(gen);
|
let exec: Option<extern "C" fn(u64, u64)> = transmute(exec);
|
||||||
let exec: Option<extern "C" fn(u64, u64)> = core::mem::transmute(exec);
|
|
||||||
let num = libafl_qemu_sys::libafl_add_edge_hook(gen, exec, data);
|
let num = libafl_qemu_sys::libafl_add_edge_hook(gen, exec, data);
|
||||||
EdgeHookId(num)
|
EdgeHookId(num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_block_hooks<T: Into<HookData>>(
|
pub fn add_block_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1125,15 +1127,15 @@ impl Qemu {
|
|||||||
) -> BlockHookId {
|
) -> BlockHookId {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let gen: Option<extern "C" fn(u64, GuestAddr) -> u64> = core::mem::transmute(gen);
|
let gen: Option<extern "C" fn(u64, GuestAddr) -> u64> = transmute(gen);
|
||||||
let post_gen: Option<extern "C" fn(u64, GuestAddr, GuestUsize)> =
|
let post_gen: Option<extern "C" fn(u64, GuestAddr, GuestUsize)> = transmute(post_gen);
|
||||||
core::mem::transmute(post_gen);
|
let exec: Option<extern "C" fn(u64, u64)> = transmute(exec);
|
||||||
let exec: Option<extern "C" fn(u64, u64)> = core::mem::transmute(exec);
|
|
||||||
let num = libafl_qemu_sys::libafl_add_block_hook(gen, post_gen, exec, data);
|
let num = libafl_qemu_sys::libafl_add_block_hook(gen, post_gen, exec, data);
|
||||||
BlockHookId(num)
|
BlockHookId(num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_read_hooks<T: Into<HookData>>(
|
pub fn add_read_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1147,13 +1149,12 @@ impl Qemu {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let gen: Option<extern "C" fn(u64, GuestAddr, libafl_qemu_sys::MemOpIdx) -> u64> =
|
let gen: Option<extern "C" fn(u64, GuestAddr, libafl_qemu_sys::MemOpIdx) -> u64> =
|
||||||
core::mem::transmute(gen);
|
transmute(gen);
|
||||||
let exec1: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec1);
|
let exec1: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec1);
|
||||||
let exec2: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec2);
|
let exec2: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec2);
|
||||||
let exec4: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec4);
|
let exec4: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec4);
|
||||||
let exec8: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec8);
|
let exec8: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec8);
|
||||||
let exec_n: Option<extern "C" fn(u64, u64, GuestAddr, usize)> =
|
let exec_n: Option<extern "C" fn(u64, u64, GuestAddr, usize)> = transmute(exec_n);
|
||||||
core::mem::transmute(exec_n);
|
|
||||||
let num = libafl_qemu_sys::libafl_add_read_hook(
|
let num = libafl_qemu_sys::libafl_add_read_hook(
|
||||||
gen, exec1, exec2, exec4, exec8, exec_n, data,
|
gen, exec1, exec2, exec4, exec8, exec_n, data,
|
||||||
);
|
);
|
||||||
@ -1162,6 +1163,7 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO add MemOp info
|
// TODO add MemOp info
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_write_hooks<T: Into<HookData>>(
|
pub fn add_write_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1175,13 +1177,12 @@ impl Qemu {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let gen: Option<extern "C" fn(u64, GuestAddr, libafl_qemu_sys::MemOpIdx) -> u64> =
|
let gen: Option<extern "C" fn(u64, GuestAddr, libafl_qemu_sys::MemOpIdx) -> u64> =
|
||||||
core::mem::transmute(gen);
|
transmute(gen);
|
||||||
let exec1: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec1);
|
let exec1: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec1);
|
||||||
let exec2: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec2);
|
let exec2: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec2);
|
||||||
let exec4: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec4);
|
let exec4: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec4);
|
||||||
let exec8: Option<extern "C" fn(u64, u64, GuestAddr)> = core::mem::transmute(exec8);
|
let exec8: Option<extern "C" fn(u64, u64, GuestAddr)> = transmute(exec8);
|
||||||
let exec_n: Option<extern "C" fn(u64, u64, GuestAddr, usize)> =
|
let exec_n: Option<extern "C" fn(u64, u64, GuestAddr, usize)> = transmute(exec_n);
|
||||||
core::mem::transmute(exec_n);
|
|
||||||
let num = libafl_qemu_sys::libafl_add_write_hook(
|
let num = libafl_qemu_sys::libafl_add_write_hook(
|
||||||
gen, exec1, exec2, exec4, exec8, exec_n, data,
|
gen, exec1, exec2, exec4, exec8, exec_n, data,
|
||||||
);
|
);
|
||||||
@ -1189,6 +1190,7 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_cmp_hooks<T: Into<HookData>>(
|
pub fn add_cmp_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1200,17 +1202,17 @@ impl Qemu {
|
|||||||
) -> CmpHookId {
|
) -> CmpHookId {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let gen: Option<extern "C" fn(u64, GuestAddr, usize) -> u64> =
|
let gen: Option<extern "C" fn(u64, GuestAddr, usize) -> u64> = transmute(gen);
|
||||||
core::mem::transmute(gen);
|
let exec1: Option<extern "C" fn(u64, u64, u8, u8)> = transmute(exec1);
|
||||||
let exec1: Option<extern "C" fn(u64, u64, u8, u8)> = core::mem::transmute(exec1);
|
let exec2: Option<extern "C" fn(u64, u64, u16, u16)> = transmute(exec2);
|
||||||
let exec2: Option<extern "C" fn(u64, u64, u16, u16)> = core::mem::transmute(exec2);
|
let exec4: Option<extern "C" fn(u64, u64, u32, u32)> = transmute(exec4);
|
||||||
let exec4: Option<extern "C" fn(u64, u64, u32, u32)> = core::mem::transmute(exec4);
|
let exec8: Option<extern "C" fn(u64, u64, u64, u64)> = transmute(exec8);
|
||||||
let exec8: Option<extern "C" fn(u64, u64, u64, u64)> = core::mem::transmute(exec8);
|
|
||||||
let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
|
let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
|
||||||
CmpHookId(num)
|
CmpHookId(num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_backdoor_hook<T: Into<HookData>>(
|
pub fn add_backdoor_hook<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
data: T,
|
data: T,
|
||||||
@ -1218,7 +1220,7 @@ impl Qemu {
|
|||||||
) -> BackdoorHookId {
|
) -> BackdoorHookId {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data: u64 = data.into().0;
|
let data: u64 = data.into().0;
|
||||||
let callback: extern "C" fn(u64, GuestAddr) = core::mem::transmute(callback);
|
let callback: extern "C" fn(u64, GuestAddr) = transmute(callback);
|
||||||
let num = libafl_qemu_sys::libafl_add_backdoor_hook(Some(callback), data);
|
let num = libafl_qemu_sys::libafl_add_backdoor_hook(Some(callback), data);
|
||||||
BackdoorHookId(num)
|
BackdoorHookId(num)
|
||||||
}
|
}
|
||||||
@ -1227,7 +1229,10 @@ impl Qemu {
|
|||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn add_gdb_cmd(&self, callback: Box<dyn FnMut(&Self, &str) -> bool>) {
|
pub fn add_gdb_cmd(&self, callback: Box<dyn FnMut(&Self, &str) -> bool>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let fat: Box<FatPtr> = Box::new(transmute(callback));
|
let fat: Box<FatPtr> = Box::new(transmute::<
|
||||||
|
Box<dyn for<'a, 'b> FnMut(&'a Qemu, &'b str) -> bool>,
|
||||||
|
FatPtr,
|
||||||
|
>(callback));
|
||||||
libafl_qemu_add_gdb_cmd(gdb_cmd, core::ptr::from_ref(&*fat) as *const ());
|
libafl_qemu_add_gdb_cmd(gdb_cmd, core::ptr::from_ref(&*fat) as *const ());
|
||||||
GDB_COMMANDS.push(fat);
|
GDB_COMMANDS.push(fat);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! The high-level hooks
|
//! The high-level hooks
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity, clippy::missing_transmute_annotations)]
|
||||||
|
|
||||||
#[cfg(emulation_mode = "usermode")]
|
#[cfg(emulation_mode = "usermode")]
|
||||||
use core::ptr::addr_of_mut;
|
use core::ptr::addr_of_mut;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#![allow(clippy::transmute_ptr_to_ptr)]
|
#![allow(clippy::transmute_ptr_to_ptr)]
|
||||||
#![allow(clippy::ptr_cast_constness)]
|
#![allow(clippy::ptr_cast_constness)]
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
#![allow(clippy::missing_transmute_annotations)]
|
|
||||||
// Till they fix this buggy lint in clippy
|
// Till they fix this buggy lint in clippy
|
||||||
#![allow(clippy::borrow_as_ptr)]
|
#![allow(clippy::borrow_as_ptr)]
|
||||||
#![allow(clippy::borrow_deref_ref)]
|
#![allow(clippy::borrow_deref_ref)]
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
clippy::missing_panics_doc,
|
clippy::missing_panics_doc,
|
||||||
clippy::missing_docs_in_private_items,
|
clippy::missing_docs_in_private_items,
|
||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::pub_underscore_fields,
|
clippy::pub_underscore_fields
|
||||||
clippy::missing_transmute_annotations
|
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -11,13 +11,13 @@ fi
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
echo "[+] Fixing build"
|
echo "[+] Fixing build"
|
||||||
cargo +nightly fix --release --workspace --all-features
|
cargo +nightly fix --release --workspace --all-features --allow-dirty --allow-staged
|
||||||
|
|
||||||
echo "[+] Done fixing build"
|
echo "[+] Done fixing build"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo 'Fixing clippy (might need a "git commit" and a rerun, if "cargo fix" changed the source)'
|
echo 'Fixing clippy (might need a "git commit" and a rerun, if "cargo fix" changed the source)'
|
||||||
RUST_BACKTRACE=full cargo +nightly clippy --fix --release --all --all-features --tests --examples --benches -- -Z macro-backtrace \
|
RUST_BACKTRACE=full cargo +nightly clippy --fix --release --all --all-features --tests --examples --benches --allow-dirty --allow-staged -- -Z macro-backtrace \
|
||||||
-D clippy::all \
|
-D clippy::all \
|
||||||
-D clippy::pedantic \
|
-D clippy::pedantic \
|
||||||
-W clippy::similar_names \
|
-W clippy::similar_names \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user