lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 13 Dec 2019 20:11:22 +0300
From:   Pavel Begunkov <asml.silence@...il.com>
To:     Jens Axboe <axboe@...nel.dk>, io-uring@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2 liburing] Test wait after under-consuming

In case of an error submission won't consume all sqes. This tests that
it will get back to the userspace even if (to_submit == to_wait)

Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---

since v1: don't leave ring dirty, as it will fail following tests

 test/link.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/test/link.c b/test/link.c
index 8ec1649..6c8ae09 100644
--- a/test/link.c
+++ b/test/link.c
@@ -384,6 +384,50 @@ err:
 	return 1;
 }
 
+static int test_early_fail_and_wait(void)
+{
+	struct io_uring ring;
+	struct io_uring_sqe *sqe;
+	int ret, invalid_fd = 42;
+	struct iovec iov = { .iov_base = NULL, .iov_len = 0 };
+
+	/* create a new ring as it leaves it dirty */
+	ret = io_uring_queue_init(8, &ring, 0);
+	if (ret) {
+		printf("ring setup failed\n");
+		return 1;
+	}
+
+	sqe = io_uring_get_sqe(&ring);
+	if (!sqe) {
+		printf("get sqe failed\n");
+		goto err;
+	}
+
+	io_uring_prep_readv(sqe, invalid_fd, &iov, 1, 0);
+	sqe->flags |= IOSQE_IO_LINK;
+
+	sqe = io_uring_get_sqe(&ring);
+	if (!sqe) {
+		printf("get sqe failed\n");
+		goto err;
+	}
+
+	io_uring_prep_nop(sqe);
+
+	ret = io_uring_submit_and_wait(&ring, 2);
+	if (ret <= 0 && ret != -EAGAIN) {
+		printf("sqe submit failed: %d\n", ret);
+		goto err;
+	}
+
+	io_uring_queue_exit(&ring);
+	return 0;
+err:
+	io_uring_queue_exit(&ring);
+	return 1;
+}
+
 int main(int argc, char *argv[])
 {
 	struct io_uring ring, poll_ring;
@@ -400,7 +444,6 @@ int main(int argc, char *argv[])
 	if (ret) {
 		printf("poll_ring setup failed\n");
 		return 1;
-
 	}
 
 	ret = test_single_link(&ring);
@@ -439,5 +482,11 @@ int main(int argc, char *argv[])
 		return ret;
 	}
 
+	ret = test_early_fail_and_wait();
+	if (ret) {
+		fprintf(stderr, "test_early_fail_and_wait\n");
+		return ret;
+	}
+
 	return 0;
 }
-- 
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