Skip to content

gh-126703: Fix possible use after free in pycfunction freelist #132319

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2025

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Apr 9, 2025

@Fidget-Spinner Fidget-Spinner changed the title gh-128692: Fix possible use after free in pycfunction freelist gh-126703: Fix possible use after free in pycfunction freelist Apr 9, 2025
@Fidget-Spinner
Copy link
Member Author

@hawkinsp does this look right to you?

@@ -173,12 +173,16 @@ meth_dealloc(PyObject *self)
if (m->m_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*) m);
}
// We need to access ml_flags here rather than later.
// `m` might have the same lifetime
Copy link
Contributor

@hawkinsp hawkinsp Apr 9, 2025

Choose a reason for hiding this comment

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

m->m_ml I think here, but yes.

You are also right that probably we should update the API documentation to clarify this is an acceptable thing to do.

@Fidget-Spinner Fidget-Spinner merged commit bd3aa0b into python:main Apr 9, 2025
42 checks passed
@Fidget-Spinner Fidget-Spinner deleted the freelist-fix branch April 9, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants