GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-40294: Fix use-after-free in _asynciomodule.c when module is loaded/unloaded multiple times by jquesnelle · Pull Request #19542 · python/cpython

Conversation

@jquesnelle

@jquesnelle jquesnelle commented Apr 15, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

GH-16598 added the static variable module_initialized to _asynciomodule.c to guard against multiple initializations and instead re-use the resources from the first initialization. However, the variable isn't cleared in module_free(). If the module is again initialized after module_free is called, the program will crash. In particular, Py_INCREF(all_tasks); in PyInit__asyncio() will access invalid memory.

The fix seems straightforward: simply clear the flag in module_free(). This seems symmetric with it being set in module_init().

https://bugs.python.org/issue40294

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jquesnelle
clear module_initialized when module is freed
cd5229a
@jquesnelle
jquesnelle requested review from 1st1 and asvetlov as code owners April 15, 2020 17:45
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Apr 15, 2020
@bedevere-bot bedevere-bot added the awaiting review label Apr 15, 2020
@vstinner vstinner added the skip news label Apr 17, 2020
@vstinner
vstinner merged commit a75e730 into python:master Apr 17, 2020
@bedevere-bot bedevere-bot removed the awaiting review label Apr 17, 2020
@vstinner vstinner added the needs backport to 3.8 label Apr 17, 2020
@miss-islington

miss-islington commented Apr 17, 2020

Copy link
Copy Markdown
Contributor

Thanks @jquesnelle for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 17, 2020
@jquesnelle @miss-islington
bpo-40294: Fix _asyncio when module is loaded/unloaded multiple times (…
96611a2
…pythonGH-19542)

(cherry picked from commit a75e730)

Co-authored-by: Jeffrey Quesnelle <[email protected]>
@bedevere-bot

bedevere-bot commented Apr 17, 2020

Copy link
Copy Markdown

GH-19565 is a backport of this pull request to the 3.8 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.8 label Apr 17, 2020
@vstinner

vstinner commented Apr 17, 2020

Copy link
Copy Markdown
Member

I tested manually and I confirm that this change fix https://bugs.python.org/issue40294 : I tested main.c attached to the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington added a commit that referenced this pull request Apr 17, 2020
@miss-islington @jquesnelle
bpo-40294: Fix _asyncio when module is loaded/unloaded multiple times (…
6b0ca0a
…GH-19542)

(cherry picked from commit a75e730)

Co-authored-by: Jeffrey Quesnelle <[email protected]>
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request May 29, 2020
@CuriousLearner
Merge branch 'master' into bpo-26543
e4d193d
* master: (1985 commits)
  bpo-40179: Fix translation of #elif in Argument Clinic (pythonGH-19364)
  bpo-35967: Skip test with `uname -p` on Android (pythonGH-19577)
  bpo-40257: Improve help for the typing module (pythonGH-19546)
  Fix two typos in multiprocessing (pythonGH-19571)
  bpo-40286: Use random.randbytes() in tests (pythonGH-19575)
  bpo-40286: Makes simpler the relation between randbytes() and getrandbits() (pythonGH-19574)
  bpo-39894: Route calls from pathlib.Path.samefile() to os.stat() via the path accessor (pythonGH-18836)
  bpo-39897: Remove needless `Path(self.parent)` call, which makes `is_mount()` misbehave in `Path` subclasses. (pythonGH-18839)
  bpo-40282: Allow random.getrandbits(0) (pythonGH-19539)
  bpo-40302: UTF-32 encoder SWAB4() macro use a|b rather than a+b (pythonGH-19572)
  bpo-40302: Replace PY_INT64_T with int64_t (pythonGH-19573)
  bpo-40286: Add randbytes() method to random.Random (pythonGH-19527)
  bpo-39901: Move `pathlib.Path.owner()` and `group()` implementations into the path accessor. (pythonGH-18844)
  bpo-40300: Allow empty logging.Formatter.default_msec_format. (pythonGH-19551)
  bpo-40302: Add pycore_byteswap.h header file (pythonGH-19552)
  bpo-40287: Fix SpooledTemporaryFile.seek() return value (pythonGH-19540)
  Minor modernization and readability improvement to the tokenizer example (pythonGH-19558)
  bpo-40294: Fix _asyncio when module is loaded/unloaded multiple times (pythonGH-19542)
  Fix parameter names in assertIn() docs (pythonGH-18829)
  bpo-39793: use the same domain on make_msgid tests (python#18698)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@1st1 1st1 Awaiting requested review from 1st1
@asvetlov asvetlov Awaiting requested review from asvetlov

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@jquesnelle @miss-islington @bedevere-bot @vstinner @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.