Description
hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
pub struct SkBuff {
pub skb: *mut __sk_buff,
}
impl SkBuff {
pub fn new(skb: *mut __sk_buff) -> SkBuff {
SkBuff { skb }
}
#[allow(clippy::len_without_is_empty)]
#[inline]
pub fn len(&self) -> u32 {
unsafe { (*self.skb).len }
}
............................
}
Considering that programs
is a pub mod and skb
is a pub field, I assume that users can directly manipulate this field, and that len
is a public function. This potential situation could result in self.skb
being a null pointer, and directly dereferencing it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.
Sorry, I can't provide a Poc, because trying to import SkBuff in my environment will get an error:
error[E0432]: unresolved import `aya::programs::SkBuff`
--> src/main.rs:3:5
|
3 | use aya::programs::SkBuff;
| ^^^^^^^^^^^^^^^^^^^^^ no `SkBuff` in `programs`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `lwz` (bin "lwz") due to 1 previous error
If this can be solved, I am happy to provide a Poc.