Null pointer dereference in AArch64AsmParser::tryParseAdjImm0_63 via unchecked dyn_cast
@yijan4845 is already working on this.
Since Feb 25, 2026.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.