|
|
@ -10,7 +10,7 @@ use aya_ebpf_bindings::helpers::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use aya_ebpf_cty::c_long;
|
|
|
|
use aya_ebpf_cty::c_long;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{EbpfContext, bindings::__sk_buff};
|
|
|
|
use crate::{bindings::__sk_buff, check_bounds_signed, EbpfContext};
|
|
|
|
|
|
|
|
|
|
|
|
pub struct SkBuff {
|
|
|
|
pub struct SkBuff {
|
|
|
|
pub skb: *mut __sk_buff,
|
|
|
|
pub skb: *mut __sk_buff,
|
|
|
@ -90,6 +90,9 @@ impl SkBuff {
|
|
|
|
let len = usize::try_from(self.len()).map_err(|core::num::TryFromIntError { .. }| -1)?;
|
|
|
|
let len = usize::try_from(self.len()).map_err(|core::num::TryFromIntError { .. }| -1)?;
|
|
|
|
let len = len.checked_sub(offset).ok_or(-1)?;
|
|
|
|
let len = len.checked_sub(offset).ok_or(-1)?;
|
|
|
|
let len = len.min(dst.len());
|
|
|
|
let len = len.min(dst.len());
|
|
|
|
|
|
|
|
if !check_bounds_signed(len as c_long, 1, dst.len() as c_long) {
|
|
|
|
|
|
|
|
return Err(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
let len_u32 = u32::try_from(len).map_err(|core::num::TryFromIntError { .. }| -1)?;
|
|
|
|
let len_u32 = u32::try_from(len).map_err(|core::num::TryFromIntError { .. }| -1)?;
|
|
|
|
let ret = unsafe {
|
|
|
|
let ret = unsafe {
|
|
|
|
bpf_skb_load_bytes(
|
|
|
|
bpf_skb_load_bytes(
|
|
|
|