KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
80 stars 5 forks source link

get -Wformat-truncation and -Wformat-overflow re-enabled #343

Open nickdesaulniers opened 9 months ago

nickdesaulniers commented 9 months ago

Looks like Linus just turned this off in bd664f6b3e376a8ef4990f87d08271cc2d01ba9a.

I suspect that Linus was hitting https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78512#c7 (i.e. the kernel's use of %p with additional non-standard modifiers) which was eventually disabled in GCC.

We hit this in https://github.com/ClangBuiltLinux/linux/issues/1923 because clang had the same checks under a different flag name -Wfortify-source. This is getting fixed in https://github.com/llvm/llvm-project/pull/65969.

These issues still persist (compile time detection of the use of snprintf that result in unconditional truncation). These should be fixed; they're not compiler specfic though, as noted by @nathanchance here. So filing this TODO here so that we can close https://github.com/ClangBuiltLinux/linux/issues/1923 once https://github.com/llvm/llvm-project/pull/65969 lands.

nickdesaulniers commented 9 months ago

As noted by @kees in https://lore.kernel.org/llvm/202308291147.2CB91AB9@keescook/, some of these usages may need larger refactorings, such as the usage of sysfs_emit.