-
Notifications
You must be signed in to change notification settings - Fork 18
Honor GRATE_MEMORY_FLAG in mmap_syscall and brk_syscall #1185
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
rennergade
wants to merge
25
commits into
main
Choose a base branch
from
grate-memory-flag-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
afa13ba
Honor GRATE_MEMORY_FLAG in mmap_syscall and brk_syscall
rennergade 1d2d47b
sc_convert_addr_to_sys: short-circuit arg=0 to cage base
rennergade 9dcdcb0
mmap-flag cage test: stdout prints + fflush to localize failure
rennergade 8b78e00
mmap-flag grate: log each interception with args + return value
rennergade 45ea1bb
mmap_syscall: temporary eprintln diagnostic
rennergade 7f1f583
sc_convert_addr_to_sys: cross-cage base lookup, not "use as-is"
rennergade ae73bd8
mmap_syscall: re-add diagnostic eprintln to identify why MAP_FIXED br…
rennergade 790917c
Switch mmap/brk runtime check from FLAG-bit to value-range
rennergade 1d7004a
mmap-flag grate test: only apply FLAG to fd-backed mmaps
rennergade c4ba2a7
diagnostics: hex eprintln in mmap_syscall + grate, to compare with/wi…
rennergade 304f5a4
mmap-flag grate: fix target cageid (use arg5cage, not handler's grate…
rennergade ef4846f
Strip diagnostic eprintlns and grate/cage debug printfs
rennergade 3829f3a
TEMP diagnostic: trace mmap_syscall path-by-path
rennergade a11fad8
Revert "TEMP diagnostic: trace mmap_syscall path-by-path"
rennergade d1b9877
Address review: repurpose sc_convert_uaddr_to_host instead of adding …
rennergade 2368331
vmmap: handle cage uaddr in calculate_page_range (issue #1186 part 2)
rennergade 0192789
copy_data_between_cages: translate src/dest before validate + memcpy
rennergade 64e92c0
Merge remote-tracking branch 'origin/main' into grate-memory-flag-run…
rennergade d2ec548
Trace popen handler table inheritance
rennergade 310c803
Trace dashmap handler table dup2 state
rennergade de012db
Trace threei handler table backend for popen
rennergade d64f844
Remove popen trace instrumentation
rennergade f706ed6
Fix grate memory runtime formatting
rennergade 619179d
Leave hashmap handler table unchanged
rennergade 7b65359
Address grate memory flag review comments
rennergade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* Cage side of the mmap-with-GRATE_MEMORY_FLAG test. | ||
| * | ||
| * fd-backed mmap → write → read → munmap round-trip. The companion | ||
| * grate forwards this call to RawPOSIX with `arg1cage | GRATE_MEMORY_FLAG`, | ||
| * exercising the runtime's flag-aware path in mmap_syscall. | ||
| * | ||
| * Anonymous mmaps (including the runtime's own pre-main stack setup) | ||
| * are forwarded by the grate without the flag and aren't exercised here. | ||
| */ | ||
|
|
||
| #include <fcntl.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <sys/mman.h> | ||
| #include <unistd.h> | ||
|
|
||
| #define FILE_PATH "mmap-flag.tmp" | ||
|
|
||
| int main(void) { | ||
| const size_t size = 4096; | ||
|
|
||
| int fd = open(FILE_PATH, O_RDWR | O_CREAT | O_TRUNC, 0666); | ||
| if (fd < 0) { | ||
| return 1; | ||
| } | ||
| if (ftruncate(fd, size) != 0) { | ||
| return 1; | ||
| } | ||
|
|
||
| void *p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | ||
| if (p == MAP_FAILED) { | ||
| return 1; | ||
| } | ||
|
|
||
| memset(p, 0x42, size); | ||
| for (size_t i = 0; i < size; i++) { | ||
| if (((unsigned char *)p)[i] != 0x42) { | ||
| return 1; | ||
| } | ||
| } | ||
|
|
||
| if (munmap(p, size) != 0) { | ||
| return 1; | ||
| } | ||
|
|
||
| close(fd); | ||
| unlink(FILE_PATH); | ||
|
|
||
| printf("[Cage|mmap-flag] PASS\n"); | ||
| return 0; | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to make a macro that uses this?