Repository navigation
mingw: guard process tree traversal against PID reuse - #6474
Open
huong8373tt-beep wants to merge 1 commit into
Open
huong8373tt-beep wants to merge 1 commit into
huong8373tt-beep wants to merge 1 commit into
Conversation
Signed-off-by: wangluoye <294879785+huong8373tt-beep@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #6435.
terminate_process_tree()previously expanded the cleanup tree using only the parent PID recorded in a Toolhelp snapshot. A PID can be reused after its original process exits, so an unrelated long-running orphan could retain a dead parent PID that is later assigned to a Git child. The fallback cleanup path could then terminate that unrelated process.Validate every candidate before adding it to the cleanup tree:
NtQueryInformationProcess(ProcessBasicInformation);If a candidate cannot be opened with the query and terminate rights needed for this validation, it is not added to the descendant tree. The explicitly targeted root process still follows the existing termination fallback.
Validation
make -j2 DEVELOPER=1 NO_RUST=1 git.exe t/unit-tests/bin/unit-tests.exeon Windows/MINGW64t/unit-tests/bin/unit-tests.exe -r mingwgit diff --checkThe new Windows unit coverage verifies creation-time ordering and live parent identity for a real child process, including rejection when the claimed parent timestamp is later than the child.
Artificial intelligence assistance disclosure
Slai Agent Runtime assisted with reproduction, implementation, and test execution; the account owner is responsible for this submission.