-
Notifications
You must be signed in to change notification settings - Fork 3
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
vaddr_t rules #22
Comments
ptraddr_t (the new name for vaddr_t) is a non-provenance-carrying integer type in both purecap and hybrid. In hybrid you can obviously still cast it to an integer pointer and dereference it (relative to DDC), but in purecap it's always a plain integer than can't be dereferenced. |
On RV32 it should be just unsigned int, and on 64-bit Windows it would be unsigned long long as their long is 32-bit. As with all types in C though there’s no upper bound on its size, it’s just large enough to be able to hold the integer addresses of all valid pointers. |
In hybrid mode, if it's non-provenance carrying, can I safely cast it to a pointer type and dereference it? [I ask this slightly naively: I've not poked and prodded all the dark corners of pointer provenance.] |
It's non-provenance-carrying in the CHERI sense. In hybrid C it maintains all the same semantics as any other integral type being cast to a pointer, namely that it works provided the integer is big enough (which, by the definition of ptraddr_t, it will be), so in hybrid C you can consider it to just be another name for uintptr_t (though they could differ in representation). |
Just to check: if I'm in hybrid mode, and I cast a capability to (say) |
Yes (with the only subtle difference being that, if you've mucked with DDC, that pointer had better be in DDC's bounds if you want to use it). |
Indeed :) OK, I think that @jacobbramley and I feel better informed now. I can't promise we won't have future questions, but I am grateful for the answers to our current head-scratchers! |
are there corresponding limits for ptraddr_t (and why’s the guide not updated for the new name)? ok I guess one could use … but CheriOS uses |
and are there cpp constants to check whether to use |
b6062ce, just the published report predates that. CheriOS is old abandonware, most of which was written years before
|
|
Thanks! Is there also something for Cheri* (generally, not limited to BSD, and yes including a hypothetical Windows) so that I could use…
… and in which header(s) would |
Eh, ptraddr_t lives in stdint.h like (u)intptr_t. You can ignore vaddr_t; using it will even give you a warning in CheriBSD as of late, so that we can finally purge it. |
We (mostly @jacobbramley and I) are unsure about the precise semantics of
vaddr_t
. The C/C++ programming guide says:From this we infer that the expectation is that it maps to a
uintX_t
type? Does it map to the same type in both hybrid and purecap compilation? [One possibility is thatvaddr_t
could map tovoid *
in hybrid mode but that wouldn't work in purecap mode where presumablyuintX_t
is the only practical C type to map to.]We're also not sure what to do with "vaddr_t should not be directly cast to a pointer type for dereference". Does that mean that (say)
char *x = cheri_address_get(cap)
causes UB? Are there implications for pointer provenance (and are those the same in hybrid/purecap)? We're also not sure if there are things that we should think are different about CHERI C/C++ vs. "standard" C/C++.I'm sure there are other questions I should ask. I know enough about C's semantics to know that I don't know everything :)
The text was updated successfully, but these errors were encountered: