Skip to content

Fix null pointer dereference in ks_option for EVM backend#603

Open
SAY-5 wants to merge 1 commit into
keystone-engine:masterfrom
SAY-5:fix-evm-ks-option-null-mai
Open

Fix null pointer dereference in ks_option for EVM backend#603
SAY-5 wants to merge 1 commit into
keystone-engine:masterfrom
SAY-5:fix-evm-ks-option-null-mai

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 20, 2026

Copy link
Copy Markdown

ks_option() dereferences ks->MAI unconditionally at the top of the function before checking the architecture. For LLVM-based backends MAI is initialized during ks_open(), but the EVM backend returns early without setting it up, so ks->MAI stays NULL. As a result, calling ks_option(ks, KS_OPT_SYNTAX, value) on an EVM engine crashes with a SIGSEGV before any option validation runs.

This guards the setRadix(16) call with a NULL check on ks->MAI. The KS_OPT_SYNTAX case already rejects non-x86 architectures with KS_ERR_OPT_INVALID, so with the guard in place EVM now returns that error instead of dereferencing a null pointer. x86 behavior is unchanged since MAI is always set for that path.

Fixes #602.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Null pointer dereference in Keystone EVM backend when setting KS_OPT_SYNTAX

1 participant