anthropics / anthropics/claudes-c-compiler
[SECURITY] CCC -O2 removes volatile loads (DCE on volatile access)
- 主要語言
- Rust
- 星號
- 2.8k
- 分支
- 247
- PR 合併指標
- 30 天內沒有已合併 PR
描述
CCC drops volatile reads under optimization. A volatile load with no used result is eliminated entirely, violating C volatile semantics and enabling miscompilation of MMIO/tamper‑detection patterns.
Repro:
```cpp
void ping(volatile int *p) { *p; }
```
`./target/release/ccc -O2 -S ping.c -o ping.`
```asm
.section .text
.globl ping
.type ping, @function
ping:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $16, %rsp
movq %rdi, -8(%rbp)
movq %rbp, %rsp
popq %rbp
ret
.cfi_endproc
.size ping, .-ping
.section .note.GNU-stack,"",@progbits
```
---
There is no load from *p.
Expected: a volatile access must emit a memory load even if the value is unused.
Actual: CCC emits no load at -O2.
Impact: Volatile reads can be removed or coalesced, breaking MMIO register access, glitch/tamper detection, and other security‑critical patterns.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。