https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102317
--- Comment #9 from Kees Cook <kees at outflux dot net> --- (In reply to Jakub Jelinek from comment #8) > So, instead (when building the kernel with sanitization) build with > -fsanitize=signed-integer-overflow and no -fno-strict-overflow, and > the routines where you want wrapv behavior and not runtime traps build with > optimize ("wrapv", "wrapv-pointer") attribute? __attribute__((optimize)) is documented as not for production use ("for debugging purposes only"): https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-optimize-function-attribute and the kernel has hit multiple problems with it. As such, all use has been removed, for example: https://lore.kernel.org/lkml/20201027205723.12514-1-a...@kernel.org/ https://lore.kernel.org/lkml/20201028080433.26799-1-a...@kernel.org/ https://lore.kernel.org/lkml/20210118105557.186614-3-adrian.ra...@collabora.com/ If there were an __attribute__((wrapv)) and __attribute__((wrapv-pointer)), we could create the wrapping helpers with those and __attribute__((no_sanitize("signed-integer-overflow"))) FWIW, I've been trying to track this issue in the kernel here: https://github.com/KSPP/linux/issues/26