-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-127655: Ensure _SelectorSocketTransport.writelines
pauses the protocol if needed
#127656
gh-127655: Ensure _SelectorSocketTransport.writelines
pauses the protocol if needed
#127656
Conversation
_SelectorSocketTransport.writelines
pauses the protocol if needed
Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
Outdated
Show resolved
Hide resolved
Looks like the CI failure was GitHub being flakey and not an actual problem AFAICT |
I will review later today.
…--Guido (mobile)
On Thu, Dec 5, 2024 at 14:25 Seth Michael Larson ***@***.***> wrote:
@sethmlarson <https://github.com/sethmlarson> requested your review on:
#127656 <#127656> gh-127655
<#127655>: Ensure
_SelectorSocketTransport.writelines pauses the protocol if needed.
—
Reply to this email directly, view it on GitHub
<#127656 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWCWMR5R5HAQRB5UCXG5A32EDHGDAVCNFSM6AAAAABTDMMDRGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJVGU2TCMZUGQ3DIMI>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
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.
The one-line fix looks good.
The test doesn't really test anything except that the new logic is in place -- it doesn't prove at all that it does what it claims to do (prevent memory filling up if the other end never reads). But that's hard to test without bringing the test machine to its knees, so as long as you have tested this on one of your actual reproducing scenarios, I'm okay with this.
I suppose some people will be surprised that they are now paused by voluminous writelines() calls where previously they weren't. (What happens if you are paused but you keep calling writelines() anyway?) But consistency with write() is more important, and that may already pause. So I'm okay with this, since writelines() is supposed to be equivalent to multiple write() calls.
Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
Outdated
Show resolved
Hide resolved
Yeah but if you still continue to call writelines then I guess the memory will go unbounded right? |
@python/organization-owners please add me so I can view the advisory |
Yes if the implementation doesn't |
Thanks @bdraco for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…the protocol if needed (pythonGH-127656) Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. (cherry picked from commit e991ac8) Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…the protocol if needed (pythonGH-127656) Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. (cherry picked from commit e991ac8) Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
GH-127663 is a backport of this pull request to the 3.13 branch. |
GH-127664 is a backport of this pull request to the 3.12 branch. |
@kumaraditya303 Do you still need access to the advisory? |
FWIW, it was arguably a design mistake to make write() and writelines() regular functions that must not block, but it's well over a decade too late to fix that. So the convention is that code calling write() or writelines() must also occasionally await drain(). The docstring says it's supposed to be used like this: w.write(data)
await w.drain() and I'm sure that's the same for writelines(). The problem is that for streams, drain() doesn't do anything if the protocol isn't paused (check Thanks @bdraco for finding, reporting and fixing this! |
@sethmlarson Not for this but do add me for any future asyncio issues. |
… the protocol if needed (GH-127656) (#127663) gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (GH-127656) Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. (cherry picked from commit e991ac8) Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
… the protocol if needed (GH-127656) (#127664) gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (GH-127656) Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. (cherry picked from commit e991ac8) Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
Thanks for the quick turnaround on getting this merged. Looking forward to being able to use zero copy writes in production soon. |
@kumaraditya303 I don't think this is possible, in a scoped way specific to asyncio, for potential future advisories. You will need to be added ad hoc |
Add patch to fix CVE-2024-12254: "Unbounded memory buffering in SelectorSocketTransport.writelines()". - https://mail.python.org/archives/list/security-announce@python.org/thread/H4O3UBAOAQQXGT4RE3E4XQYR5XLROORB/ - python/cpython#127655 - python/cpython#127656
Add patch to fix CVE-2024-12254: "Unbounded memory buffering in SelectorSocketTransport.writelines()". - https://mail.python.org/archives/list/security-announce@python.org/thread/H4O3UBAOAQQXGT4RE3E4XQYR5XLROORB/ - python/cpython#127655 - python/cpython#127656
Add patch to fix CVE-2024-12254: "Unbounded memory buffering in SelectorSocketTransport.writelines()". - https://mail.python.org/archives/list/security-announce@python.org/thread/H4O3UBAOAQQXGT4RE3E4XQYR5XLROORB/ - python/cpython#127655 - python/cpython#127656
The Android buildbot failure appears to be unrelated - it's looks like a timing-related failure, which passed on the next CI pass. |
[ commit 717301b5302681e860de49ca12981cec9166e057 ] Add patch to fix CVE-2024-12254: "Unbounded memory buffering in SelectorSocketTransport.writelines()". - https://mail.python.org/archives/list/security-announce@python.org/thread/H4O3UBAOAQQXGT4RE3E4XQYR5XLROORB/ - python/cpython#127655 - python/cpython#127656
…the protocol if needed (python#127656) Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-127655: Ensure writelines pauses the protocol if needed
Note for reviewers: 3.12+ only since writelines only exists since 3.12.