path: root/test/nop.c
diff options
authorJens Axboe <>2019-04-17 09:25:32 -0600
committerJens Axboe <>2019-04-17 09:42:23 -0600
commit76b61ebf1bd17d3a31c3bf2d8236b9bd50d0f9a8 (patch)
treec2216573054fa22dab7e9c5672ba60a3ae28fbb1 /test/nop.c
parent26993e98723e1f2d9be94b53068ead1e4a9a849d (diff)
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 <>
Diffstat (limited to 'test/nop.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/test/nop.c b/test/nop.c
index a37246b..7fe2455 100644
--- a/test/nop.c
+++ b/test/nop.c
@@ -37,6 +37,7 @@ static int test_single_nop(struct io_uring *ring)
goto err;
+ io_uring_cqe_seen(ring, cqe);
return 0;
return 1;
@@ -75,6 +76,7 @@ static int test_barrier_nop(struct io_uring *ring)
printf("wait completion %d\n", ret);
goto err;
+ io_uring_cqe_seen(ring, cqe);
return 0;