lib/string: Move helper functions out of string.c
authorKees Cook <keescook@chromium.org>
Fri, 18 Jun 2021 17:57:38 +0000 (10:57 -0700)
committerKees Cook <keescook@chromium.org>
Sat, 25 Sep 2021 15:20:49 +0000 (08:20 -0700)
commitcfecea6ead5f15880fc1fb31fc655f8be5cf7424
tree331af507e9084ca106a9a225aa3b166bde9605a9
parentc80d92fbb67b2c80b8eeb8759ee79d676eb33520
lib/string: Move helper functions out of string.c

The core functions of string.c are those that may be implemented by
per-architecture functions, or overloaded by FORTIFY_SOURCE. As a
result, it needs to be built with __NO_FORTIFY. Without this, macros
will collide with function declarations. This was accidentally working
due to -ffreestanding (on some architectures). Make this deterministic
by explicitly setting __NO_FORTIFY and move all the helper functions
into string_helpers.c so that they gain the fortification coverage they
had been missing.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Andy Lavr <andy.lavr@gmail.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
arch/arm/boot/compressed/string.c
arch/s390/lib/string.c
arch/x86/boot/compressed/misc.h
arch/x86/boot/compressed/pgtable_64.c
arch/x86/lib/string_32.c
lib/string.c
lib/string_helpers.c