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

Refactors regmgr_call and privileges #663

Closed
wants to merge 18 commits into from

Conversation

SuchAFuriousDeath
Copy link
Contributor

No description provided.

@SuchAFuriousDeath SuchAFuriousDeath requested a review from a team February 18, 2024 00:23
src/kernel/src/regmgr/command.rs Outdated Show resolved Hide resolved
pub fn try_from_raw_parts(cmd: u64, arg: *mut u8) -> Result<Self, SysErr> {
/// # Safety
/// `arg` has to be a pointer to the correct value
pub unsafe fn try_from_raw_parts(cmd: u64, arg: SysArg) -> Result<Self, SysErr> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is even dangerous than the pointer because it hide the fact that the returned value have a lifetime bind to some pointer.

I guess we should required every PRs that use unsafe to be reviewed by me (or someone else who can catch this kind of bug) so we don't have a dangerous bug get merged. Here is an example of what going to happen if we violate the Rust assumption due to unsafe: #48

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried something, take a look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's that simple? :D

Copy link
Contributor Author

@SuchAFuriousDeath SuchAFuriousDeath Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a minute. To be completely honest, sometimes I don't fully understand lifetimes. The CStr struct isn't lifetimed (which is why from_ptr has a lifetime parameter and returns a lifetimed reference), but our IoCmd and RegMgrCommand are. Doesn't that make any difference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is try_from_raw_parts need to have an explicit lifetime and document it how it bind to the pointer.

@github-actions github-actions bot added the S-ready Status: Ready for review label Feb 25, 2024
@ultimaweapon ultimaweapon removed the S-ready Status: Ready for review label Feb 25, 2024
@github-actions github-actions bot added S-ready Status: Ready for review and removed S-ready Status: Ready for review labels Feb 28, 2024
@github-actions github-actions bot added the S-ready Status: Ready for review label Mar 19, 2024
@github-actions github-actions bot removed the S-ready Status: Ready for review label Mar 19, 2024
Copy link

We are closing this PR due to no any activities in the last 30 days. Feel free to re-open it if you would like to continue working on this.

@github-actions github-actions bot closed this Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants