linux/drivers/misc/lkdtm
Kees Cook f260fd59e3 lkdtm/heap: Hide allocation size from -Warray-bounds
With the kmalloc() size annotations, GCC is smart enough to realize that
LKDTM is intentionally writing past the end of the buffer. This is on
purpose, of course, so hide the buffer from the optimizer. Silences:

../drivers/misc/lkdtm/heap.c: In function 'lkdtm_SLAB_LINEAR_OVERFLOW':
../drivers/misc/lkdtm/heap.c:59:13: warning: array subscript 256 is outside array bounds of 'void[1020]' [-Warray-bounds]
   59 |         data[1024 / sizeof(u32)] = 0x12345678;
      |         ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/misc/lkdtm/heap.c:7:
In function 'kmalloc',
    inlined from 'lkdtm_SLAB_LINEAR_OVERFLOW' at ../drivers/misc/lkdtm/heap.c:54:14:
../include/linux/slab.h:581:24: note: at offset 1024 into object of size 1020 allocated by 'kmem_cache_alloc_trace'
  581 |                 return kmem_cache_alloc_trace(
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
  582 |                                 kmalloc_caches[kmalloc_type(flags)][index],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  583 |                                 flags, size);
      |                                 ~~~~~~~~~~~~

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
2022-05-17 14:47:08 -07:00
..
bugs.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
cfi.c lkdtm: cfi: Fix type width for masking PAC bits 2022-04-26 17:11:05 -07:00
core.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
fortify.c lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
heap.c lkdtm/heap: Hide allocation size from -Warray-bounds 2022-05-17 14:47:08 -07:00
lkdtm.h lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
Makefile Char/Misc and other driver changes for 5.17-rc1 2022-01-14 16:02:28 +01: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 lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
usercopy.c lkdtm/usercopy: Check vmalloc and >0-order folios 2022-05-17 14:35:49 -07:00