Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcondiro committed Dec 18, 2024
2 parents 76b13d0 + d9ddf82 commit 53c0299
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 48 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ libafl_benches = { path = "./utils/libafl_benches", version = "0.14.1", default-
libafl_jumper = { path = "./utils/libafl_jumper", version = "0.14.1", default-features = false }

# External deps
ahash = { version = "0.8.11", default-features = false } # The hash function already used in hashbrown
arbitrary-int = "1.2.7" # arbitrary sized integers, useful in combination with bitfields (bitbybit crate)
ahash = { version = "0.8.11", default-features = false } # The hash function already used in hashbrown
arbitrary-int = "1.2.7" # arbitrary sized integers, useful in combination with bitfields (bitbybit crate)
backtrace = { version = "0.3.74", default-features = false } # Used to get the stacktrace in StacktraceObserver
bindgen = "0.71.1"
bitbybit = "1.3.3" # bitfields, use this for bit fields and bit enums
# 2024-12-16: bitbybit 1.3.3 is leading CI to fail due to missing docs.
# fixme: Change this to 1.3.3 when the issue https://github.com/danlehmann/bitfield/issues/66 is resolved.
bitbybit = "=1.3.2" # bitfields, use this for bit fields and bit enums
clap = "4.5.18"
cc = "1.1.21"
cmake = "0.1.51"
Expand Down
77 changes: 36 additions & 41 deletions libafl/src/observers/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use core::{
ops::{Deref, DerefMut},
};

use arbitrary_int::{u1, u4, u5, u6};
use bitbybit::bitfield;
use hashbrown::HashMap;
use libafl_bolts::{ownedref::OwnedRefMut, AsSlice, HasLen, Named};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -403,47 +405,40 @@ impl AFLppCmpValuesMetadata {
}
}

#[allow(missing_docs)] // 2024-12-15: bitfield is leading CI to fail due to missing docs.
mod aflpp_cmplog_header {
use arbitrary_int::{u1, u4, u5, u6};
use bitbybit::bitfield;

/// Comparison header, used to describe a set of comparison values efficiently.
/// Comparison header, used to describe a set of comparison values efficiently.
///
/// # Bitfields
///
/// - hits: The number of hits of a particular comparison
/// - id: Unused by ``LibAFL``, a unique ID for a particular comparison
/// - shape: Whether a comparison is u8/u8, u16/u16, etc.
/// - type_: Whether the comparison value represents an instruction (like a `cmp`) or function
/// call arguments
/// - attribute: OR-ed bitflags describing whether the comparison is <, >, =, <=, >=, or transform
/// - overflow: Whether the comparison overflows
/// - reserved: Reserved for future use
#[bitfield(u16)]
#[derive(Debug)]
pub struct AFLppCmpLogHeader {
/// The number of hits of a particular comparison
///
/// # Bitfields
/// 6 bits up to 63 entries, we have CMP_MAP_H = 32 (so using half of it)
#[bits(0..=5, r)]
hits: u6,
/// Whether a comparison is u8/u8, u16/u16, etc.
///
/// - hits: The number of hits of a particular comparison
/// - id: Unused by ``LibAFL``, a unique ID for a particular comparison
/// - shape: Whether a comparison is u8/u8, u16/u16, etc.
/// - type_: Whether the comparison value represents an instruction (like a `cmp`) or function
/// call arguments
/// - attribute: OR-ed bitflags describing whether the comparison is <, >, =, <=, >=, or transform
/// - overflow: Whether the comparison overflows
/// - reserved: Reserved for future use
#[bitfield(u16)]
#[derive(Debug)]
pub struct AFLppCmpLogHeader {
/// The number of hits of a particular comparison
///
/// 6 bits up to 63 entries, we have CMP_MAP_H = 32 (so using half of it)
#[bits(0..=5, r)]
hits: u6,
/// Whether a comparison is u8/u8, u16/u16, etc.
///
/// 31 + 1 bytes max
#[bits(6..=10, r)]
shape: u5,
/// Whether the comparison value represents an instruction (like a `cmp`) or function call
/// arguments
///
/// 2: cmp, rtn
#[bit(11, r)]
type_: u1,
/// OR-ed bitflags describing whether the comparison is <, >, =, <=, >=, or transform
///
/// 16 types for arithmetic comparison types
#[bits(12..=15, r)]
attribute: u4,
}
/// 31 + 1 bytes max
#[bits(6..=10, r)]
shape: u5,
/// Whether the comparison value represents an instruction (like a `cmp`) or function call
/// arguments
///
/// 2: cmp, rtn
#[bit(11, r)]
type_: u1,
/// OR-ed bitflags describing whether the comparison is <, >, =, <=, >=, or transform
///
/// 16 types for arithmetic comparison types
#[bits(12..=15, r)]
attribute: u4,
}
pub use aflpp_cmplog_header::AFLppCmpLogHeader;
2 changes: 1 addition & 1 deletion libafl_cc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readme = "README.md"
license = "MIT OR Apache-2.0"
keywords = ["fuzzing", "testing", "compiler"]
edition = "2021"
rust-version = "1.78"
rust-version = "1.82"
categories = [
"development-tools::testing",
"emulators",
Expand Down
2 changes: 1 addition & 1 deletion libafl_cc/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ where
let new_distance = distance + successor_info.get_weight();
let is_shorter = distances
.get(successor)
.map_or(true, |&current| new_distance < current);
.is_none_or(|&current| new_distance < current);

if is_shorter {
distances.insert(*successor, new_distance);
Expand Down
2 changes: 1 addition & 1 deletion libafl_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readme = "../README.md"
license = "MIT OR Apache-2.0"
keywords = ["fuzzing", "testing"]
edition = "2021"
rust-version = "1.78"
rust-version = "1.82"
categories = [
"development-tools::testing",
"emulators",
Expand Down
1 change: 0 additions & 1 deletion libafl_intelpt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ impl IntelPTBuilder {
/// Perf event config for `IntelPT`
///
/// (This is almost mapped to `IA32_RTIT_CTL MSR` by perf)
#[allow(missing_docs)] // 2024-12-15: bitfield is leading CI to fail due to missing docs.
#[cfg(target_os = "linux")]
#[bitfield(u64, default = 0)]
struct PtConfig {
Expand Down

0 comments on commit 53c0299

Please sign in to comment.