From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jann Horn <jannh@google.com>, Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
Dominik Maier <dmnk+artist@google.com>,
stable+noautosel@kernel.org, Jann Horn <jannh@google.com>
Subject: Re: [PATCH] io_uring/fdinfo: ignore IORING_CQE_F_32 in last CQ array slot
Date: Fri, 11 Sep 2026 13:33:42 -0300 [thread overview]
Message-ID: <87y0d721eh.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260911-uring-fdinfo-tighten-v1-1-47c62a154aca@google.com>
Jann Horn <jannh@google.com> writes:
>
> diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c
> index 3ae4804765b9..0b656a6c8428 100644
> --- a/io_uring/fdinfo.c
> +++ b/io_uring/fdinfo.c
> @@ -155,9 +155,11 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
> for (i = 0; i < cq_entries; i++) {
> struct io_uring_cqe *cqe;
> bool cqe32 = false;
> + bool is_last_cqarray_slot = (cq_head == cq_mask);
>
> cqe = &r->cqes[(cq_head & cq_mask)];
> - if (cqe->flags & IORING_CQE_F_32 || ctx->flags & IORING_SETUP_CQE32)
> + if ((cqe->flags & IORING_CQE_F_32 || ctx->flags & IORING_SETUP_CQE32) &&
> + !is_last_cqarray_slot)
Could we have a small comment here explaining we can't just trust
IORING_CQE_F_32 for the last slot? it is very non-obvious to me from
the code. Something as simple as (if I got it right):
/* userspace can manipulate IORING_CQE_F_32 which is usually harmless,
* except in the last CQ slot. Ignore the flag only for that slot to avoid
* reading memory out-of-bounds.
*/
Either way,
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Thanks,
> cqe32 = true;
> seq_printf(m, "%5u: user_data:%llu, res:%d, flags:%x",
> cq_head & cq_mask, cqe->user_data, cqe->res,
>
> ---
> base-commit: 50d05c7c76c96b90462f24debacca971d2e86713
> change-id: 20260910-uring-fdinfo-tighten-1b1c18945305
>
> Best regards,
> --
> Jann Horn <jannh@google.com>
>
--
Gabriel Krisman Bertazi
prev parent reply other threads:[~2026-09-11 16:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 15:34 [PATCH] io_uring/fdinfo: ignore IORING_CQE_F_32 in last CQ array slot Jann Horn
2026-09-11 15:37 ` Jann Horn
2026-09-11 15:44 ` Jann Horn
2026-09-11 15:50 ` Jens Axboe
2026-09-11 15:52 ` Jann Horn
2026-09-11 15:55 ` Jens Axboe
2026-09-11 16:33 ` Gabriel Krisman Bertazi [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=87y0d721eh.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=dmnk+artist@google.com \
--cc=io-uring@vger.kernel.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable+noautosel@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 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.