bpf: add override for bpf_probe_read_user_str

pull/67/head
Alessandro Decina 3 years ago
parent 59a1854a6b
commit 1f3acbcfe0

@ -20,6 +20,26 @@ pub unsafe fn bpf_probe_read<T>(src: *const T) -> Result<T, c_long> {
Ok(v.assume_init())
}
#[inline]
pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result<usize, c_long> {
let len = gen::bpf_probe_read_user_str(
dest.as_mut_ptr() as *mut c_void,
dest.len() as u32,
src as *const c_void,
);
if len < 0 {
return Err(-1);
}
let mut len = len as usize;
if len > dest.len() {
// this can never happen, it's needed to tell the verifier that len is
// bounded
len = dest.len();
}
Ok(len as usize)
}
#[inline]
pub fn bpf_get_current_comm() -> Result<[c_char; 16], c_long> {
let mut comm: [c_char; 16usize] = [0; 16];

Loading…
Cancel
Save