Skip to content

Commit

Permalink
fixup! c18n: Rework implementation to be interrupt-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgao committed Apr 9, 2024
1 parent 404ff02 commit 4d1c6ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions libexec/rtld-elf/aarch64/rtld_c18n_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ TRAMP(tramp_pop_frame)
* Load the address of the previous trusted frame, the compartment ID of
* the caller, and the number of return value registers.
*/
ldp c16, c10, [TRUSTED_STACK_C, #(CAP_WIDTH * 14)]
ldp c17, c10, [TRUSTED_STACK_C, #(CAP_WIDTH * 14)]

/*
* Load the caller's current stack top and old stack top.
Expand All @@ -454,15 +454,6 @@ TRAMP(tramp_pop_frame)
ldp c19, c20, [TRUSTED_STACK_C, #(CAP_WIDTH * 2)]
ldp c29, c30, [TRUSTED_STACK_C]

/*
* Get the stack lookup table.
*/
mrs STACK_TABLE_C, STACK_TABLE
/*
* Store the caller's old stack top in the stack lookup table.
*/
str c12, [STACK_TABLE_C, w10, uxtw #0]

/*
* Install the caller's stack.
*
Expand All @@ -474,7 +465,16 @@ TRAMP(tramp_pop_frame)
/*
* Bump the trusted stack pointer.
*/
msr TRUSTED_STACK, c16
msr TRUSTED_STACK, c17

/*
* Get the stack lookup table.
*/
mrs STACK_TABLE_C, STACK_TABLE
/*
* Store the caller's old stack top in the stack lookup table.
*/
str c12, [STACK_TABLE_C, w10, uxtw #0]

/*
* Extrace the number of return value registers.
Expand Down
3 changes: 2 additions & 1 deletion libexec/rtld-elf/rtld_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,8 @@ _rtld_sighandler_impl(int sig, siginfo_t *info, ucontext_t *ucp, void *nsp
*/
intr_idx = tf->callee;
intr = index_to_cid(intr_idx);
if (table->sizes->capacity >= intr || table->sizes->data[intr] == 0) {
if (table->sizes->capacity >= intr ||
table->sizes->data[intr].size == 0) {
/*
* If the interrupt occurred at a point in the trampoline where
* stack resolution is taking place, nsp would remain the
Expand Down

0 comments on commit 4d1c6ac

Please sign in to comment.