fortify: Add protection for strlcat()
authorKees Cook <keescook@chromium.org>
Mon, 3 Apr 2023 06:00:05 +0000 (23:00 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 16 May 2023 21:15:42 +0000 (14:15 -0700)
commit605395cd7ceded5842c8ba6763ea24feee690c87
treeb6808ef44a0fca91a8ea45dbd3c4a9b17c7230ec
parent21a2c74b0a2a784228c9e3af63cff96d0dea7b8a
fortify: Add protection for strlcat()

The definition of strcat() was defined in terms of unfortified strlcat(),
but that meant there was no bounds checking done on the internal strlen()
calls, and the (bounded) copy would be performed before reporting a
failure. Additionally, pathological cases (i.e. unterminated destination
buffer) did not make calls to fortify_panic(), which will make future unit
testing more difficult. Instead, explicitly define a fortified strlcat()
wrapper for strcat() to use.

Signed-off-by: Kees Cook <keescook@chromium.org>
include/linux/fortify-string.h