diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-10-08 01:55:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-08 10:55:41 +0200 |
| commit | 6846d6712a0894f8e1a91716c11dd79f42864216 (patch) | |
| tree | 2a1467cecd2a9177565b51619bd604faa5242d9a | |
| parent | 4ce55a2353e07962280181df40af0135aef1cf51 (diff) | |
| download | cpython-git-6846d6712a0894f8e1a91716c11dd79f42864216.tar.gz | |
bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796) (GH-28816)
Prevent use-after-free of running loop holder via cache.
(cherry picked from commit 392a89835371baa0fc4bf79ae479abb80661f57d)
Co-authored-by: Matthias Reichl <github@hias.horus.com>
| -rw-r--r-- | Misc/NEWS.d/next/Library/2021-10-07-14-04-10.bpo-45262.HqF71Z.rst | 1 | ||||
| -rw-r--r-- | Modules/_asynciomodule.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-10-07-14-04-10.bpo-45262.HqF71Z.rst b/Misc/NEWS.d/next/Library/2021-10-07-14-04-10.bpo-45262.HqF71Z.rst new file mode 100644 index 0000000000..4cd949fe1e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-07-14-04-10.bpo-45262.HqF71Z.rst @@ -0,0 +1 @@ +Prevent use-after-free in asyncio. Make sure the cached running loop holder gets cleared on dealloc to prevent use-after-free in get_running_loop
\ No newline at end of file diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index ecc73d1ca8..56079b0277 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -3239,6 +3239,9 @@ new_running_loop_holder(PyObject *loop) static void PyRunningLoopHolder_tp_dealloc(PyRunningLoopHolder *rl) { + if (cached_running_holder == (PyObject *)rl) { + cached_running_holder = NULL; + } Py_CLEAR(rl->rl_loop); PyObject_Free(rl); } |
