Skip to content

Fix fuzzer support after CALL VM changes #18491

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

Merged
merged 1 commit into from
May 4, 2025
Merged
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
12 changes: 8 additions & 4 deletions sapi/fuzzer/fuzzer-execute-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
#define FILE_NAME "/tmp/fuzzer.php"
#define MAX_STEPS 1000
#define MAX_SIZE (8 * 1024)
#define ZEND_VM_ENTER_BIT 1ULL

static uint32_t steps_left;
static bool bailed_out = false;

/* Because the fuzzer is always compiled with clang,
* we can assume that we don't use global registers / hybrid VM. */
typedef int (ZEND_FASTCALL *opcode_handler_t)(zend_execute_data *);
typedef zend_op *(ZEND_FASTCALL *opcode_handler_t)(zend_execute_data *, const zend_op *);

static zend_always_inline void fuzzer_bailout(void) {
bailed_out = true;
Expand All @@ -51,11 +53,13 @@ static zend_always_inline void fuzzer_step(void) {
static void (*orig_execute_ex)(zend_execute_data *execute_data);

static void fuzzer_execute_ex(zend_execute_data *execute_data) {
const zend_op *opline = EX(opline);
while (1) {
int ret;
fuzzer_step();
if ((ret = ((opcode_handler_t) EX(opline)->handler)(execute_data)) != 0) {
if (ret > 0) {
opline = ((opcode_handler_t) opline->handler)(execute_data, opline);
if ((uintptr_t) opline & ZEND_VM_ENTER_BIT) {
opline = (const zend_op *) ((uintptr_t) opline & ~ZEND_VM_ENTER_BIT);
if (opline) {
execute_data = EG(current_execute_data);
} else {
return;
Expand Down