kasan: test: Silence GCC 12 warnings
authorKees Cook <keescook@chromium.org>
Wed, 8 Jun 2022 21:40:24 +0000 (14:40 -0700)
committerKees Cook <keescook@chromium.org>
Wed, 27 Jul 2022 20:34:41 +0000 (13:34 -0700)
commitaaf50b1969d7933a51ea421b11432a7fb90974e3
tree2960ebfa9ee7f46152ac17765941838b73883bd0
parentb4909252da9be56fe1e0a23c2c1908c5630525fa
kasan: test: Silence GCC 12 warnings

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: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220608214024.1068451-1-keescook@chromium.org
lib/test_kasan.c