[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 21:41:17 PST 2024


JustinStitt wrote:

My original idea was to get the SIO sanitizer working with `-fwrapv`, the issue [here](https://github.com/KSPP/linux/issues/26) even suggests it as a viable option. However, after seeing literal checks like:

```cpp
case LangOptions::SOB_Undefined:
        if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
```

... I think the best option is to instrument a wrap sanitizer (which this PR does). A wrap sanitizer best captures the language semantics at hand while maintaining existing functionality of the SIO sanitizer. I think Kees can speak first hand about how picky some folks are about the language being used for this arithmetic overflow/wraparound stuff (he linked some gcc threads above my comment but I've also seen some spicy LKML discussions about how OVERFLOW doesn't exist in the Linux Kernel and as such WRAPAROUND instrumentation is needed).

I think this PR bridges the gap between folks like Kees (who just want all this suspicious kernel arithmetic to go away) and folks like Linus (who is really particular about language).

https://github.com/llvm/llvm-project/pull/80089


More information about the cfe-commits mailing list