Unsound usages of unsafe implementation about c_void
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 28
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I am scanning this crate in the latest version using my own static analyzer tool.
Unsafe pointer conversion is found at: src/netmap_user.rs:16
pub unsafe fn _NETMAP_OFFSET<T, U>(ptr: *mut U, offset: isize) -> *mut T {
((ptr as *mut c_char).offset(offset) as *mut c_void) as *mut T
}
This unsound implementation would create memory issues such as overflow, underflow, or misalignment, since the type is converted to c_void (1 byte, 8 bits). The attacker can manipulate the argument offset associated with the c_void pointer with a large value, as well as T and U, which can lead to a buffer overflow bug.
This would cause undefined behaviors in Rust. Adversaries can manipulate the associated arguments to cause memory safety bugs. I am reporting this issue for your attention.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/netmap_user.rs:16 and the _NETMAP_OFFSET function, then review Rust’s undefined-behavior requirements for raw-pointer offset, alignment, and bounds. Validate the static-analyzer report against the function’s callers and determine whether the reported conversion can produce the claimed memory-safety issue. Done means the finding has a clear resolution and appropriate verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100