hpet: Replace one-element array with flexible-array member
PATCH 1/1 hpet: Replace one-element array with flexible-array member
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
--- include/linux/hpet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hpet.h +1 -1
@@ -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
Signature · 1 line
2.34.1
Quoted 11 lines · Kees Cook
One-element arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the
FORTIFY_SOURCEroutines onmemcpy(), correctly instrument array indexing withUBSAN_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 viahpet_timersarray are already done after explicit bounds checking.
Quoted 5 lines
[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]>
Such a sneaky 1-element... ~.~
Thanks!
--
Gustavo
Quoted 20 lines
--- include/linux/hpet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/hpet.h +1
-1@@ -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_mcSignature · 1 line
2.34.1
Quoted 12 lines · Gustavo A. R. Silva
Quoted 11 lines · Kees Cook
One-element arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the
FORTIFY_SOURCEroutines onmemcpy(), correctly instrument array indexing withUBSAN_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 viahpet_timersarray are already done after explicit bounds checking.
Quoted 7 lines
Quoted 5 lines
[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]>Such a sneaky 1-element... ~.~
Yes! This one made my system unbootable after adding -fstrict-flex-arrays=3. :) All better now.
Quoted 1 line
Reviewed-by Gustavo A. R. Silva <[email protected]>
Thanks!
Signature · 1 line
Kees Cook