Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SliceFromRaw False Negative #59

Open
stoneman258 opened this issue Sep 30, 2024 · 0 comments
Open

SliceFromRaw False Negative #59

stoneman258 opened this issue Sep 30, 2024 · 0 comments

Comments

@stoneman258
Copy link

Description:

Rudra is designed to detect unsafe usage patterns such as SliceFromRaw. However, it seems that the current version of Rudra fails to detect this pattern.

Root Cause:

The issue appears to be related to the specific path Rudra uses for detection. Currently, Rudra looks for the function under the path core::slice::from_raw_parts. However, as of a certain update in Rust (commit bcd18f9), the from_raw_parts function has been moved to a new location, and the correct path is now core::slice::raw::from_raw_parts.

Due to this change, Rudra's detection mechanism no longer matches the updated path, resulting in a failure to detect the SliceFromRaw pattern in newer versions of Rust.

Steps to Reproduce:

Run Rudra to analyze code that uses SliceFromRaw.
Observe that Rudra fails to detect the SliceFromRaw.

pub trait Writer {
    fn write_bytes(&mut self, slice: &[u8]) -> Result<(), ()>;
    fn write_u8(&mut self, value: u8) -> Result<(), ()> {
        let slice = unsafe { std::slice::from_raw_parts(&value, 1) };
        self.write_bytes(slice)
    }
}

Expected Behavior:

Rudra should report an SliceFromRaw warning for the code.

Actual Behavior:

Rudra does not report any SliceFromRaw warning.

Regression:

In previous versions of Rudra, the following code would trigger a warning.
However, in the current version of Rudra, no warning is reported for the same code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant