Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-140739: Fix crashes from corrupted remote memory#143190
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix several crashes due to reading invalid memory in the new Tachyon | ||
| sampling profiler. Patch by Pablo Galindo. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -45,6 +45,15 @@ process_single_stack_chunk( | ||
| // Check actual size and reread if necessary | ||
| size_t actual_size = GET_MEMBER(size_t, this_chunk, offsetof(_PyStackChunk, size)); | ||
| if (actual_size != current_size) { | ||
| // Validate size: reject garbage (too small or unreasonably large) | ||
| // Size must be at least enough for the header and reasonably bounded | ||
| if (actual_size <= offsetof(_PyStackChunk, data) || actual_size > MAX_STACK_CHUNK_SIZE) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think this is looser than I'd like for MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do you have any suggestion? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I wish we had a tighter bound, but I'm not sure what would be appropiate for a real world stack frame? So that's why I said whatever :) MemberAuthor
| ||
| PyMem_RawFree(this_chunk); | ||
| set_exception_cause(unwinder, PyExc_RuntimeError, | ||
| "Invalid stack chunk size (corrupted remote memory)"); | ||
| return -1; | ||
| } | ||
| this_chunk = PyMem_RawRealloc(this_chunk, actual_size); | ||
| if (!this_chunk) { | ||
| PyErr_NoMemory(); | ||
| @@ -129,7 +138,11 @@ void * | ||
| find_frame_in_chunks(StackChunkList *chunks, uintptr_t remote_ptr) | ||
| { | ||
| for (size_t i = 0; i < chunks->count; ++i) { | ||
| // Validate size: reject garbage that would cause underflow | ||
| if (chunks->chunks[i].size <= offsetof(_PyStackChunk, data)) { | ||
| // Skip this chunk - corrupted size from remote memory | ||
| continue; | ||
| } | ||
| uintptr_t base = chunks->chunks[i].remote_addr + offsetof(_PyStackChunk, data); | ||
| size_t payload = chunks->chunks[i].size - offsetof(_PyStackChunk, data); | ||
Uh oh!
There was an error while loading.Please reload this page.