Table::new() can cause a segfault in safe code from dereferencing an arbitrary pointer. To illustrate:
/*
[dependencies]
bcc = "=0.0.32"
*/
use bcc::table::Table;
use std::os::raw::c_void;
fn main() {
let p = &mut 0usize as *mut _ as *mut c_void;
let mut table = Table::new(0, p);
println!("{}", table.key_size());
}
The function should probably be marked unsafe, since the other methods in Table depend on p being a valid BPF module pointer. Alternatively, it should be private (or pub(crate)), since it's really only useful in BPF::table().
Table::new()
can cause a segfault in safe code from dereferencing an arbitrary pointer. To illustrate:The function should probably be marked
unsafe
, since the other methods inTable
depend onp
being a valid BPF module pointer. Alternatively, it should be private (orpub(crate)
), since it's really only useful inBPF::table()
.