gh-157364: Fix use-after-free in TextIOWrapper during reentrant detach - #157370
gh-157364: Fix use-after-free in TextIOWrapper during reentrant detach#157370ashm-dev wants to merge 3 commits into
Conversation
| wrapper = self.TextIOWrapper( | ||
| self.BufferedReader(raw), encoding="utf-8") | ||
| method = getattr(wrapper, method_name) | ||
| self.assertEqual(method(), "ab\n") |
There was a problem hiding this comment.
Can you check that wrapper is actually detached? Maybe get wrapper.buffer and expect PyExc_ValueError("underlying buffer has been detached")?
|
I will need a couple more days to look at this, it seems like this is more invasive than necessary to me and makes a number of not needed for the core UAF bug report. |
|
For gh-157364 I think the bug, and solution, is actually in Buffered I/O. This PR changes Text I/O to keep one more reference, which may also be needed. The issue though is that Buffered I/O has an internal allocation which it passes as an argument to the Raw I/O That makes two pieces to fix here:
|
|
Thanks for looking into this, @cmaloney! Regarding point 1: passing mbuf->master = *info;
mbuf->master.obj = NULL;Because of this, the resulting Regarding point 2: CPython method calls via |
Uh oh!
There was an error while loading. Please reload this page.