projects/linux·commit d662198e

hpet: Replace one-element array with flexible-array member

d662198e · Kees Cook <[email protected]> · 2022-11-17 19:42:55 -08:00

One-element arrays are deprecated[1] and are being replaced with
flexible array members in support of the ongoing efforts to tighten the
FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace one-element array with flexible-array member in struct hpet.

This results in no differences in binary output. The use of struct hpet
is never used with sizeof() and accesses via hpet_timers array are
already done after explicit bounds checking.

[1] https://github.com/KSPP/linux/issues/79

Cc: Clemens Ladisch <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Reviewed-by: Gustavo A. R. Silva <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Commit
d662198e03bc7fb4635156ee7e8b8d325e2d8512
Parents
bdc77507

Changes

1 files changed · +1 −1

FileStatusAddDelContent
include/linux/hpet.hmodified+1−1View file

include/linux/hpet.h

View file
diff --git a/include/linux/hpet.h b/include/linux/hpet.h
index 8604564..21e69ea 100644
--- a/include/linux/hpet.h
+++ b/include/linux/hpet.h
@@ -30,7 +30,7 @@ struct hpet {
unsigned long _hpet_compare;
} _u1;
u64 hpet_fsb[2]; /* FSB route */
- } hpet_timers[1];
+ } hpet_timers[];
};
#define hpet_mc _u0._hpet_mc