lua-lsm: add file_mprotect context#21
Open
chenzongyao200127 wants to merge 1 commit into
Open
Conversation
The file_mprotect hook only exposed raw protection bits to Lua, leaving policy unable to distinguish common memory protection cases such as executable upgrades, writable-executable mappings, anonymous regions, stacks, heaps, or file-backed VMAs. Add an mprotect context userdata with derived VMA attributes and an optional file accessor. Pass that context to file_mprotect() together with the requested and effective protection masks so Lua policy can make decisions without decoding vm_area_struct details itself. Signed-off-by: Zongyao Chen <ZongYao.Chen@linux.alibaba.com>
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.
Lua-LSM currently exposes file_mprotect() with only the requested and effective protection masks. That leaves Lua policy to infer intent from raw bits, and hides useful VMA context such as whether the region is anonymous, file-backed, shared, stack, heap, gaining execute permission, or becoming writable and executable.
Add an mprotect context userdata for file_mprotect(). The context exposes derived VMA attributes and a file() accessor for file-backed mappings, while preserving the raw reqprot and prot arguments for policy that wants to inspect the original protection masks.
Example Lua policy:
Validation:
Signed-off-by: Zongyao Chen ZongYao.Chen@linux.alibaba.com