KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
80 stars 5 forks source link

Replace fake flexible array with C99 flexible-array member in include/linux/platform_data/cros_ec_commands.h #262

Closed GustavoARSilva closed 1 year ago

GustavoARSilva commented 1 year ago
2690 struct ec_response_motion_sense {
2691         union {
2692                 /* Used for MOTIONSENSE_CMD_DUMP */
2693                 struct __ec_todo_unpacked {
2694                         /* Flags representing the motion sensor module. */
2695                         uint8_t module_flags;
2696 
2697                         /* Number of sensors managed directly by the EC. */
2698                         uint8_t sensor_count;
2699 
2700                         /*
2701                          * Sensor data is truncated if response_max is too small
2702                          * for holding all the data.
2703                          */
2704                         struct ec_response_motion_sensor_data sensor[0];
2705                 } dump;
...

-Warray-bounds warnings with GCC-13 and -fstrict-flex-arrays=3:

drivers/iio/accel/cros_ec_accel_legacy.c:66:46: warning: array subscript <unknown> is outside array bounds of ‘struct ec_response_motion_sensor_data[0]’ [-Warray-bounds=]
GustavoARSilva commented 1 year ago

Patch: https://lore.kernel.org/linux-hardening/ZAZUGBmSLc5wg7AK@work/