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

Change the type of data of ptrace::write to make it safe #2324

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

ShuiRuTian
Copy link
Contributor

@ShuiRuTian ShuiRuTian commented Feb 28, 2024

What does this PR do

Fix #2323

Change the signature of ptrace::write and ptrace::write_user to make them safe

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@ShuiRuTian
Copy link
Contributor Author

I use the same command, but could not reproduce the issue, does anyone know the reason?

I ran cargo clippy --target x86_64-unknown-linux-gnu --all-targets --all-features -- -D warnings -A unknown-lints

@SteveLauC
Copy link
Member

Well, it is indeed weird, I didn't reproduce it either...

Will investigate more.

@SteveLauC
Copy link
Member

SteveLauC commented Feb 29, 2024

I kinda think this error is a false positive?

My guess on the reason why it is triggered is that we are directly casting a c_long to a raw pointer, but I think this is fine as the kernel won't treat it as a raw pointer but an unsigned long, so we can:

  1. Allow it #[allow(clippy::not_unsafe_ptr_arg_deref)]

  2. Write a comment stating why the usages of ptrace_other() within write() and write_user() are safe

    // Safety:
    

@ShuiRuTian
Copy link
Contributor Author

Thanks for the suggestions, it's past now!

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

Thanks!

@SteveLauC SteveLauC added this pull request to the merge queue Feb 29, 2024
Merged via the queue into nix-rust:master with commit e0f1965 Feb 29, 2024
35 checks passed
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

Successfully merging this pull request may close these issues.

Change the signature of ptrace::write to make it safe
2 participants