Skip to content

Conversation

@martinvonz
Copy link
Contributor

Buffer has an UnsafeCell<MmapMut>. It protects against concurrent writes to it by using a mutex. However, it has UB by allowing callers of read() and write() to concurrently have mutable and immutable references to the MmapMut. This patch avoids the alias by using a pointer instead.

Thanks to @Ralith for spotting the problem and suggesting the fix during our review of unsafe Rust code at Google.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. (Because this pull request was imported automatically, there will not be any future comments.)

`Buffer` has an `UnsafeCell<MmapMut>`. It protects against concurrent
writes to it by using a mutex. However, it has UB by allowing callers
of `read()` and `write()` to concurrently have mutable and immutable
references to the `MmapMut`. This patch avoids the alias by using a
pointer instead.

Thanks to @Ralith for spotting the problem and suggesting the fix
during our review of unsafe Rust code at Google.
@facebook-github-bot
Copy link
Contributor

@martinvonz has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in c373376.

@martinvonz martinvonz deleted the push-yzqlukkyxxpn branch February 10, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants