Skip to content

gh-160663: Fix UAF in visit_generation - #160667

Open
johng wants to merge 3 commits into
python:mainfrom
johng:gc-visit-objects-uaf
Open

johng wants to merge 3 commits into
python:mainfrom
johng:gc-visit-objects-uaf

Conversation

@johng

@johng johng commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Callback can free an object resulting in UAF if we have relied on the object for visiting the next item in the chain.

Fix is to use finalize_garbage approach of walking the object gc generation list directly maintaing and moving it into a tempoary list before calling callback

Callback can free an object resulting in UAF if
we have relied on the object for visiting the next
item in the chain.

Fix is to use `finalize_garbage` approach of walking
the object gc generation list directly maintaing and
moving it into a tempoary list before calling callback
Comment thread Python/gc.c
Comment thread Modules/_testcapi/gc.c Outdated
Comment thread Python/gc.c
@johng
johng requested a review from sergey-miryanov October 25, 2026 18:24
Failure case is crashing the whole test suite, also may not be
reliable
Comment thread Python/gc.c Outdated

@sergey-miryanov sergey-miryanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! LGTM.

@sergey-miryanov

Copy link
Copy Markdown
Contributor

@nascheme Could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants