-
Notifications
You must be signed in to change notification settings - Fork 707
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
Add CapbilityPtr
and Add SuccessAddr
and SuccessPtr
syscall variants
#4174
Merged
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
12abe15
MetaPtr + usize/u32 changes
c32507d
Have MetaPtr wrap a pointer not usize
677183f
Link to CHERI tracking issue
6254b9e
Add explicit return codes for usize/ptr
a5ee396
Better comment for MetaPtr
fd51098
Fix typo
c97deea
Apply comment suggestions
LawrenceEsswood 291c8f4
Rename MetaPtr -> CapabilityPtr
695af1b
Add comment saying into_compat is for legacy only
7ec6bdd
capability_ptr: update doc to reflect meaning
alevy d0fa5fc
Update kernel/src/syscall.rs
LawrenceEsswood be62a66
Update kernel/src/process.rs
LawrenceEsswood 950deb2
Revert notes change
236a8ac
Remove extra cast step
a4e5936
Preface internal Google bug tracker
9ac666b
Remove as_checked_ptr until CHERI lands
010bf22
Change panic for assert and checked alignment too
604460c
Make the oddly chosen ANY permission a NONE permission
79b2b8d
Add provenance notes
6feb692
Refine CapabilityPtr description slightly
f800ddd
Minor changes to encode
2cd33d2
Move capability_ptr to utilities
bf24e72
Update kernel/src/process.rs
LawrenceEsswood d569776
Rename into_compat
743c8cd
Document what authority the CapabilityPtr from brk/sbrk should have
144269e
Do not pollute scope with Execute
cc0b53e
Add comment to construction of intial fn
45f8a44
Remove mention of CHERI
391dfc8
Use .cast_mut(), not as
8f8ce44
Document all methods on CapabilityPtr
a5e5a6d
More formatting/comments/name change for permissions
f3feec6
Style changes
a001b33
kernel/syscall: split out encode_syscall_return, create TRD104 subset
lschuermann 7ea663f
kernel: fix rustdoc links
lschuermann 9560125
Merge remote-tracking branch 'upstream/master' into meta_ptr
alevy 670a5d0
kernel: handle_syscall: elaborate on NonNull change for CapabilityPtr
lschuermann 3810ca8
kernel/capability_ptr: make new_with_metadata an unsafe method
lschuermann 0709e6a
kernel/arch_helpers: remove 32bit infix from encode_syscall_return_tr…
lschuermann 1ebf509
kernel: remove CapabilityPtr aliases for now
alevy d23676d
kernel: remove stale reference in upcall doc
alevy 38a5188
kernel: remove unused syscall return variant
alevy 08caaa5
kernel: rename capability_ptr constructor
alevy c6156c8
kernel: documentation nits
alevy a803e1e
kernel: remove SuccessUsize in favor of SuccessPtr
alevy 096536c
kernel: fix import order nit
alevy 3c1876b
kernel: memop: add provenance to memop returns
alevy 37cb959
Merge remote-tracking branch 'upstream/master' into meta_ptr
lschuermann 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
kernel: rename capability_ptr constructor
- Loading branch information
commit 08caaa518e8cdc76f5f4a40bc87acb315a35a02b
There are no files selected for viewing
This file contains 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 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
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.
This will happen soon, correct? We already have three calls to this function with no safety justification.
It's unclear to me what the safety conditions will look like (i.e. how we will prevent capsules from breaking isolation by copying
CapabilityPtr
s into userspace memory).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.
Technically, there are no safety requirements from rust's perspective (I would have voted "no" to making this interface unsafe) for the use of this type within the kernel. This type does not implement Deref, and is no more unsafe than the MPU configuration interfaces, which are not unsafe at present.
If we did decide that any of these might eventually be passed to the user, and there was a library invariant they should never be allowed access to kernel memory, I suppose it might say "This should never create an alias with any objects accessible by the kernel, apart from those accessed through the grant interface".
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.
Part of the reason of why I added this comment is exactly because these and other details are unclear to me. There will be safety considerations, and this is a public API, and as such this is to serve as a deterrent for anyone to rely on any stable safety conditions at this point.
In a system where capabilities serve as the only memory isolation mechanism, we must ensure that any untrusted code we're invoking (such as a process) cannot violate any of Rust's safety invariants. If arbitrary capabilities can flow across this boundary on a type-level (such as ones pointing into kernel memory, originating from capsules) either the boundary would need to be unsafe, or creating these capabilities must be.
Put differently, even though these types might be safe in isolation, this doesn't mean they're safe in the presence of other interfaces that rely on certain invariants holding for these types (such as Tock's userspace-kernel boundary). One such invariant should probably be that a
CapabilityPtr
must not have authority over kernel memory, although we might want even stronger invariants in practice.My argument for them being
unsafe
relies on the premise that there might be an API that would allow capsules to smuggle capabilities into userspace. Will this API never exist?I think this is the crux: I strongly believe that the MPU configuration interfaces ought to be unsafe, following this same reasoning. We have some much weaker argument for why it might be okay for them not to be unsafe: capsules shouldn't be able to get a hold of a reference the chip's MPU type, and as such they wouldn't be able to use those "safe" interfaces (similar to "capsules will never be able to pass a CapabilityPtr into userspace"). I disagree with this line of reasoning, and there likely is a way for capsules to get a reference like this. However, that is a different discussion, orthogonal to this PR.
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.
I definitely agree with your premise that we have a library invariant whenever MPUs / CHERI are used that we do not allow the user access to kernel, and this very much can become language UB if the user trashes the kernel.
My objections were mostly that CHERI suddenly seems special as other MPU accesses are not considered unsafe, and on the practiically of marking the interface unsafe.
If we do mark the interface unsafe, we should surely justify at the call sites that we have enforced insolation, or else propagate unsafety requirements upwards. My suspicion is that isolation probably can't be locally argued and is likely a property of broad kernel correctness. Possibly, the scope of the entire core kernel, so we would either just have to admit defeat and say every function is unsafe, or instead lie at call sites and say we we can be certain we are not breaking safety here, even though the scope is far too broad to ever do so in full spirit.
TL;DR - this can be unsafe, but then a whole lot more should be too.
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.
I think I agree to the above in spirit, although I believe we will be able to end up precisely drawing the line around unsafe interfaces, and hence don't agree with the generalization in the third paragraph.
In any case, let's wait on the follow-up PR that will introduce the reality of a real capability-hardware platform where these abstract concerns will manifest into tangible isolation properties / violations. Then we can revisit these call-sites and add appropriate documentation.