-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Unsoundness in tokio-util's LinkedList
/ListNode
APIs
#3101
Comments
Just to clarify for others: this is referring to the |
Ah, I'm sorry! |
LinkedList
/ListNode
APIsLinkedList
/ListNode
APIs
@thomcc not a problem I just wanted to make sure that was clear for future readers. |
I don't think the implementations of I agree that the API can be error-prone though. |
Is there a bug in the LinkedList right now? Are there any bugs that need to fix? If there is a soundness bug to fix, we should do that ASAP. It does not seem like there is though and this is more a discussion of how to tweak the internal API. |
I haven't looked at this |
This triggers UB according to miri: use futures::future::FutureExt;
use tokio_util::sync::CancellationToken;
fn main() {
let token = CancellationToken::new();
let fut = token.cancelled();
tokio::pin!(fut);
fut.now_or_never();
} |
At the moment it actually may no longer fail because miri currently opts to ignore aliasing violation in !Unpin types. This is probably just a workaround at the moment though, and may still be UB (presumably there are still some tules for these types, even if they may need to be looser). There’s a discussion in the miri channel on zulip which is currently going on about it, fwiw. |
Closed by #4652, which completely removes the linked list in tokio-util. |
Version: master branch
Platform: Any
Description
The
LinkedList
/ListNode
apis are unsound, and can be used to gain multiple mutable pointers to objects in the list, access freed memory, etc.This prints garbage that has been freed. Additionally some of the existing tests fail under miri, and it's easy to cause issues like that in the API.
I don't see an obvious way to actually trigger the bad behavior in tokio's public API as it stands, but someone should audit uses of this. Because of that, I didn't report this as a security issue.
It's also arguable that the fix for this is to adjust
add_front
's docs to say not to do this. I suspect thepeek
methods would still violate stacked borrows in this case, but I could be wrong... It also isn't really great IMO to have anunsafe
function that is "I promise everything from here on out is fine" but either way, yeah.The text was updated successfully, but these errors were encountered: