Skip to content

Commit

Permalink
Fixed CI by ignoring python, resolved multiple warnings (#303)
Browse files Browse the repository at this point in the history
* fixing ci

* ignoring dev deps

* fmt

* trying to fix dockerfile

* fix cargo build

* can't build sancov edges and hitcounts together

* fixed warnings

* fixed more warnings
  • Loading branch information
domenukk authored Sep 27, 2021
1 parent a0cdaf7 commit 9d669bb
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 48 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ jobs:
- name: Run a normal build
run: cargo build --verbose
# cargo-hack tests/checks each crate in the workspace
- name: Run tests
run: cargo hack test --all-features
#- name: Run tests
# run: cargo hack test --all-features
# cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs
- name: Check each feature
run: cargo hack check --each-feature
# Skipping python as it has to be built with the `maturin` tool
run: cargo hack check --feature-powerset --depth=2 --exclude-features=python,sancov_pcguard_edges,sancov_pcguard_edges_ptr --no-dev-deps
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
- name: Check pcguard edges
run: cargo check --features=sancov_pcguard_edges,sancov_pcguard_edges_ptr
- name: Build examples
run: cargo build --examples --verbose
- uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ COPY libafl_frida/src/gettls.c libafl_frida/src/gettls.c

COPY libafl_qemu/Cargo.toml libafl_qemu/build.rs libafl_qemu/
COPY scripts/dummy.rs libafl_qemu/src/lib.rs
COPY libafl_qemu/src/weaks.c libafl_qemu/src/weaks.c

COPY libafl_sugar/Cargo.toml libafl_sugar/
COPY scripts/dummy.rs libafl_sugar/src/lib.rs
Expand Down
16 changes: 8 additions & 8 deletions fuzzers/baby_fuzzer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub fn main() {
if buf.len() > 1 && buf[1] == b'b' {
signals_set(2);
if buf.len() > 2 && buf[2] == b'c' {
#[cfg(unix)]
panic!("=(");

// panic!() raises a STATUS_STACK_BUFFER_OVERRUN exception which cannot be caught by the exception handler.
// Here we make it raise STATUS_ACCESS_VIOLATION instead.
// Extending the windows exception handler is a TODO. Maybe we can refer to what winafl code does.
// https://github.com/googleprojectzero/winafl/blob/ea5f6b85572980bb2cf636910f622f36906940aa/winafl.c#L728
#[cfg(windows)]
unsafe {
#[cfg(unix)]
panic!("=(");

// panic!() raises a STATUS_STACK_BUFFER_OVERRUN exception which cannot be caught by the exception handler.
// Here we make it raise STATUS_ACCESS_VIOLATION instead.
// Extending the windows exception handler is a TODO. Maybe we can refer to what winafl code does.
// https://github.com/googleprojectzero/winafl/blob/ea5f6b85572980bb2cf636910f622f36906940aa/winafl.c#L728
#[cfg(windows)]
write_volatile(0 as *mut u32, 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions fuzzers/libfuzzer_reachability/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
&mut fuzzer,
&mut executor,
&mut restarting_mgr,
&corpus_dirs,
corpus_dirs,
)
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", &corpus_dirs));
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", corpus_dirs));
println!("We imported {} inputs from disk.", state.corpus().count());
}

Expand Down
4 changes: 2 additions & 2 deletions fuzzers/libfuzzer_stb_image/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
&mut fuzzer,
&mut executor,
&mut restarting_mgr,
&corpus_dirs,
corpus_dirs,
)
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", &corpus_dirs));
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", corpus_dirs));
println!("We imported {} inputs from disk.", state.corpus().count());
}

Expand Down
18 changes: 3 additions & 15 deletions libafl/src/bolts/llmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,11 +1675,6 @@ where
/// This allows us to intercept messages right in the broker
/// This keeps the out map clean.
pub llmp_clients: Vec<LlmpReceiver<SP>>,
/// This is the socket name, when unix domain sockets are used.
socket_name: Option<String>,
/// This flag is used to indicate that shutdown has been requested by the SIGINT and SIGTERM
/// handlers
shutting_down: bool,
/// The ShMemProvider to use
shmem_provider: SP,
}
Expand Down Expand Up @@ -1726,8 +1721,6 @@ where
shmem_provider: shmem_provider.clone(),
},
llmp_clients: vec![],
socket_name: None,
shutting_down: false,
shmem_provider,
})
}
Expand Down Expand Up @@ -2350,7 +2343,6 @@ pub struct LlmpClient<SP>
where
SP: ShMemProvider,
{
shmem_provider: SP,
/// Outgoing channel to the broker
pub sender: LlmpSender<SP>,
/// Incoming (broker) broadcast map
Expand Down Expand Up @@ -2381,11 +2373,10 @@ where
last_msg_recvd_offset,
)?,
sender: LlmpSender::on_existing_map(
shmem_provider.clone(),
shmem_provider,
current_broker_map,
last_msg_recvd_offset,
)?,
shmem_provider,
})
}

Expand All @@ -2398,10 +2389,9 @@ where
&format!("{}_SENDER", env_name),
)?,
receiver: LlmpReceiver::on_existing_from_env(
shmem_provider.clone(),
shmem_provider,
&format!("{}_RECEIVER", env_name),
)?,
shmem_provider,
})
}

Expand Down Expand Up @@ -2432,10 +2422,9 @@ where
&description.sender,
)?,
receiver: LlmpReceiver::on_existing_from_description(
shmem_provider.clone(),
shmem_provider,
&description.receiver,
)?,
shmem_provider,
})
}

