Skip to content

[3.14] gh-149816: Fix UAF in Modules/_pickle.c (GH-150024)#153719

Open
nascheme wants to merge 1 commit into
python:3.14from
nascheme:ft-backport/gh-149816-3.14
Open

[3.14] gh-149816: Fix UAF in Modules/_pickle.c (GH-150024)#153719
nascheme wants to merge 1 commit into
python:3.14from
nascheme:ft-backport/gh-149816-3.14

Conversation

@nascheme

@nascheme nascheme commented Jul 14, 2026

Copy link
Copy Markdown
Member

gh-149816: Fix UAF in Modules/_pickle.c (GH-150024)

Backport note: 3.14's batch_list_exact() has the single-item fast path before the batch loop; main moved it inside the loop, which changes the emitted pickle byte stream (APPEND vs MARK ... APPENDS for a trailing single item). To avoid changing 3.14's pickle output, 3.14's structure was kept and only the fix applied: the borrowed PyList_GET_ITEM() + Py_INCREF() became PyList_GetItemRef(), and the list changed size during iteration RuntimeError check was added after each batch. The upstream regression test (test_pickle_dumps_with_concurrent_list_mutations) tolerates RuntimeError/IndexError and passes unchanged.

(cherry picked from commit d095ceb)

Co-authored-by: Alexey Katsman alex2007508@gmail.com
Co-authored-by: Gregory P. Smith 68491+gpshead@users.noreply.github.com

(cherry picked from commit d095ceb)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Alexey Katsman <alex2007508@gmail.com>
@python-cla-bot

python-cla-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

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