Repository navigation
Linux: handle stack guards protected via MADV_GUARD_INSTALL - #245
Merged
schopin-mozilla merged 4 commits intoOct 14, 2026
Merged
Conversation
schopin-mozilla
force-pushed
the
stack-guard-regions
branch
2 times, most recently
from
October 8, 2026 10:01
c758212 to
6e32ab0
Compare
Collaborator
Author
|
To clarify (and justify the number of commits), there's actually two bugs at play here:
Also, regarding the code, I leaned on Claude rather heavily for this one, notably for the tests. |
gabrielesvelto
requested changes
Oct 13, 2026
In recent glibc (>= 2.42), guard pages use the MADV_GUARD_INSTALL mechanism which isn't reflected in procmaps, so some stacks are merged together in a single mapping, and reading that entire mapping fails due to some pages within it being guarded. Instead, we take another approach: we know where the stack starts, so we just read from there up until we can't anymore, which would be our guard page. Fixes rust-minidump#244
<
8000
div class="d-flex flex-md-row flex-column">
More functions to be used later on, with only one small observable effect: when get_stack_info can't find the end of the guard area, it now errors out rather than return the last visited page, which would inevitably trigger a failure down the road.
As it turns out, just because a page permissions tell you it's readable doesn't actually mean it is. You can madvise() the kernel to segfault on that page via MADV_GUARD_INSTALL, so we actually try and read stuff to be sure that we're safe.
schopin-mozilla
force-pushed
the
stack-guard-regions
branch
from
October 13, 2026 14:39
6e32ab0 to
2ab79a5
Compare
gabrielesvelto
approved these changes
Oct 14, 2026
Contributor
There was a problem hiding this comment.
LGTM, just left a nit
This should allow us a decent coverage of the various glibc quirks over time. That would have caught the madvise thing.
schopin-mozilla
force-pushed
the
stack-guard-regions
branch
from
October 14, 2026 13:38
2ab79a5 to
37824b5
Compare
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.
The recent glibc releases have changed the way they allocate guard regions. Instead of a separate mapping, they use a kernel hint that doesn't show up in the procmaps data.
Closes #244