• Kees Cook's avatar
    kasan: test: Silence GCC 12 warnings · aaf50b19
    Kees Cook authored
    
    
    GCC 12 continues to get smarter about array accesses. The KASAN tests
    are expecting to explicitly test out-of-bounds conditions at run-time,
    so hide the variable from GCC, to avoid warnings like:
    
    ../lib/test_kasan.c: In function 'ksize_uaf':
    ../lib/test_kasan.c:790:61: warning: array subscript 120 is outside array bounds of 'void[120]' [-Warray-bounds]
      790 |         KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[size]);
          |                                       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
    ../lib/test_kasan.c:97:9: note: in definition of macro 'KUNIT_EXPECT_KASAN_FAIL'
       97 |         expression; \
          |         ^~~~~~~~~~
    
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Andrey Konovalov <andreyknvl@gmail.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Cc: kasan-dev@googlegroups.com
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20220608214024.1068451-1-keescook@chromium.org
    aaf50b19
test_kasan.c 37.5 KB