From 342d826310820e6634d641016911707ae7345574 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 18 Oct 2021 21:51:49 +0100 Subject: [PATCH] CheriBSD bugs workarounds The correct thing to do, of course, is to fix these upstream, but that requires understanding exactly what's wrong, and that's harder than just not tickling the bugs. --- src/pal/pal_consts.h | 7 ++++++- src/pal/pal_posix.h | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pal/pal_consts.h b/src/pal/pal_consts.h index 0cb9e81..8497e33 100644 --- a/src/pal/pal_consts.h +++ b/src/pal/pal_consts.h @@ -14,8 +14,13 @@ namespace snmalloc * - using_readonly * - not_using * model. + * + * TODO: There is a known bug in CheriBSD that means round-tripping through + * PROT_NONE sheds capability load and store permissions (while restoring data + * read/write, for added excitement). For the moment, just force this down on + * CHERI. */ -#ifdef SNMALLOC_CHECK_CLIENT +#if defined(SNMALLOC_CHECK_CLIENT) && !defined(__CHERI_PURE_CAPABILITY__) static constexpr bool PalEnforceAccess = true; #else static constexpr bool PalEnforceAccess = false; diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index 55d96a5..3f3d163 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -146,7 +146,10 @@ namespace snmalloc static void print_stack_trace() { -#ifdef SNMALLOC_BACKTRACE_HEADER + // TODO: the backtrace mechanism does not yet work on CHERI, and causes + // tests which expect to be able to hook abort() to fail. Skip it until + // https://github.com/CTSRD-CHERI/cheribsd/issues/962 is fixed. +#if defined(SNMALLOC_BACKTRACE_HEADER) && !defined(__CHERI_PURE_CAPABILITY__) constexpr int SIZE = 1024; void* buffer[SIZE]; auto nptrs = backtrace(buffer, SIZE);