Re: [PATCH v2] iio: imu: kmx61: Fix potential time-of-check to time-of-use race
From: Andy Shevchenko
Date: Wed May 13 2026 - 07:25:37 EST
On Tue, May 12, 2026 at 08:36:38PM -0500, Maxwell Doose wrote:
The Subject can be made better:
iio: imu: kmx61: Fix potential TOCTOU race in kmx61_write_event_config()
> A time-of-check to time-of-use race condition exists in
> kmx61_write_event_config(). If two threads enter the function at the
> same time, both threads may pass the check and get to the lock. Thus,
> when the first thread releases the lock allowing the second thread to
> start execution after the first thread modifies data->ev_enable_state to
> force returning from the function, the second thread continues execution
> regardless. Fix this by moving the data->ev_enable_state check inside of
> the critical section.
--
With Best Regards,
Andy Shevchenko