Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lkdtm/bugs: Switch from 1-element array to flexible array

The testing for ARRAY_BOUNDS just wants an uninstrumented array,
and the proper flexible array definition is fine for that.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bill Wendling <morbo@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>

+2 -2
+2 -2
drivers/misc/lkdtm/bugs.c
··· 309 309 struct array_bounds_flex_array { 310 310 int one; 311 311 int two; 312 - char data[1]; 312 + char data[]; 313 313 }; 314 314 315 315 struct array_bounds { ··· 341 341 * For the uninstrumented flex array member, also touch 1 byte 342 342 * beyond to verify it is correctly uninstrumented. 343 343 */ 344 - for (i = 0; i < sizeof(not_checked->data) + 1; i++) 344 + for (i = 0; i < 2; i++) 345 345 not_checked->data[i] = 'A'; 346 346 347 347 pr_info("Array access beyond bounds ...\n");