-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Use Pin<Box<S>>
in BodyStream
and SizedStream
#1328
Conversation
Fixes actix#1321 A better fix would be to change `MessageBody` to take a `Pin<&mut Self>`, rather than a `Pin<&mut Self>`. This will avoid requiring the use of `Box` for all consumers by allowing the caller to determine how to pin the `MessageBody` implementation (e.g. via stack pinning). However, doing so is a breaking change that will affect every user of `MessageBody`. By pinning the inner stream ourselves, we can fix the undefined behavior without breaking the API. I've included @sebzim4500's reproduction case as a new test case. However, due to the nature of undefined behavior, this could pass (and not segfault) even if underlying issue were to regress. Unfortunately, until rust-lang/unsafe-code-guidelines#148 is resolved, it's not even possible to write a Miri test that will pass when the bug is fixed.
a8b853f
to
dede6fe
Compare
I'm torn on this but having some breaking change PRs merged in recently is making me sway more towards solving this "properly" and not boxing these streams. |
Can you please elaborate on this (I am assuming you didn't meant to say
If the Proper solution doesn't involve introducing more unsafe code, then I think that is worthwhile, considering we have a few breaking changes in master. |
Oops, my bad. That should be "A better fix would be to change MessageBody to take a Neither apporach requires any If you're okay with breaking a breaking change (which I agree is the correct solution, at least in the long term), I'm happy to make a different PR. However, be aware that this comment states that this will be a significant breaking change. |
Oh, you're talking about this line, I am assuming: actix-web/actix-http/src/body.rs Line 39 in dede6fe
I think we should definitely change that to I'm going to guess there are going to be other places this change will need to be made, so it might make sense to group them into the one PR (on the assumption that @actix/contributors agree to go down this path). |
Ops, it seems we started working on this in parallel. I actually started preparing separate PR with breaking change #1332 .. It affects a lot of places |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine to merge the change as it is since we can backport this PR to 2.0
branch. Then we should introduce better fixes and release them as alpha version.
@JohnTitor Yep, I agree. Should we raise an issue for the bigger task? |
Yeah, I think so too. |
Thanks! |
You could run Miri with |
Following the 3.0 release of actix-web I'm filing security advisories for the issues it resolved. Advisory draft for this issue can be found here: rustsec/advisory-db#402 I'd appreciate if someone could take a look before it goes live. Also, insights into how easy it this is to trigger (i.e. how unusual the API client code has to be) would be appreciated. |
Fixes #1321
A better fix would be to change
MessageBody
to take aPin<&mut Self>
, rather than a&mut self
. This will avoid requiring theuse of
Box
for all consumers by allowing the caller to determine howto pin the
MessageBody
implementation (e.g. via stack pinning).However, doing so is a breaking change that will affect every user of
MessageBody
. By pinning the inner stream ourselves, we can fix theundefined behavior without breaking the API.
I've included @sebzim4500's reproduction case as a new test case.
However, due to the nature of undefined behavior, this could pass (and
not segfault) even if underlying issue were to regress.
Unfortunately, until rust-lang/unsafe-code-guidelines#148 is resolved,
it's not even possible to write a Miri test that will pass when the bug
is fixed.