StrictProvenance: re-introduce capptr_rebound

This commit is contained in:
Nathaniel Wesley Filardo 2022-12-09 14:31:26 +00:00 коммит произвёл Nathaniel Filardo
Родитель 90ac1ba8d3
Коммит e7a3130f79
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -216,6 +216,19 @@ namespace snmalloc
a.template as_static<T>().unsafe_ptr());
}
template<
typename T,
SNMALLOC_CONCEPT(capptr::IsBound) BOut,
SNMALLOC_CONCEPT(capptr::IsBound) BIn,
typename U = T>
static SNMALLOC_FAST_PATH CapPtr<T, BOut>
capptr_rebound(CapPtr<T, BOut> a, CapPtr<U, BIn> b) noexcept
{
UNUSED(a);
return CapPtr<T, BOut>::unsafe_from(
b.template as_static<T>().unsafe_ptr());
}
static SNMALLOC_FAST_PATH size_t capptr_size_round(size_t sz) noexcept
{
return sz;

Просмотреть файл

@ -93,6 +93,18 @@ namespace snmalloc
return CapPtr<T, BOut>::unsafe_from(static_cast<T*>(pb));
}
template<
typename T,
SNMALLOC_CONCEPT(capptr::IsBound) BOut,
SNMALLOC_CONCEPT(capptr::IsBound) BIn,
typename U = T>
static SNMALLOC_FAST_PATH CapPtr<T, BOut>
capptr_rebound(CapPtr<T, BOut> a, CapPtr<U, BIn> b) noexcept
{
return CapPtr<T, BOut>::unsafe_from(static_cast<T*>(
__builtin_cheri_address_set(a.unsafe_ptr(), address_cast(b))));
}
static SNMALLOC_FAST_PATH size_t capptr_size_round(size_t sz) noexcept
{
/*

Просмотреть файл

@ -60,6 +60,15 @@ namespace snmalloc
}
noexcept->ConceptSame<capptr::Chunk<void>>;
/**
* "Amplify" by copying the address of one pointer into one of higher
* privilege. The resulting pointer differs from auth only in address.
*/
{
AAL::capptr_rebound(auth, ret)
}
noexcept->ConceptSame<capptr::Chunk<void>>;
/**
* Round up an allocation size to a size this architecture can represent.
* While there may also, in general, be alignment requirements for