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-108253: Fix bug in func version cache by gvanrossum · Pull Request #108296 · python/cpython

Conversation

@gvanrossum

@gvanrossum gvanrossum commented Aug 22, 2023

Copy link
Copy Markdown
Member

When a function object changed its version, a stale pointer might remain in the cache.

Now, test_opcache just fails when run with -Xuops instead of accessing freed memory. This fixes gh-108253.

Sorry, something went wrong.

Uh oh!

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

All reactions
@gvanrossum
Fix bug in func version cache
472ed9f
When a function object changed its version, a stale pointer
might remain in the cache.
@bedevere-bot bedevere-bot added the awaiting core review label Aug 22, 2023
@gvanrossum gvanrossum added the skip news label Aug 22, 2023
@gvanrossum
gvanrossum requested a review from markshannon August 22, 2023 14:21
@gvanrossum
gvanrossum merged commit b8f96b5 into python:main Aug 22, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Aug 22, 2023
@gvanrossum
gvanrossum deleted the fix-func-cache branch August 22, 2023 15:29
@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

This PR introduces a use of uninitialized memory.

  • A new PyFunctionObject is allocated here
  • And then here _PyFunction_SetVersion is called
  • Which reads from ->func_version here
  • However, ->func_version was never initialized

This was detected by OSS-Fuzz: https://oss-fuzz.com/testcase-detail/5086904889245696

All reactions

Sorry, something went wrong.

Uh oh!

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

@gvanrossum

gvanrossum commented Aug 23, 2023

Copy link
Copy Markdown
Member Author

This PR introduces a use of uninitialized memory.

Interesting, since it also definitely fixed a case of free-after-use. I will try to understand the report.

All reactions

Sorry, something went wrong.

Uh oh!

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

@gvanrossum

gvanrossum commented Aug 23, 2023

Copy link
Copy Markdown
Member Author

Ah, I was over-zealous. That is the one place where ...->func_version = 0 is correct instead of going through the call. :-( PR coming up.

All reactions

Sorry, something went wrong.

Uh oh!

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

@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@gvanrossum gvanrossum mentioned this pull request Aug 23, 2023
gh-108253: Fix reads of uninitialized memory in funcobject.c #108383
Merged
@gvanrossum

gvanrossum commented Aug 23, 2023

Copy link
Copy Markdown
Member Author

This is a great service! Surprised though that address-sanitizer didn't catch this.

All reactions

Sorry, something went wrong.

Uh oh!

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

@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

ASAN doesn't catch unitialized memory, only MSAN does. (And MSAN is kind of a pain in the neck to setup.)

gvanrossum 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.

@llooFlashooll

llooFlashooll commented Oct 29, 2023

Copy link
Copy Markdown

This PR introduces a use of uninitialized memory.

  • A new PyFunctionObject is allocated here
  • And then here _PyFunction_SetVersion is called
  • Which reads from ->func_version here
  • However, ->func_version was never initialized

This was detected by OSS-Fuzz: https://oss-fuzz.com/testcase-detail/5086904889245696

Dear Alex @alex ,

Could you please give me an access to this issue? I am a security Ph.D. student, and I am analyzing some issues to summarize some patterns. I would be very grateful if you could help me.

Best regards,
Zeyang ([email protected], or [email protected])

All reactions

Sorry, something went wrong.

Uh oh!

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

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

Reviewers

@markshannon markshannon Awaiting requested review from markshannon

Uh oh!

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

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

heap-use-after-free in _PyFunction_LookupByVersion

Uh oh!

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

4 participants

@gvanrossum @alex @llooFlashooll @bedevere-bot
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 01402503 — 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.