Skip to content

Commit 5c724e2

Browse files
committed
Increase SHSTK stack size
The shadow stack may need as much space as the fiber stack in the worse case, so allocate a shadow stack the same size as the fiber stack. This matches what the kernel does for the main stack.
1 parent 5a94da0 commit 5c724e2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Zend/zend_fibers.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,7 @@ static zend_fiber_stack *zend_fiber_stack_allocate(size_t size)
268268
stack->size = stack_size;
269269

270270
#if !defined(ZEND_FIBER_UCONTEXT) && BOOST_CONTEXT_SHADOW_STACK
271-
/* shadow stack saves ret address only, need less space */
272-
stack->ss_size= stack_size >> 5;
273-
274-
/* align shadow stack to 8 bytes. */
275-
stack->ss_size = (stack->ss_size + 7) & ~7;
271+
stack->ss_size = stack_size;
276272

277273
/* issue syscall to create shadow stack for the new fcontext */
278274
/* SHADOW_STACK_SET_TOKEN option will put "restore token" on the new shadow stack */

0 commit comments

Comments
 (0)