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

Support dynamically allocated lockdep keys #1102

Open
fbq opened this issue Aug 16, 2024 · 1 comment
Open

Support dynamically allocated lockdep keys #1102

fbq opened this issue Aug 16, 2024 · 1 comment
Assignees
Labels
• lib Related to the `rust/` library. unsound The possibility of UB in safe code.

Comments

@fbq
Copy link
Member

fbq commented Aug 16, 2024

Currently, there's a design hole which allows users to pass an unregistered lockdep key to a C function that expects a registered one: example. We can fix this by:

  • Replace &LockClassKey with Pin<&LockClassKey> in all lock APIs to reflect that the lock keys need address stability to work.
  • Introduce pin initializer for LockClassKey, which registers the key at the initialization time.
  • Add pin drop function for LockClassKey, which unregisters the key.
  • Make sure static_lock_class!() still work by creating a Pin<&'static LockClassKey> from a static uninit variable (as long as it's static allocated, lockdep supports the uninitialized key).

Detailed discussions can be found: https://lore.kernel.org/rust-for-linux/2e3bc20e-ca91-45bb-9e35-586620e56d96@proton.me/

@fbq fbq added • lib Related to the `rust/` library. unsound The possibility of UB in safe code. labels Aug 16, 2024
@chessturo
Copy link

Looking into getting a patch out for this

@fbq fbq assigned fbq and chessturo and unassigned fbq Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• lib Related to the `rust/` library. unsound The possibility of UB in safe code.
Development

No branches or pull requests

2 participants