|
|
@ -10,7 +10,7 @@ use aya_ebpf_bindings::helpers::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use aya_ebpf_cty::c_long;
|
|
|
|
use aya_ebpf_cty::c_long;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{bindings::__sk_buff, EbpfContext};
|
|
|
|
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,10 @@ 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());
|
|
|
|
|
|
|
|
let in_bounds = check_bounds_signed(len as c_long, 0, dst.len() as c_long + 1);
|
|
|
|
|
|
|
|
if !in_bounds {
|
|
|
|
|
|
|
|
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(
|
|
|
|