Add io_uring_cqe_seen()

There's a failure case where an application gets a cqe entry, but
the kernel can then overwrite it before the application is done
reading it. This can happen since the io_uring_{get,wait}_completion()
interface both returns a CQE pointer AND increments the ring index.
If the kernel reuses this entry before the applications is done reading
it, the contents may be corrupted.

Remove the CQ head increment from the CQE retrieval, and put it into
a separate helper, io_uring_cqe_seen(). The application must call this
helper when it got a new CQE entry through one of the above calls, and
it's now done reading it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
11 files changed
tree: c2216573054fa22dab7e9c5672ba60a3ae28fbb1
  1. man/
  2. src/
  3. test/
  4. .gitignore
  5. configure
  6. COPYING
  7. liburing.spec
  8. Makefile