From: Jens Axboe <axboe@kernel.dk>
To: Hui Peng <benquike@gmail.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring: fix CQ tail over-commit and CQE32 index corruption in io_cqe_cache_refill()
Date: Mon, 21 Sep 2026 10:10:35 -0600 [thread overview]
Message-ID: <cbdf1ef2-7fe0-4cd9-8ce4-3235478e536b@kernel.dk> (raw)
In-Reply-To: <20260919203516.2581409-1-benquike@gmail.com>
On 9/19/26 2:35 PM, Hui Peng wrote:
> io_cqe_cache_refill() has three issues when handling 32-byte CQEs on
> IORING_SETUP_CQE32 and IORING_SETUP_CQE_MIXED rings:
Don't combine fixes, send 3 separate patches.
> 1. When cqe32 is true and off + 1 == ctx->cq_entries,
> io_cqe_cache_refill() posts a 16-byte dummy IORING_CQE_F_SKIP CQE via
> io_fill_nop_cqe(ctx, off) even on pure IORING_SETUP_CQE32 rings
> (where IORING_SETUP_CQE_MIXED is not set). On a pure CQE32 ring,
> ctx->cq_entries is the number of 32-byte CQEs and rings->cqes is
> indexed by (off << 1), so writing a 16-byte skip CQE at
> &rings->cqes[off] corrupts the middle of the CQ ring and misaligns
> all subsequent CQEs. Restrict the wrap-around skip CQE to
> IORING_SETUP_CQE_MIXED rings.
>
> 2. On an IORING_SETUP_CQE_MIXED ring, when off + 1 == ctx->cq_entries
> and only 1 free CQ slot remains (ctx->cq_entries - io_cqring_queued()
> == 1), io_fill_nop_cqe(ctx, off) consumes that last slot and
> increments ctx->cached_cq_tail, after which free == 0 causes
> io_cqe_cache_refill() to return false without updating
> ctx->cqe_cached. Check that at least 2 free CQ slots exist before
> posting the dummy skip CQE.
These two look fine.
> 3. On pure IORING_SETUP_CQE32 rings, len is in 32-byte CQE units prior
> to `len <<= 1`, so `len < (cqe32 + 1)` falsely requires 2 free
> 32-byte CQEs instead of 1. Check `!len` before scaling `off` and
> `len` on IORING_SETUP_CQE32 rings, and in io_fill_cqe_aux() zero
> cqe->big_cqe[0..1] whenever IORING_SETUP_CQE32 is set on the ring.
This part looks wrong.
--
Jens Axboe
prev parent reply other threads:[~2026-09-21 16:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 20:35 Hui Peng
2026-09-21 16:10 ` Jens Axboe [this message]
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=cbdf1ef2-7fe0-4cd9-8ce4-3235478e536b@kernel.dk \
--to=axboe@kernel.dk \
--cc=benquike@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®