WSL2-Linux-Kernel/drivers/misc/lkdtm
Kees Cook 439a1bcac6 fortify: Use __builtin_dynamic_object_size() when available
Since the commits starting with c37495d625 ("slab: add __alloc_size
attributes for better bounds checking"), the compilers have runtime
allocation size hints available in some places. This was immediately
available to CONFIG_UBSAN_BOUNDS, but CONFIG_FORTIFY_SOURCE needed
updating to explicitly make use of the hints via the associated
__builtin_dynamic_object_size() helper. Detect and use the builtin when
it is available, increasing the accuracy of the mitigation. When runtime
sizes are not available, __builtin_dynamic_object_size() falls back to
__builtin_object_size(), leaving the existing bounds checking unchanged.

Additionally update the VMALLOC_LINEAR_OVERFLOW LKDTM test to make the
hint invisible, otherwise the architectural defense is not exercised
(the buffer overflow is detected in the memset() rather than when it
crosses the edge of the allocation).

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Tom Rix <trix@redhat.com>
Cc: linux-hardening@vger.kernel.org
Cc: llvm@lists.linux.dev
Reviewed-by: Miguel Ojeda <ojeda@kernel.org> # include/linux/compiler_attributes.h
Signed-off-by: Kees Cook <keescook@chromium.org>
2023-01-05 12:08:29 -08:00
..
Makefile lkdtm: Disable return thunks in rodata.c 2022-07-20 19:24:53 +02:00
bugs.c drivers: lkdtm: fix clang -Wformat warning 2022-07-28 16:20:36 +02:00
cfi.c lkdtm: cfi: Make PAC test work with GCC 7 and 8 2022-12-14 16:05:09 -08:00
core.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
fortify.c lkdtm: Update tests for memcpy() run-time warnings 2022-09-07 16:37:27 -07:00
heap.c fortify: Use __builtin_dynamic_object_size() when available 2023-01-05 12:08:29 -08:00
lkdtm.h lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
perms.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
powerpc.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
refcount.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
rodata.c lkdtm: don't move ctors to .rodata 2020-12-09 15:51:14 +01:00
stackleak.c Char / Misc / Other smaller driver subsystem updates for 5.19-rc1 2022-06-03 11:36:34 -07:00
usercopy.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00