From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev,
Leonid Ovchinnikov <teiny.work@gmail.com>,
Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 7.2 39/88] io_uring: drop the CQE cache if a refill fails
Date: Wed, 28 Oct 2026 17:59:47 +0100 [thread overview]
Message-ID: <20261028165943.031121717@linuxfoundation.org> (raw)
In-Reply-To: <20261028165942.107695352@linuxfoundation.org>
7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <josef@toxicpanda.com>
Commit 78f9c9cffef02a290b6e97672aaa9c75df0d21da upstream.
->cqe_cached and ->cqe_sentinel delimit the CQ entries which can be
handed out without looking at the ring. io_get_cqe_overflow() only calls
io_cqe_cache_refill() if that range is too small. Without
IORING_SETUP_CQE_MIXED too small means empty. With it, a 32b CQE needs
two entries, and one may be left. If the refill then fails, the entry
stays in the cache, and the next 16b CQE gets it without any checks.
That CQE overtakes the 32b one, which went to the overflow list. The test
for IO_CHECK_CQ_OVERFLOW_BIT, which is there to prevent that, is part of
the refill:
CQ ring with 4 entries, head == 0
16b CQE, 32b CQE tail == 3, one entry cached
32b CQE no room, the CQE overflows
16b CQE written to entry 3, ahead of the 32b CQE
Forget about the rest of the cache when it is refilled.
Fixes: e26dca67fde1 ("io_uring: add support for IORING_SETUP_CQE_MIXED")
Reported-by: Leonid Ovchinnikov <teiny.work@gmail.com>
Closes: https://lore.kernel.org/io-uring/CAECZYD5OMD9vMTzjteFMMP40Dn+SWKj9SFj=43U6uO3XMnxJbw@mail.gmail.com/
Assisted-by: LLM
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20261015-b4-io-uring-fixes-v1-23-c1556f5d7bf5@toxicpanda.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
io_uring/io_uring.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -739,6 +739,13 @@ bool io_cqe_cache_refill(struct io_ring_
return false;
/*
+ * A single entry may be left if a 32b CQE is asked for. It must not be
+ * handed out later on if this fails, as the CQE is going to overflow.
+ */
+ ctx->cqe_cached = NULL;
+ ctx->cqe_sentinel = NULL;
+
+ /*
* Post dummy CQE if a 32b CQE is needed and there's only room for a
* 16b CQE before the ring wraps.
*/
next prev parent reply other threads:[~2026-10-28 17:07 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 16:59 [PATCH 7.2 00/88] 7.2.14-rc1 review Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 01/88] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks off DSQs Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 02/88] ntfs: fix race between fallocate and mmap reads Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 03/88] ntfs: take invalidate_lock in ntfs_filemap_page_mkwrite() Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 04/88] mm/damon/core: error damos_commit_quota_goal() for zero target_value Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 05/88] sched/fair: Avoid overflow in place_entity() Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 06/88] Bluetooth: L2CAP: refuse __l2cap_chan_add if chan already has conn Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 07/88] tools/dma: fix building with O= Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 08/88] tracing: Hold trace_types_lock when updating modules in persistent instances Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 09/88] tracing: Hold trace_types_lock when resetting last boot data from readers Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 10/88] tracing: Reject incomplete event filter expressions Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 11/88] tracing: Save the event file instead of the compatible histogram Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 12/88] tracing: Unregister field variable histograms when the command fails Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 13/88] tracing: Fix 64-bit and signed histogram fields on 32-bit kernels Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 14/88] tracing/histograms: Verify event_call identity when updating synth_event refcount Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 15/88] tracing/syscalls: Use copy_from_user for the faultable syscall buffer Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 16/88] io-wq: order the exit bit against worker creation task work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 17/88] io_uring/waitid: own the request before clearing ->head Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 18/88] io_uring/cmd: dont leave list poison in ->hash_node Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 19/88] io_uring/wait: dont spin on a stuck overflow list Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 20/88] io_uring/io-wq: dont lose the signal that ends work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 21/88] io_uring/io-wq: dont hide a link from cancellations Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 22/88] io_uring: dont flood a cancelling task with task_work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 23/88] io_uring: dont lose the DEFER_TASKRUN wake up Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 24/88] io_uring/cancel: rearm local work wake up before sleep Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 25/88] io_uring/mpscq: disable preemption while pushing Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 26/88] io_uring/io-wq: dont go to sleep on pending work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 27/88] io_uring/io-wq: dont strand work when a worker exits Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 28/88] io_uring/io-wq: dont exit with a creation pending Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 29/88] io_uring/io-wq: let cancel find picked up hashed work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 30/88] io_uring/poll: dont lose a cancel as io-wq arms poll Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 31/88] io_uring: dont lose a cancel as io-wq parks a request Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 32/88] io_uring/cancel: dont forget that the work was running Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 33/88] io_uring/cancel: recognize "no timeout" on 32-bit Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 34/88] io_uring/cancel: let CANCEL_ALL find parked requests Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 35/88] io_uring: wake ring pollers for local task_work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 36/88] io_uring/wait: look at all CQ waiters on wake up Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 37/88] io_uring/poll: drop stale double poll entry on rearm Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 38/88] io_uring/futex: allocate private hash before waiting Greg Kroah-Hartman
2026-10-28 16:59 ` Greg Kroah-Hartman [this message]
2026-10-28 16:59 ` [PATCH 7.2 40/88] io_uring: dont split 128b SQEs at the SQPOLL cap Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 41/88] io_uring/register: dont wrap 32b CQEs when resizing Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 42/88] io_uring/register: handle index wrap " Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 43/88] io_uring/register: keep 128b SQEs intact on resize Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 44/88] io_uring/fdinfo: fix CQE dump of CQE32 rings Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 45/88] io_uring/timeout: dont skip over reached sequences Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 46/88] io_uring/timeout: keep repeat count on multishot update Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 47/88] io_uring/timeout: use the right clock for ABS updates Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 48/88] io_uring/wait: no early -ETIME if min_wait finds work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 49/88] io_uring/napi: make stale entries time out after 60s Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 50/88] io_uring/napi: dont busy poll past an expired timeout Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 51/88] io_uring/zcrx: fix buffer offsets in areas above 4GB Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 52/88] io_uring/kbuf: handle index wrap in last buffer check Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 53/88] io_uring/sqpoll: let the thread sleep on disabled rings Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 54/88] io_uring/openclose: keep the lock in io_pipe_fixed() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 55/88] io_uring: dont pass restart error codes to userspace Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 56/88] io_uring/net: dont retry recv on uncommitted buffers Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 57/88] io_uring/timeout: no ABS update of multishot timeouts Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 58/88] io_uring/timeout: dont end a linked timeout with 1 Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 59/88] io_uring: look up the file before queueing to io-wq Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 60/88] io_uring/poll: avoid retry wakeup loss when dropping ownership Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 61/88] io_uring/timeout: dont put a sequence target behind the last flush Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 62/88] io_uring/timeout: dont flush with the sequence " Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 63/88] io_uring/timeout: dont lose a cancel as io-wq arms a timeout Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 64/88] io_uring/poll: dont loop on HUP with multiple references Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 65/88] io_uring/net: keep recv buffer select length within MAX_RW_COUNT Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 66/88] io_uring/wait: wake real-time waiters from hard interrupt context Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 67/88] io_uring/waitid: prevent cancel reference wrap Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 68/88] io_uring: end the drain when the drain request completes Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 69/88] io_uring: keep the drain active when a deferred drain request is started Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 70/88] keys: Avoid the owner account dereference in named keyring lookup Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 71/88] keys: Check the authorization payload in process keyring searches Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 72/88] keys: Protect the type name while describing a key Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 73/88] keys: make keyring indexes independent of kernel addresses Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 74/88] keys: Protect the read method check against type removal Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 75/88] KEYS: Fix key_reject_and_link() race with keyring restriction Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 76/88] KEYS: trusted: Fix blob allocation size in tpm2_key_decode() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 77/88] keys/trusted_keys: return immediately after TPM unseal failure Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 78/88] asymmetric_keys: reject trust keys without IDs Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 79/88] ftrace: Initialize modname and offset in print_rec() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 80/88] coredump: hold RCU while releasing parked threads Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 81/88] signal: only SIGKILL and the freezers interrupt a coredumping task Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 82/88] signal: dont retarget shared signals in a dying thread group Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 83/88] ptrace: refuse to change the signal mask of a user worker Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 84/88] fork: release the files of a failed fork after sched_cancel_fork() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 85/88] exit: hang up the tty before closing the files Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 86/88] coredump: prevent TIF_NOTIFY_SIGNAL from interrupting coredumps Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 87/88] pid_namespace: prevent TIF_NOTIFY_SIGNAL from interrupting the reaper Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 88/88] signal: allow taks to temporarily block TIF_NOTIFY_SIGNAL Greg Kroah-Hartman
2026-10-28 19:39 ` [PATCH 7.2 00/88] 7.2.14-rc1 review Brett A C Sheffield
2026-10-29 4:09 ` Peter Schneider
2026-10-29 10:08 ` Pavel Machek
2026-10-29 13:49 ` Miguel Ojeda
2026-10-29 14:17 ` Ron Economos
2026-10-29 14:43 ` SJ Park
2026-10-29 15:19 ` Shuah Khan
2026-10-29 15:57 ` Barry K. Nathan
2026-10-29 16:56 ` Florian Fainelli
2026-10-29 22:27 ` Sean Lyon
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=20261028165943.031121717@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=teiny.work@gmail.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 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.