]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796)
authorMatthias Reichl <github@hias.horus.com>
Thu, 7 Oct 2021 22:46:49 +0000 (00:46 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Oct 2021 22:46:49 +0000 (00:46 +0200)
Prevent use-after-free of running loop holder via cache.

Misc/NEWS.d/next/Library/2021-10-07-14-04-10.bpo-45262.HqF71Z.rst [new file with mode: 0644]
Modules/_asynciomodule.c

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 (file)
index 0000000..4cd949f
--- /dev/null
@@ -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
index ecc73d1ca8bf0f577a096617ff6837cfae60dcb4..56079b0277d1a677165b6ec82a968fbc775cff1b 100644 (file)
@@ -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);
 }