Re: [PATCH v2] iio: imu: kmx61: Fix potential time-of-check to time-of-use race

From: Maxwell Doose

Date: Wed May 13 2026 - 11:20:30 EST


On Wed, May 13, 2026 at 6:25 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxx> wrote:
>
> 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()
>

That all sounds good. Will wait for Jonathan to see if he just wants
to merge as is, change the subject, or ask for v3.

best regards,
max



> > 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
>
>