WIP runtime/libia2: Protect RW segments for libc and ld.so#628
Open
WIP runtime/libia2: Protect RW segments for libc and ld.so#628
Conversation
This is currently expected to crash most programs since calls into libc from compartments other than pkey = 1 do not change compartments.
ayrtonm
commented
Aug 12, 2025
| @@ -1,5 +1,9 @@ | |||
| #include "ia2.h" | |||
|
|
|||
| void ia2_compartment_destructor_1(void); | |||
Contributor
Author
There was a problem hiding this comment.
TODO: Move this somewhere else/generate it from the rewriter.
ayrtonm
commented
Aug 12, 2025
| project(libia2) | ||
|
|
||
| add_library(libia2 ia2.c init.c threads.c main.c exit.c memory_maps.c thread_name.c) | ||
| add_library(libia2 ia2.c init.c threads.c main.c memory_maps.c thread_name.c) |
Contributor
Author
There was a problem hiding this comment.
TODO: Do we want to keep the option of exiting the process in the untrusted compartment?
This was referenced Aug 12, 2025
ayrtonm
commented
Aug 12, 2025
| } | ||
|
|
||
| #if IA2_REWRITING | ||
| void *__tls_get_addr(size_t m, size_t offset) { |
Contributor
Author
There was a problem hiding this comment.
This could be autogenerated by the rewriter w/o requiring that it appears in user-code, but this was the easiest way to test this. This function is defined in ld.so which is in the same compartment as main.c and the call to __tls_get_addr in library.c is required for the rewriter to realize it needs to generate callgates to call it from that compartment. It then adds the -Wl,--wrap flag for this function and uses that when linking library.o.
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.
This is currently expected to crash most programs since calls into libc from compartments other than pkey = 1 do not change compartments.