From: Kees Cook Date: Mon, 22 May 2023 21:28:46 +0000 (-0700) Subject: lkdtm/bugs: Switch from 1-element array to flexible array X-Git-Tag: v6.6.7~2390^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b45861ed66ded8b31c718ed096c993dfba2b07df;p=platform%2Fkernel%2Flinux-starfive.git 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 Cc: Greg Kroah-Hartman Reviewed-by: Bill Wendling Signed-off-by: Kees Cook --- diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c index 48821f4..d359e38 100644 --- a/drivers/misc/lkdtm/bugs.c +++ b/drivers/misc/lkdtm/bugs.c @@ -309,7 +309,7 @@ static void lkdtm_OVERFLOW_UNSIGNED(void) struct array_bounds_flex_array { int one; int two; - char data[1]; + char data[]; }; struct array_bounds { @@ -341,7 +341,7 @@ static void lkdtm_ARRAY_BOUNDS(void) * For the uninstrumented flex array member, also touch 1 byte * beyond to verify it is correctly uninstrumented. */ - for (i = 0; i < sizeof(not_checked->data) + 1; i++) + for (i = 0; i < 2; i++) not_checked->data[i] = 'A'; pr_info("Array access beyond bounds ...\n");