Repository navigation
feat(libkernel): accept MADV_PROTECT advisory hint in madvise - #4582
Merged
adriadam10 merged 1 commit intoOct 13, 2026
Merged
Conversation
jagrat04
force-pushed
the
feat/libkernel-madvise-madv-protect-pr
branch
from
October 12, 2026 18:57
de693db to
5e6c257
Compare
adriadam10
requested changes
Oct 12, 2026
adriadam10
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR. Before this can go in:
madvisewithMADV_PROTECTis not an address-range hint in FreeBSD:kern_madvise(sys/vm/vm_mmap.c) handles it before the address check, ignoresaddr/len, and callskern_procctl(..., PROC_SPROTECT, PPROT_SET)on the calling process. HerePosixMemory.cpp:229still validates the range for advice 10, somadvise(0, 0xFFFFFFFFFFFFF000, 10)returnsEINVALwhere FreeBSD does not look at it. Please make advice 10 skip the range check, or keep throwing.PROC_SPROTECTneeds privilege (PRIV_VM_MADV_PROTECT) and fails otherwise, so returning 0 unconditionally is a guess, not the exact result. If you keep it as a stub, say which result it follows and why in the TechnicalDebt line (docs/dev/debt/libkernel.md:146), and citevm_mmap.c.core/libs/tests/GuestMemory.cpp:1969only adds advice 10 with a valid range. Add a row with an invalid range for advice 10, so the test pins the behaviour chosen above.- The description names no title or issue that calls
madvise(MADV_PROTECT). Without one, the previous explicit throw is the exact-or-throw choice; please add the title/PPSA (or log) that hits it.
Feel free to push the changes and ping me.
9 tasks done
jagrat04
force-pushed
the
feat/libkernel-madvise-madv-protect-pr
branch
from
October 12, 2026 22:52
5e6c257 to
59bd0c1
Compare
Contributor
Author
|
Updated as requested:
|
This was referenced Oct 13, 2026
Contributor
10 tasks done
adriadam10
approved these changes
Oct 13, 2026
adriadam10
left a comment
Collaborator
There was a problem hiding this comment.
Checked against FreeBSD kern_madvise: advice 10 now returns before the range validation, the debt entry documents the privilege assumption, and the new guest_memory rows fail with the source change reverted. Build and ctest green locally (also confirmed on Linux by @nicolasfalesy); merging.
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.
What
Accepts MADV_PROTECT (10) as a valid advisory hint in madvise in libkernel. In FreeBSD, MADV_PROTECT protects the process from OOM termination. Like the other madvise hints (0-9), user-mode emulation accepts it as a no-op hint without terminating the process via NotImplemented_nid_no_patch. Updates unit tests in GuestMemory.cpp and documents Technical Debt.
Tested
Guest unit tests in core/libs/tests/GuestMemory.cpp
Checklist