GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-134070: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 by vedant713 · Pull Request #134149 · python/cpython

Conversation

@vedant713

@vedant713 vedant713 commented May 17, 2025

Copy link
Copy Markdown

Fixes GH-134070

Summary:
This patch adds a masking operation to the index calculation in mi_ctz32() and mi_clz32() functions to prevent out-of-bounds access on 64-bit systems, matching the fix from upstream mimalloc.

Why:
On systems where unsigned long is 64-bit, the multiplication may produce a value >31, causing a read outside the array bounds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vedant713
Fix: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 (python#134070)
e8466b0
@bedevere-app

bedevere-app Bot commented May 17, 2025

Copy link
Copy Markdown

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 skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label May 17, 2025
@ZeroIntensity ZeroIntensity changed the title Fix: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 (#134070) gh-134070: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 (#134070) May 17, 2025
@ZeroIntensity
ZeroIntensity requested a review from colesbury May 17, 2025 18:51
@bedevere-app bedevere-app Bot mentioned this pull request May 17, 2025
Out-of-bounds read in integrated mimalloc (fixed upstream) #134070
Closed
@ZeroIntensity ZeroIntensity added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels May 17, 2025
@ZeroIntensity ZeroIntensity changed the title gh-134070: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 (#134070) gh-134070: Prevent out-of-bounds read in mi_clz32 and mi_ctz32 May 17, 2025
ZeroIntensity
ZeroIntensity reviewed May 17, 2025
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please add a test and blurb.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@collinfunk

collinfunk commented May 17, 2025

Copy link
Copy Markdown
Contributor

FYI, this code is from https://github.com/microsoft/mimalloc. You might want to send a pull request there too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 17, 2025

Copy link
Copy Markdown
Member

It's said to be fixed in microsoft/mimalloc@ed31847.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vedant713 added a commit to vedant713/cpython that referenced this pull request May 17, 2025
@vedant713
pythongh-134070: Fix mi_clz32/mi_ctz32 to prevent out-of-bounds read (p…
960e266
…ythonGH-134149)
@vedant713
Merge branch 'main' into fix-mimalloc-bug
3658bc3
@bedevere-app

bedevere-app Bot commented May 17, 2025

Copy link
Copy Markdown

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 skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 17, 2025

Copy link
Copy Markdown
Member

Please, stop updating two PRs at the same time. See https://devguide.python.org/getting-started/pull-request-lifecycle/. I am going to close the other PR as it only contains the NEWS entry. In addition, please do not merge main into this branch if there is no conflict. TiA.

vedant713 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz mentioned this pull request May 17, 2025
gh-134070: Fix mi_clz32/mi_ctz32 to prevent out-of-bounds read (GH-134149) #134157
Closed
@vedant713

vedant713 commented May 17, 2025

Copy link
Copy Markdown
Author

I'm trying to add via heroku app but giving server error
bedevere/news
bedevere/news — No news entry in Misc/NEWS.d/next/ or "skip news" label found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I never used the app, so I'd suggest using the command-line instead:

python -m pip install blurb
python -m blurb
git commit -m 'blurb'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
picnixz marked this pull request as draft May 17, 2025 20:33
@bedevere-app bedevere-app Bot removed the awaiting review label May 17, 2025
vedant713 added 4 commits May 17, 2025 17:15
@vedant713
pythongh-134070: Add news entry for mimalloc out-of-bounds fix
64e9718
@vedant713
pythongh-134070: Add news entry for mimalloc out-of-bounds fix
c961fa0
@vedant713
pythongh-134070: Add news entry for mimalloc out-of-bounds fix
911c128
@vedant713
pythongh-134070: Add news entry for mimalloc out-of-bounds fix
bce07b2
@vedant713
vedant713 marked this pull request as ready for review May 17, 2025 21:52
@bedevere-app bedevere-app Bot added the awaiting review label May 17, 2025
@collinfunk

collinfunk commented May 17, 2025

Copy link
Copy Markdown
Contributor

@picnixz Thanks for checking. Somehow I missed that commit in mimalloc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@colesbury

colesbury commented May 18, 2025

Copy link
Copy Markdown
Contributor

I think we should copy-paste the change from upstream instead of doing a similar (but not identical) fix here.

In other words, copy this code from upstream (from the fix commit) into our mimalloc/internal.h file.

https://github.com/microsoft/mimalloc/blob/ed318471126918fce7caf0001cf1e0c78f95173e/include/mimalloc/internal.h#L875-L932

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Jul 12, 2025

Copy link
Copy Markdown
Member

@vedant713 Are you still working on this one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vedant713 added 2 commits July 13, 2025 19:33
@vedant713
Update internal.h
bd186c9
@vedant713
Update internal.h
796a176
@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 24, 2026
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.15 bugs and security fixes label May 30, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 31, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Sep 3, 2026
@corona10 corona10 closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ZeroIntensity ZeroIntensity ZeroIntensity left review comments
@colesbury colesbury Awaiting requested review from colesbury

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Out-of-bounds read in integrated mimalloc (fixed upstream)

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@vedant713 @collinfunk @picnixz @colesbury @ZeroIntensity @serhiy-storchaka @corona10
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.