fortify: Use __diagnose_as() for better diagnostic coverage
authorKees Cook <keescook@chromium.org>
Tue, 8 Feb 2022 22:53:48 +0000 (14:53 -0800)
committerKees Cook <keescook@chromium.org>
Mon, 14 Feb 2022 00:50:07 +0000 (16:50 -0800)
commit92df138a8d663cefebc3124041253677a53c92cf
tree9dd830cc3b8666120e5658642a1583bdf2ac1a9b
parent0a2b782a00f33e7d06dc43d099fa071ae97bee77
fortify: Use __diagnose_as() for better diagnostic coverage

In preparation for using Clang's __pass_object_size, add __diagnose_as()
attributes to mark the functions as being the same as the indicated
builtins. When __daignose_as() is available, Clang will have a more
complete ability to apply its own diagnostic analysis to callers of these
functions, as if they were the builtins themselves. Without __diagnose_as,
Clang's compile time diagnostic messages won't be as precise as they
could be, but at least users of older toolchains will still benefit from
having fortified routines.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20220208225350.1331628-7-keescook@chromium.org
include/linux/fortify-string.h