Skip to content

Commit cab4da7

Browse files
committed
rt: Don't check the stack canary on most upcalls
1 parent a5d48ce commit cab4da7

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/rt/rust_task.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ static stk_seg*
133133
new_stk(rust_scheduler *sched, rust_task *task, size_t requested_sz)
134134
{
135135
LOG(task, mem, "creating new stack for task %" PRIxPTR, task);
136+
if (task->stk) {
137+
check_stack_canary(task->stk);
138+
}
136139

137140
// The minimum stack size, in bytes, of a Rust stack, excluding red zone
138141
size_t min_sz = get_min_stk_size(sched->min_stack_size);

src/rt/rust_upcall.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ check_stack_alignment() __attribute__ ((aligned (16)));
2727
static void check_stack_alignment() { }
2828
#endif
2929

30-
static inline void
31-
do_sanity_check(rust_task *task) {
32-
check_stack_alignment();
33-
task->check_stack_canary();
34-
}
35-
3630
#define UPCALL_SWITCH_STACK(A, F) call_upcall_on_c_stack((void*)A, (void*)F)
3731

3832
inline void
3933
call_upcall_on_c_stack(void *args, void *fn_ptr) {
34+
check_stack_alignment();
4035
rust_task *task = rust_scheduler::get_task();
41-
do_sanity_check(task);
4236
rust_scheduler *sched = task->sched;
4337
sched->c_context.call_shim_on_c_stack(args, fn_ptr);
4438
}
@@ -55,7 +49,6 @@ extern "C" void record_sp(void *limit);
5549
extern "C" CDECL void
5650
upcall_call_shim_on_c_stack(void *args, void *fn_ptr) {
5751
rust_task *task = rust_scheduler::get_task();
58-
do_sanity_check(task);
5952

6053
// FIXME (1226) - The shim functions generated by rustc contain the
6154
// morestack prologue, so we need to let them know they have enough
@@ -645,9 +638,7 @@ upcall_del_stack() {
645638
extern "C" CDECL void
646639
upcall_reset_stack_limit() {
647640
rust_task *task = rust_scheduler::get_task();
648-
do_sanity_check(task);
649641
task->reset_stack_limit();
650-
task->check_stack_canary();
651642
}
652643

653644
//

0 commit comments

Comments
 (0)