CHERI: Avoid traps on nullptr
The CHERI-RISC-V `CAndPerm` and `CSetBoundsExact` instructions trap on untagged inputs, so avoid passing `nullptr` to primitives that become those instructions.
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
13a4b0471e
commit
3a509d41f0
@@ -57,6 +57,13 @@ namespace snmalloc
|
||||
static SNMALLOC_FAST_PATH CapPtr<T, capptr::user_address_control_type<B>>
|
||||
capptr_to_user_address_control(CapPtr<T, B> p)
|
||||
{
|
||||
if constexpr (Aal::aal_cheri_features & Aal::AndPermsTrapsUntagged)
|
||||
{
|
||||
if (p == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return CapPtr<T, capptr::user_address_control_type<B>>(
|
||||
__builtin_cheri_perms_and(
|
||||
p.unsafe_ptr(),
|
||||
|
||||
Reference in New Issue
Block a user