Skip to content

coredump: Fix failure of executing gcore command due to memory write out of bounds #4

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yulong-tang
Copy link

executing gcore command fails with the following messages:
crash> gcore -v 0 1
free(): invalid next size (normal)
Aborted

This is caused by the buffer size allocated for fill_files_note() is estimated as size = cprm->vma_count * 64, when filenames are generally long, it may lead to a write-out-of-bounds error, which occurs during free.

The modification involves increasing the estimated size or calculating the total length of filenames in all VMAs, and then adding metadata information to obtain the size. Here, the latter approach is adopted.

…out of bounds.

executing gcore command fails with the following messages:
	crash> gcore -v 0 1
	free(): invalid next size (normal)
	Aborted

This is caused by the buffer size allocated for fill_files_note() is estimated as size = cprm->vma_count * 64, when filenames are generally long, it may lead to a write-out-of-bounds error, which occurs during free.

The modification involves increasing the estimated size or calculating the total length of filenames in all VMAs, and then adding metadata information to obtain the size. Here, the latter approach is adopted.
@d-hatayama
Copy link
Collaborator

Could you tell me how to reproduce this issue? Let the target process open a file with sufficiently lengthy a file name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants