Skip to content

Fixed bug #8338 (Intel CET is disabled unintentionally since PHP-8.1.0) #8339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
6 changes: 6 additions & 0 deletions Zend/asm/jump_x86_64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
* *
****************************************************************************************/

# if defined __CET__
# include <cet.h>
# else
# define _CET_ENDBR
# endif
.file "jump_x86_64_sysv_elf_gas.S"
.text
.globl jump_fcontext
.type jump_fcontext,@function
.align 16
jump_fcontext:
_CET_ENDBR
leaq -0x38(%rsp), %rsp /* prepare stack */

#if !defined(BOOST_USE_TSX)
Expand Down
8 changes: 8 additions & 0 deletions Zend/asm/make_x86_64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
* *
****************************************************************************************/

# if defined __CET__
# include <cet.h>
# else
# define _CET_ENDBR
# endif
.file "make_x86_64_sysv_elf_gas.S"
.text
.globl make_fcontext
.type make_fcontext,@function
.align 16
make_fcontext:
_CET_ENDBR
/* first arg of make_fcontext() == top of context-stack */
movq %rdi, %rax

Expand Down Expand Up @@ -66,11 +72,13 @@ make_fcontext:
trampoline:
/* store return address on stack */
/* fix stack alignment */
_CET_ENDBR
push %rbp
/* jump to context-function */
jmp *%rbx

finish:
_CET_ENDBR
/* exit code is zero */
xorq %rdi, %rdi
/* exit application */
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ typedef struct {

/* These functions are defined in assembler files provided by boost.context (located in "Zend/asm"). */
extern void *make_fcontext(void *sp, size_t size, void (*fn)(boost_context_data));
extern boost_context_data jump_fcontext(void *to, zend_fiber_transfer *transfer);
extern ZEND_INDIRECT_RETURN boost_context_data jump_fcontext(void *to, zend_fiber_transfer *transfer);
#endif

ZEND_API zend_class_entry *zend_ce_fiber;
Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,4 +679,10 @@ extern "C++" {
# define ZEND_VOIDP(ptr) (ptr)
#endif

#if defined(__GNUC__) && ZEND_GCC_VERSION >= 9000
# define ZEND_INDIRECT_RETURN __attribute__((__indirect_return__))
#else
# define ZEND_INDIRECT_RETURN
#endif

#endif /* ZEND_PORTABILITY_H */