Skip to content

Commit

Permalink
c18n: Add CHERI-RISC-V workaround for lack of memarg ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgao committed Aug 20, 2024
1 parent 6316592 commit 1b24f97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
17 changes: 17 additions & 0 deletions libexec/rtld-elf/rtld_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,17 @@ compart_id_allocate(const char *lib)
if (string_base_search(&comparts.data[i].libs, lib) != -1)
return (i);

#ifdef __riscv
/*
* XXX: All compartments have the same compartment ID on CHERI-RISC-V to
* work around the lack of bounded memory and variadic arguments.
*/
lib = "[grand]";
for (i = RTLD_COMPART_ID; i < comparts.size; ++i)
if (string_base_search(&comparts.data[i].libs, lib) != -1)
return (i);
#endif

com = add_comparts_data(lib);
string_base_push(&com->libs, lib);

Expand Down Expand Up @@ -571,8 +582,14 @@ tramp_should_include(const Obj_Entry *reqobj, const struct tramp_data *data)
if (reqobj == NULL)
return (true);

#ifndef __riscv
/*
* XXX: All compartments have the same compartment ID on CHERI-RISC-V to
* work around the lack of bounded memory and variadic arguments.
*/
if (reqobj->compart_id == data->defobj->compart_id)
return (false);
#endif

if (string_base_search(&comparts.data[reqobj->compart_id].trusts, sym)
!= -1)
Expand Down
30 changes: 0 additions & 30 deletions libexec/rtld-elf/rtld_c18n_policy.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
Version 1

compartment [TCB]
libc.so.7
libthr.so.3
libsys.so.7

compartment [libunwind]
libgcc_s.so.1

caller *
trust
memset
Expand Down Expand Up @@ -46,25 +38,3 @@ trust
unw_getcontext
_rtld_thread_start
_rtld_sighandler

callee [RTLD]
export to [TCB]
_rtld_thread_start_init
_rtld_thread_start
_rtld_thr_exit
_rtld_sighandler_init
_rtld_sighandler
_rtld_siginvoke
_rtld_sigaction

callee [RTLD]
export to [TCB]
export to [libunwind]
c18n_get_trusted_stk
c18n_unwind_trusted_stk

callee [RTLD]
export to [libunwind]
c18n_is_enabled
c18n_is_tramp
c18n_pop_trusted_stk

0 comments on commit 1b24f97

Please sign in to comment.