Repository navigation
Fix undefined left shifts in stack_swap() (Objects/frameobject.c) - #161422
PavlNekrasov wants to merge 1 commit into
Conversation
Widen MASK and top to int64_t before shifting: shift can reach 60.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate. Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors. We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines. Please read our guidelines for using AI tools. |
stack_swap()inObjects/frameobject.cshiftedMASKandtopas32-bit values and converted the result to
int64_t, while the value-stackmodel is a 63-bit
int64_tandshift = BITS_PER_BLOCK*(n-1)can reach 60.The shifts overflow / drop bits (undefined behavior) and corrupt the stack
model used by
frame_setlineno()to validate line jumps.UBSan output:
Found by Linux Verification Center (linuxtesting.org) with SVACE