pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: aio: io_uring: Fix danger of completion getting reused before be
Date: Thu, 15 Jan 2026 16:10:37 +0000
Message-ID: <E1vgPvg-000dZJ-11@gemulon.postgresql.org> (raw)

aio: io_uring: Fix danger of completion getting reused before being read

We called io_uring_cqe_seen(..., cqe) before reading cqe->res. That allows the
completion to be reused, which in turn could lead to cqe->res being
overwritten. The window for that is very narrow and the likelihood of it
happening is very low, as we should never actually utilize all CQEs, but the
consequences would be bad.

This bug was reported to me privately.

Backpatch-through: 18
Discussion: https://postgr.es/m/bwo3e5lj2dgi2wzq4yvbyzu7nmwueczvvzioqsqo6azu6lm5oy@pbx75g2ach3p

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8077649907d40b9831358d0c5121a8c58267a988

Modified Files
--------------
src/backend/storage/aio/method_io_uring.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1vgPvg-000dZJ-11@gemulon.postgresql.org>
Permalink:  ../E1vgPvg-000dZJ-11@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vgPvg-000dZJ-11@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: aio: io_uring: Fix danger of completion getting reused before be
  In-Reply-To: <E1vgPvg-000dZJ-11@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox