Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-143228: Fix UAF in perf trampoline during finalization#143233

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 1 commit intopython:mainfrompablogsal:gh-143228
Dec 28, 2025

Conversation

@pablogsal
Copy link
Member

@pablogsalpablogsal commentedDec 27, 2025
edited by bedevere-appbot
Loading

When toggling perf trampoline while threads are running, or during
interpreter finalization with daemon threads active, a use-after-free
occurs. The munmap call in free_code_arenas releases executable memory
while other threads may still be executing within trampolines or
unwinding through them, causing SIGSEGV or SystemError.

The fix uses reference counting with a code watcher. Each code object
that receives a trampoline increments a refcount. When code objects are
destroyed, the watcher decrements the refcount and frees arenas only
when it reaches zero. This ensures trampolines are never freed while
any code object could still reference them.

Copy link
Member

@Fidget-SpinnerFidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good, just one question

When toggling perf trampoline while threads are running, or duringinterpreter finalization with daemon threads active, a use-after-freeoccurs. The munmap call in free_code_arenas releases executable memorywhile other threads may still be executing within trampolines orunwinding through them, causing SIGSEGV or SystemError.The fix uses reference counting with a code watcher. Each code objectthat receives a trampoline increments a refcount. When code objects aredestroyed, the watcher decrements the refcount and frees arenas onlywhen it reaches zero. This ensures trampolines are never freed whileany code object could still reference them.
@pablogsalpablogsal merged commit3ccc76f intopython:mainDec 28, 2025
50 checks passed
@miss-islington-app
Copy link

Thanks@pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@pablogsalpablogsal deleted the gh-143228 branchDecember 28, 2025 13:50
@miss-islington-app
Copy link

Sorry,@pablogsal, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 3ccc76f036bfaabb5a4631783b966501fe64859a 3.14

@miss-islington-app
Copy link

Sorry,@pablogsal, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 3ccc76f036bfaabb5a4631783b966501fe64859a 3.13

@bedevere-app
Copy link

GH-143247 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelDec 28, 2025
pablogsal added a commit to pablogsal/cpython that referenced this pull requestDec 28, 2025
pythonGH-143233)(cherry picked from commit3ccc76f)Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this pull requestDec 28, 2025
pythonGH-143233)(cherry picked from commit3ccc76f)Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
@bedevere-app
Copy link

GH-143248 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelDec 28, 2025
pablogsal added a commit to pablogsal/cpython that referenced this pull requestDec 28, 2025
pythonGH-143233)(cherry picked from commit3ccc76f)Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ZeroIntensityZeroIntensityAwaiting requested review from ZeroIntensityZeroIntensity is a code owner

Assignees

@pablogsalpablogsal

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@pablogsal@Fidget-Spinner

[8]ページ先頭

©2009-2026 Movatter.jp