[lvc-project] Patch "io_uring/napi: fix io_napi_entry RCU accesses" has been added to the 6.12-stable tree

gregkh at linuxfoundation.org gregkh at linuxfoundation.org
Fri Nov 21 12:57:40 MSK 2025


This is a note to let you know that I've just added the patch titled

    io_uring/napi: fix io_napi_entry RCU accesses

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-napi-fix-io_napi_entry-rcu-accesses.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.


>From s.artuhov at tssltd.ru Wed Nov 12 12:37:46 2025
From: Stepan Artuhov <s.artuhov at tssltd.ru>
Date: Wed, 12 Nov 2025 14:37:06 +0300
Subject: io_uring/napi: fix io_napi_entry RCU accesses
To: stable at vger.kernel.org, Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: Olivier Langlois <olivier at trillion01.com>, Jens Axboe <axboe at kernel.dk>, Pavel Begunkov <asml.silence at gmail.com>, io-uring at vger.kernel.org, linux-kernel at vger.kernel.org, lvc-project at linuxtesting.org, Stepan Artuhov <s.artuhov at tssltd.ru>
Message-ID: <20251112113706.533309-1-s.artuhov at tssltd.ru>

From: Olivier Langlois <olivier at trillion01.com>

[Upstream commit 45b3941d09d13b3503309be1f023b83deaf69b4d ]

correct 3 RCU structures modifications that were not using the RCU
functions to make their update.

Cc: Jens Axboe <axboe at kernel.dk>
Cc: Pavel Begunkov <asml.silence at gmail.com>
Cc: io-uring at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: lvc-project at linuxtesting.org
Signed-off-by: Olivier Langlois <olivier at trillion01.com>
Link: https://lore.kernel.org/r/9f53b5169afa8c7bf3665a0b19dc2f7061173530.1728828877.git.olivier@trillion01.com
Signed-off-by: Jens Axboe <axboe at kernel.dk>
[Stepan Artuhov: cherry-picked a commit]
Signed-off-by: Stepan Artuhov <s.artuhov at tssltd.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 io_uring/napi.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

--- a/io_uring/napi.c
+++ b/io_uring/napi.c
@@ -81,19 +81,24 @@ void __io_napi_add(struct io_ring_ctx *c
 	}
 
 	hlist_add_tail_rcu(&e->node, hash_list);
-	list_add_tail(&e->list, &ctx->napi_list);
+	list_add_tail_rcu(&e->list, &ctx->napi_list);
 	spin_unlock(&ctx->napi_lock);
 }
 
 static void __io_napi_remove_stale(struct io_ring_ctx *ctx)
 {
 	struct io_napi_entry *e;
-	unsigned int i;
 
 	spin_lock(&ctx->napi_lock);
-	hash_for_each(ctx->napi_ht, i, e, node) {
-		if (time_after(jiffies, e->timeout)) {
-			list_del(&e->list);
+	/*
+	 * list_for_each_entry_safe() is not required as long as:
+	 * 1. list_del_rcu() does not reset the deleted node next pointer
+	 * 2. kfree_rcu() delays the memory freeing until the next quiescent
+	 *    state
+	 */
+	list_for_each_entry(e, &ctx->napi_list, list) {
+		if (time_after(jiffies, READ_ONCE(e->timeout))) {
+			list_del_rcu(&e->list);
 			hash_del_rcu(&e->node);
 			kfree_rcu(e, rcu);
 		}
@@ -204,13 +209,13 @@ void io_napi_init(struct io_ring_ctx *ct
 void io_napi_free(struct io_ring_ctx *ctx)
 {
 	struct io_napi_entry *e;
-	unsigned int i;
 
 	spin_lock(&ctx->napi_lock);
-	hash_for_each(ctx->napi_ht, i, e, node) {
+	list_for_each_entry(e, &ctx->napi_list, list) {
 		hash_del_rcu(&e->node);
 		kfree_rcu(e, rcu);
 	}
+	INIT_LIST_HEAD_RCU(&ctx->napi_list);
 	spin_unlock(&ctx->napi_lock);
 }
 


Patches currently in stable-queue which might be from s.artuhov at tssltd.ru are

queue-6.12/io_uring-napi-fix-io_napi_entry-rcu-accesses.patch



More information about the lvc-project mailing list