Re: [PATCH v2] platform/chrome: sensorhub: bound the EC-reported sensor number
Tzung-Bi Shih <[email protected]>
| Newsgroups | dev.linux.lists.chrome-platform,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jun 17, 2026 at 12:42:27AM -0500, Bryam Vargas via B4 Relay wrote: > From: Bryam Vargas <[email protected]> > > Each EC FIFO event carries a sensor number (in->sensor_num, an 8-bit > value). cros_ec_sensorhub_ring_handler() validates the FIFO event count, > the per-read count and the ring bound, but not the per-event sensor > number. cros_ec_sensor_ring_process_event() then uses it unchecked to > index sensorhub->batch_state[], which is allocated with only > sensorhub->sensor_num entries, so a sensor number of sensor_num or larger > is an out-of-bounds read and write of batch_state[] - in the ODR and > FLUSH paths and, via cros_ec_sensor_ring_check_for_past_timestamp(), as > an out-of-bounds read that is fed back into the event timestamp. > > Validate the sensor number in the ring handler, where each event is read > from the EC, and drop a malformed event before it is used. This is the > bound cros_sensorhub_send_sample() already applies on the push path, > hoisted to the point where the EC data enters the kernel so it also > covers the batch_state[] indexing in cros_ec_sensor_ring_process_event() > and sensor_mask |= BIT(in->sensor_num) in the handler. > > Fixes: 93fe48a58590 ("platform/chrome: cros_ec_sensorhub: Add median filter") > Cc: [email protected] > Signed-off-by: Bryam Vargas <[email protected]> I'd trim the commit message and use: Fixes: 145d59baff59 ("platform/chrome: cros_ec_sensorhub: Add FIFO support") For my reference, Reviewed-by: Tzung-Bi Shih <[email protected]>