From: Jonathan Cameron <jic23@kernel.org>
To: Maxwell Doose <m32285159@gmail.com>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Daniel Baluta" <daniel.baluta@intel.com>,
"open list:IIO SUBSYSTEM AND DRIVERS" <linux-iio@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: imu: kmx61: Fix TOCTOU race condition
Date: Tue, 12 May 2026 18:10:40 +0100 [thread overview]
Message-ID: <20260512181040.7578fbd0@jic23-huawei> (raw)
In-Reply-To: <CAKqfh0FyELOpgB1W+_nv4a1G1tuSjnVxbEFrUeR2+KCT2Q=-Ug@mail.gmail.com>
On Tue, 12 May 2026 10:30:42 -0500
Maxwell Doose <m32285159@gmail.com> wrote:
> On Tue, May 12, 2026 at 10:25 AM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > On Tue, May 12, 2026 at 6:17 PM Maxwell Doose <m32285159@gmail.com> wrote:
> > >
> > > On Tue May 12, 2026 at 7:03 AM CDT, Maxwell Doose wrote:
> > > > A Time-of-check to Time-of-use race condition is present in
> > > > kmx61_write_event_config(). Move the mutex_lock() call above it to fix
> > > > it.
> >
> > I think you want to elaborate a bit more on this. Id est explain why
> > ev_enable_state needs to be protected. Not everybody is willing to go
> > to some site to read some AI reports and interpreted them.
> >
>
> Can do that for v2. I believe that it needs to be protected since
> later we set ev_enable_state to false (basically right after). Could
> be wrong of course, but Jonathan did confirm the TOCTOU.
I'd talk more about how we'd get a race. If two calls enter the function
at the same time (which is easy to do) they may both pass this check before
getting to the lock. Therefore we end up with at best pointless repeated
work, at worst a reference or similar count issue. You'd need to look closely
at what is protected to be sure whether it benign waste of time or a real
bug.
Jonathan
>
> best regards,
> max
>
>
>
> >
> > > Reported-by: sashiko <sashiko-bot@kernel.org>
> > > Closes: https://sashiko.dev/#/patchset/20260507223337.48437-1-m32285159%40gmail.com
> >
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
next prev parent reply other threads:[~2026-05-12 17:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 12:03 [PATCH] iio: imu: kmx61: Fix TOCTOU race condition Maxwell Doose
2026-05-12 15:17 ` Maxwell Doose
2026-05-12 15:24 ` Andy Shevchenko
2026-05-12 15:30 ` Maxwell Doose
2026-05-12 17:10 ` Jonathan Cameron [this message]
2026-05-12 17:37 ` Maxwell Doose
2026-05-12 15:54 ` David Lechner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512181040.7578fbd0@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=daniel.baluta@intel.com \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m32285159@gmail.com \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox