Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions devbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
git checkout wip
git commit -am "WIP $(date -Iseconds)"
git push dev
ssh morellobox 'cd ~/cheri/cheribuild && ./cheribuild.py cheribsd-morello-purecap --cheribsd/build-options "CHERI_STACK_TEMP_SAFETY=yes" --subdir "libexec/rtld-elf/ lib/libsys/"'
5 changes: 5 additions & 0 deletions lib/libsys/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
PACKAGE= clibs
SHLIBDIR?= /lib


.include <src.opts.mk>

.ifdef CHERI_STACK_TEMP_SAFETY
CFLAGS+=-DCHERI_STACK_TEMP_SAFETY
.endif

LIBC_SRCTOP?= ${SRCTOP}/lib/libc
LIBSYS_SRCTOP?= ${SRCTOP}/lib/libsys

Expand Down
3 changes: 3 additions & 0 deletions lib/libsys/mmap_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ __mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
perms = CHERI_PERM_SYSCALL;
#ifdef __aarch64__
perms |= CHERI_PERM_EXECUTIVE;
#endif
#ifdef CHERI_STACK_TEMP_SAFETY
perms |= CHERI_PERM_STORE_LOCAL_CAP;
#endif
ret = cheri_perms_clear(ret, perms);
}
Expand Down
4 changes: 4 additions & 0 deletions libexec/rtld-elf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

RTLD_ELF_DIR:= ${.PARSEDIR}

.ifdef CHERI_STACK_TEMP_SAFETY
CFLAGS+=-DCHERI_STACK_TEMP_SAFETY
.endif

.ifdef BUILD_RTLD_DEBUG
DEBUG+=-DDEBUG
.endif
Expand Down
7 changes: 6 additions & 1 deletion libexec/rtld-elf/rtld_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,16 @@ get_or_create_untrusted_stk(compart_id_t cid, struct stk_table **tablep)
size = C18N_STACK_SIZE;
stk = create_stk(size);

#ifdef CHERI_STACK_TEMP_SAFETY
stk = cheri_perms_clear(stk, CHERI_PERM_GLOBAL);
#endif

table->meta->compart_stk[cid] = (struct stk_table_stk_info) {
.size = size,
.begin = stk - size
};
table->entries[cid].stack = cheri_perms_clear(stk, CHERI_PERM_SW_VMEM);
uint64_t perms = CHERI_PERM_SW_VMEM;
table->entries[cid].stack = cheri_perms_clear(stk, perms);

atomic_fetch_add_explicit(&c18n_stats->rcs_ustack, 1,
memory_order_relaxed);
Expand Down