Expand Down Expand Up @@ -2484,7 +2473,6 @@ where
last_msg_recvd: ptr::null_mut(),
shmem_provider: shmem_provider.clone(),
},
shmem_provider,
})
}

Expand Down
2 changes: 1 addition & 1 deletion libafl/src/stages/concolic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use crate::{
start_timer, Evaluator,
};

#[cfg(feature = "concolic_mutation")]
#[cfg(all(feature = "concolic_mutation", feature = "introspection"))]
use crate::stats::PerfFeature;

#[cfg(feature = "concolic_mutation")]
Expand Down
3 changes: 0 additions & 3 deletions libafl/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ where
{
print_fn: F,
start_time: Duration,
corpus_size: usize,
client_stats: Vec<ClientStats>,
}

Expand Down Expand Up @@ -308,7 +307,6 @@ where
Self {
print_fn,
start_time: current_time(),
corpus_size: 0,
client_stats: vec![],
}
}
Expand All @@ -318,7 +316,6 @@ where
Self {
print_fn,
start_time,
corpus_size: 0,
client_stats: vec![],
}
}
Expand Down
3 changes: 0 additions & 3 deletions libafl/src/stats/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ where
{
print_fn: F,
start_time: Duration,
corpus_size: usize,
client_stats: Vec<ClientStats>,
}

Expand Down Expand Up @@ -99,7 +98,6 @@ where
Self {
print_fn,
start_time: current_time(),
corpus_size: 0,
client_stats: vec![],
}
}
Expand All @@ -109,7 +107,6 @@ where
Self {
print_fn,
start_time,
corpus_size: 0,
client_stats: vec![],
}
}
Expand Down
5 changes: 4 additions & 1 deletion libafl_qemu/src/emu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ pub fn init(args: &[String], env: &[(String, String)]) -> i32 {
let args: Vec<String> = args.iter().map(|x| x.clone() + "\0").collect();
let argv: Vec<*const u8> = args.iter().map(|x| x.as_bytes().as_ptr()).collect();
assert!(argv.len() < i32::MAX as usize);
let env_strs: Vec<String> = env.iter().map(|(k, v)| format!("{}={}\0", &k, &v)).collect();
let env_strs: Vec<String> = env
.iter()
.map(|(k, v)| format!("{}={}\0", &k, &v))
.collect();
let mut envp: Vec<*const u8> = env_strs.iter().map(|x| x.as_bytes().as_ptr()).collect();
envp.push(null());
#[allow(clippy::cast_possible_wrap)]
Expand Down
16 changes: 9 additions & 7 deletions libafl_qemu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ pub fn python_module(_py: Python, m: &PyModule) -> PyResult<()> {
use pyo3::exceptions::PyValueError;

#[pyfn(m)]
#[allow(clippy::needless_pass_by_value)]
fn init(args: Vec<String>, env: Vec<(String, String)>) -> i32 {
emu::init(&args, &env)
}

#[pyfn(m)]
#[allow(clippy::needless_pass_by_value)]
fn write_mem(addr: u64, buf: &[u8]) {
emu::write_mem(addr, buf)
emu::write_mem(addr, buf);
}
#[pyfn(m)]
fn read_mem(addr: u64, size: usize) -> Vec<u8> {
Expand All @@ -65,27 +67,27 @@ pub fn python_module(_py: Python, m: &PyModule) -> PyResult<()> {
}
#[pyfn(m)]
fn write_reg(reg: i32, val: u64) -> PyResult<()> {
emu::write_reg(reg, val).map_err(|e| PyValueError::new_err(e))
emu::write_reg(reg, val).map_err(PyValueError::new_err)
}
#[pyfn(m)]
fn read_reg(reg: i32) -> PyResult<u64> {
emu::read_reg(reg).map_err(|e| PyValueError::new_err(e))
emu::read_reg(reg).map_err(PyValueError::new_err)
}
#[pyfn(m)]
fn set_breakpoint(addr: u64) {
emu::set_breakpoint(addr)
emu::set_breakpoint(addr);
}
#[pyfn(m)]
fn remove_breakpoint(addr: u64) {
emu::remove_breakpoint(addr)
emu::remove_breakpoint(addr);
}
#[pyfn(m)]
fn run() {
emu::run()
emu::run();
}
#[pyfn(m)]
fn g2h(addr: u64) -> u64 {
unsafe { transmute(emu::g2h::<*const u8>(addr)) }
unsafe { emu::g2h::<*const u8>(addr) as u64 }
}
#[pyfn(m)]
fn h2g(addr: u64) -> u64 {
Expand Down
4 changes: 2 additions & 2 deletions libafl_targets/src/sancov_pcguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use crate::coverage::{EDGES_MAP, MAX_EDGES_NUM};
))]
#[cfg(not(any(doc, feature = "clippy")))]
compile_error!(
"the libafl_targets `pcguard_edges_ptr` and `pcguard_hitcounts_ptr` features are mutually exclusive."
"the libafl_targets `sancov_pcguard_edges_ptr` and `sancov_pcguard_hitcounts_ptr` features are mutually exclusive."
);

#[cfg(all(feature = "sancov_pcguard_edges", feature = "sancov_pcguard_hitcounts"))]
#[cfg(not(any(doc, feature = "clippy")))]
compile_error!(
"the libafl_targets `pcguard_edges` and `pcguard_hitcounts` features are mutually exclusive."
"the libafl_targets `sancov_pcguard_edges` and `sancov_pcguard_hitcounts` features are mutually exclusive."
);

/// Callback for sancov `pc_guard` - usually called by `llvm` on each block or edge.
Expand Down

0 comments on commit 9d669bb

Please sign in to comment.