[tip: timers/core] aio: Use accessor for hrtimer_sleeper ->task field

From: tip-bot2 for Paul E. McKenney

Date: Tue Sep 29 2026 - 15:07:33 EST


The following commit has been merged into the timers/core branch of tip:

Commit-ID: cefc1a24ace53c9b26f5adee1f60a439cc0d53a4
Gitweb: https://git.kernel.org/tip/cefc1a24ace53c9b26f5adee1f60a439cc0d53a4
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
AuthorDate: Fri, 18 Sep 2026 17:14:18 -07:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 29 Sep 2026 21:02:51 +02:00

aio: Use accessor for hrtimer_sleeper ->task field

The hrtimer_sleeper structure's ->task field is used as a flag to indicate
that the associated hrtimer has expired. This means that the hrtimer
handler can be storing to this field while other code is loading from it
to check for expiry. Note that additional races appear for hrtimers that
can be restarted, which could be argued to be a user error. However, that
is no reason to let the compiler introduce additional confusion, and to
this end, the hrtimer_sleeper_task_get() was introduced, use of which also
has the benefit of avoiding open-code access to hrtimer_sleeper innards.

KCSAN located this issue.

Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Reviewed-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
Acked-by: Jan Kara <jack@xxxxxxx>
Link: https://patch.msgid.link/20260919001428.3133388-2-paulmck@xxxxxxxxxx
---
fs/aio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index d78acc6..8130d9e 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1402,7 +1402,7 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr,
w.min_nr = min_nr - ret;

ret2 = prepare_to_wait_event(&ctx->wait, &w.w, TASK_INTERRUPTIBLE);
- if (!ret2 && !t.task)
+ if (!ret2 && !hrtimer_sleeper_task_get(&t))
ret2 = -ETIME;

if (aio_read_events(ctx, min_nr, nr, event, &ret) || ret2)