llvm / llvm/llvm-project

Null pointer dereference in AArch64AsmParser::tryParseAdjImm0_63 via unchecked dyn_cast

Open
#182,757 1 comment 0 reactions 1 assignee View on GitHub

@yijan4845 is already working on this.

Since Feb 25, 2026.

backend:AArch64 crash-on-invalid
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Compiler explorer: https://godbolt.org/z/9o6sqo8rW

Vulnerable code location(s)

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp, line 8937

Vulnerable code analysis

tryParseAdjImm0_63 checks that the current token is AsmToken::Integer, then calls parseExpression(Ex). The result is cast via dyn_cast<MCConstantExpr>(Ex)->getValue() without a null check.

Although the first token is an integer, parseExpression can consume additional tokens and return a non-MCConstantExpr. For example, input 1f is parsed as a forward directional label reference (MCSymbolRefExpr), and 1 + sym produces an MCBinaryExpr. In either case, dyn_cast returns nullptr, which is immediately dereferenced.

int64_t Imm = dyn_cast<MCConstantExpr>(Ex)->getValue(); // nullptr dereference

The POC uses the cbge instruction (which invokes tryParseAdjImm0_63) with operand 1f, causing parseExpression to return an MCSymbolRefExpr and triggering the crash.

PoC

cbge w0, 1f, .target

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.