Skip to content

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

Merged
SteveLauC merged 3 commits intonix-rust:masterfrom
ShuiRuTian:make-ptrace-write-safe
Feb 29, 2024
Merged

Change the type of data of ptrace::write to make it safe#2324
SteveLauC merged 3 commits intonix-rust:masterfrom
ShuiRuTian:make-ptrace-write-safe

Conversation

@ShuiRuTian
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

Will investigate more.

@SteveLauC
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Thanks for the suggestions, it's past now!

Copy link
Copy Markdown
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
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