All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, kernel-team@meta.com,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Benjamin LaHaise <bcrl@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-aio@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH RFC 2/9] aio: Use accessor for hrtimer_sleeper ->task field
Date: Thu, 30 Jul 2026 17:40:12 -0700	[thread overview]
Message-ID: <20260731004019.3530210-2-paulmck@kernel.org> (raw)
In-Reply-To: <e76a426b-f65c-4357-b263-96506d877136@paulmck-laptop>

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@kernel.org>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: <linux-aio@kvack.org>
Cc: <linux-fsdevel@vger.kernel.org>
---
 fs/aio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index f57fa21a250353..e8cd65fce41eba 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)
-- 
2.40.1


  parent reply	other threads:[~2026-07-31  0:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  0:39 [PATCH RFC 0/9] Fix data races on hrtimer_sleeper ->task field Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 1/9] hrtimer: Mark data-racy accesses to " Paul E. McKenney
2026-07-31  0:40 ` Paul E. McKenney [this message]
2026-07-31  0:40 ` [PATCH RFC 3/9] wait: Use accessor for " Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 4/9] io-uring/rw: " Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 5/9] futex: Use accessor for hrtimer_sleeper ->task field in waitwake.c Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 6/9] timers: Use accessor for hrtimer_sleeper ->task field in sleep_timeout.c Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 7/9] net: pktgen: Use accessor for hrtimer_sleeper ->task field Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 8/9] rtmutex: " Paul E. McKenney
2026-07-31  0:40 ` [PATCH RFC 9/9] futex: Use accessor for hrtimer_sleeper ->task field in requeue Paul E. McKenney

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=20260731004019.3530210-2-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=bcrl@kvack.org \
    --cc=brauner@kernel.org \
    --cc=frederic@kernel.org \
    --cc=jack@suse.cz \
    --cc=kernel-team@meta.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.