-
Notifications
You must be signed in to change notification settings - Fork 1
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
Initial support for .so
compartments
#13
Conversation
I've left lots of detailed, but mostly shallow, comments. I have two bigger comments:
I think the first point might need to be thought about in the context of this PR. I think the second point doesn't need to be addressed in this PR, but (assuming this isn't entirely me being stupid!) I think a follow-up PR that rethinks the structure might be worthwhile. I guess that some splitting up of some of the larger files might be worthwhile, as well as moving code around? One thing that might be useful at that point is to use the old trick of giving "public" functions in each module a "modulename_" prefix. So all public functions in "manager.c" might have the prefix I have one shallow comment: I keep misreading types formatted And finally one very random idea: I wonder whether it might be worth running a static analyser over the code? Clearly the DDC manipulation is going to confuse any static analyser and it will give even more imperfect results than on "normal" C code. But I am partly curious whether it does anything useful! I have found LLVM's builtin in |
I think I'm using
The idea with that re-organization was:
If you agree with the layout above (which I can add to a
I personally prefer putting the pointer next to the type, but it seems 1 the other way is considered "C-style". I can of course (and probably should, unrelated to this particular point) add a
I would love to run any Footnotes |
In ye olde days, if you wanted to do byte-level pointer arithmetic on pointers whose underlying data you're unsure about was to use
Documenting this would definitely be good! I think perhaps
That would work for me. The older the keener I am on autoformatters because it stops me having to develop or enforce formatting opinions on my own :p |
I got this idea from was page 12 of the CHERI Programming Guide 1, which has the following excerpt for
I'm not too familiar with pointer tagging, or can think of any other "non-pointer integer operations", but I think pointer arithmetic should fall under the above defined use for Footnotes |
Might be worth asking @jacobbramley for a second opinion here, but I think (especially in a hybrid context) doing pointer arithmetic on pointers is preferred, unless we're doing arithmetic stuff that can't be done on a pointer. |
Practical C/C+ code does it both ways and this tends to be a style choice, or similar. I'd like to be a purist and say that you should always use As an aside: I've never been terribly convinced that using As a starting point, keeping the original If I can't do what I want with The only advantage I can see for using |
I've been perusing the standard 1, and I think these are the relevant parts to extract, in my own words:
Overall, I think the most "C-like" way of tackling this would be Footnotes |
@0152la Thanks! My suggestion is that you change the "easy obvious" cases of |
So this means we decide to use |
I would say: at a minimum don't use |
@0152la Thanks! We're almost there for this PR I think -- there are still a couple of open comments above though. |
Please squash. |
Implement support for compartments to be gives as dynamic libraries (i.e., `so` files). This includes looking for library dependencies, and loading those in the same compartment as the given user file. These libraries are expected to be found in the path given by the environment variable `COMP_LIBRARY_PATH`. What this means is that we now also add a "local" `libc` to each compartment that needs it (likely all?). Thus, we can greatly reduce the number of intercepts we require. Perhaps we can overhaul the mechanism entirely to only intercept hard-coded functions we know we need (e.g., allocator calls). The support for static binaries has not been removed completely, but likely has been broken due to this overhaul. Whether to leave as is, to remove completely, or to add support for it remains to be decided. Further small changes: * Rework testing infrastructure to account for `so` compartments * Replace `false` `assert`s and `exit`s with `err`s * Replace all `pread`s with `do_pread` wrappers * Rename intercept functions from `manager_` prefix to `intercepted_` * Slight `README` update * Replace `intptr_t` usage with `void*` where appopriate * Fixed a bug where we would find symbols in dependency libraries with a value of 0x0 to be eagerly relocated. Assumption is these symbols are meant to be relocated in the dependency library itself. We now simply filter out 0x0 addresses for symbols to eagerly relocate
Squashed. |
Implement support for compartments to be gives as dynamic libraries (i.e.,
so
files). This includes looking for library dependencies, and loading those in the same compartment as the given user file. These libraries are expected to be found in the path given by the environment variableCOMP_LIBRARY_PATH
.What this means is that we now also add a "local"
libc
to each compartment that needs it (likely all?). Thus, we can greatly reduce the number of intercepts we require. Perhaps we can overhaul the mechanism entirely to only intercept hard-coded functions we know we need (e.g., allocator calls).The support for static binaries has not been removed completely, but likely has been broken due to this overhaul. Whether to leave as is, to remove completely, or to add support for it remains to be decided.
In terms of the PR, there might be scope to logically split it up. I kept the individual commits in a separate branch, to squash them into smaller commits, if need be.
Left TODOs: