Skip to contentSkip to conversation

tests updates

PATCH Applied Dylan Yudaken 3 participants 7 messages Jul 21, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

cover tests updates

This series adds a patch for a panic in 5.19-rc7 simplified from the syzkaller reproducer
It also causes the poll-mshot-overflow test to be skipped in versions < 5.20

Patch
1: is the panic regression test
2-4: skips the poll-mshot-overflow test on old kernels

Dylan Yudaken (4):
add a test for bad buf_ring register
Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h
test: poll-mshot-overflow use proper return codes skip poll-mshot-overflow on old kernels

 src/include/liburing/io_uring.h |  4 ++++
 test/buf-ring.c                 | 30 +++++++++++++++++++++++++++++
 test/poll-mshot-overflow.c      | 34 +++++++++++++++++----------------
 3 files changed, 52 insertions(+), 16 deletions(-)

base-commit: 4e6eec8bdea906fe5341c97aef96986d605004e9

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 add a test for bad buf_ring register

This shows up a kernel panic in v5.19-rc7

---
 test/buf-ring.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
test/buf-ring.c +30 -0
index 5e032663d93b..b17030cbe952 100644
@@ -206,6 +206,30 @@ static int test_reg_unreg(int bgid)
 	return 0;
 }
 
+static int test_bad_reg(int bgid)
+{
+	struct io_uring ring;
+	int ret;
+	struct io_uring_buf_reg reg = { };
+
+	ret = t_create_ring(1, &ring, 0);
+	if (ret == T_SETUP_SKIP)
+		return 0;
+	else if (ret != T_SETUP_OK)
+		return 1;
+
+	reg.ring_addr = 4096;
+	reg.ring_entries = 32;
+	reg.bgid = bgid;
+
+	ret = io_uring_register_buf_ring(&ring, &reg, 0);
+	if (!ret)
+		fprintf(stderr, "Buffer ring register worked unexpectedly\n");
+
+	io_uring_queue_exit(&ring);
+	return !ret;
+}
+
 static int test_one_read(int fd, int bgid, struct io_uring *ring)
 {
 	int ret;
@@ -359,6 +383,12 @@ int main(int argc, char *argv[])
 		if (no_buf_ring)
 			break;
 
+		ret = test_bad_reg(bgids[i]);
+		if (ret) {
+			fprintf(stderr, "test_bad_reg failed\n");
+			return T_EXIT_FAIL;
+		}
+
 		ret = test_double_reg_unreg(bgids[i]);
 		if (ret) {
 			fprintf(stderr, "test_double_reg_unreg failed\n");
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/4 Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h

In reply to Dylan Yudaken

Copy from the 5.20 tree IORING_SETUP_SINGLE_ISSUER which is queued up.

---
 src/include/liburing/io_uring.h | 4 ++++
 1 file changed, 4 insertions(+)
src/include/liburing/io_uring.h +4 -0
index 51126c4f6fd5..99e6963f3ff9 100644
@@ -134,6 +134,10 @@ enum {
 
 #define IORING_SETUP_SQE128		(1U << 10) /* SQEs are 128 byte */
 #define IORING_SETUP_CQE32		(1U << 11) /* CQEs are 32 byte */
+/*
+ * Only one task is allowed to submit requests
+ */
+#define IORING_SETUP_SINGLE_ISSUER	(1U << 12)
 
 enum io_uring_op {
 	IORING_OP_NOP,
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/4 test: poll-mshot-overflow use proper return codes

In reply to Dylan Yudaken

This missed out on the refactor, so do it now in preparation for adding a skip path.

---
 test/poll-mshot-overflow.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
test/poll-mshot-overflow.c +13 -12
index 078df04294fc..17039f585a77 100644
@@ -10,6 +10,7 @@
 #include <sys/wait.h>
 
 #include "liburing.h"
+#include "helpers.h"
 
 int check_final_cqe(struct io_uring *ring)
 {
@@ -22,23 +23,23 @@ int check_final_cqe(struct io_uring *ring)
 			count++;
 			if (signalled_no_more) {
 				fprintf(stderr, "signalled no more!\n");
-				return 1;
+				return T_EXIT_FAIL;
 			}
 			if (!(cqe->flags & IORING_CQE_F_MORE))
 				signalled_no_more = true;
 		} else if (cqe->user_data != 3) {
 			fprintf(stderr, "%d: got unexpected %d\n", count, (int)cqe->user_data);
-			return 1;
+			return T_EXIT_FAIL;
 		}
 		io_uring_cqe_seen(ring, cqe);
 	}
 
 	if (!count) {
 		fprintf(stderr, "no cqe\n");
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
-	return 0;
+	return T_EXIT_PASS;
 }
 
 int main(int argc, char *argv[])
@@ -54,7 +55,7 @@ int main(int argc, char *argv[])
 
 	if (pipe(pipe1) != 0) {
 		perror("pipe");
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
 	struct io_uring_params params = {
@@ -65,20 +66,20 @@ int main(int argc, char *argv[])
 	ret = io_uring_queue_init_params(2, &ring, &params);
 	if (ret) {
 		fprintf(stderr, "ring setup failed: %d\n", ret);
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
 	sqe = io_uring_get_sqe(&ring);
 	if (!sqe) {
 		fprintf(stderr, "get sqe failed\n");
-		return 1;
+		return T_EXIT_FAIL;
 	}
 	io_uring_prep_poll_multishot(sqe, pipe1[0], POLLIN);
 	io_uring_sqe_set_data64(sqe, 1);
 
 	if (io_uring_cq_ready(&ring)) {
 		fprintf(stderr, "unexpected cqe\n");
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
 	for (i = 0; i < 2; i++) {
@@ -95,18 +96,18 @@ int main(int argc, char *argv[])
 
 	if (ret <= 0) {
 		fprintf(stderr, "write failed: %d\n", errno);
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
 	/* should have 2 cqe + 1 overflow now, so take out two cqes */
 	for (i = 0; i < 2; i++) {
 		if (io_uring_peek_cqe(&ring, &cqe)) {
 			fprintf(stderr, "unexpectedly no cqe\n");
-			return 1;
+			return T_EXIT_FAIL;
 		}
 		if (cqe->user_data != 2) {
 			fprintf(stderr, "unexpected user_data\n");
-			return 1;
+			return T_EXIT_FAIL;
 		}
 		io_uring_cqe_seen(&ring, cqe);
 	}
@@ -119,7 +120,7 @@ int main(int argc, char *argv[])
 
 	if (ret != 1) {
 		fprintf(stderr, "bad poll remove\n");
-		return 1;
+		return T_EXIT_FAIL;
 	}
 
 	ret = check_final_cqe(&ring);
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/4 skip poll-mshot-overflow on old kernels

In reply to Dylan Yudaken

Older kernels have slightly different behaviour, so rather skip the test on them.

---
 test/poll-mshot-overflow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
test/poll-mshot-overflow.c +6 -5
index 17039f585a77..360df65d2b15 100644
@@ -59,15 +59,16 @@ int main(int argc, char *argv[])
 	}
 
 	struct io_uring_params params = {
-		.flags = IORING_SETUP_CQSIZE,
+		/* cheat using SINGLE_ISSUER existence to know if this behaviour
+		 * is updated
+		 */
+		.flags = IORING_SETUP_CQSIZE | IORING_SETUP_SINGLE_ISSUER,
 		.cq_entries = 2
 	};
 
 	ret = io_uring_queue_init_params(2, &ring, &params);
-	if (ret) {
-		fprintf(stderr, "ring setup failed: %d\n", ret);
-		return T_EXIT_FAIL;
-	}
+	if (ret)
+		return T_EXIT_SKIP;
 
 	sqe = io_uring_get_sqe(&ring);
 	if (!sqe) {
Signature · 1 line
2.30.2
maintainer Applied
#6 lore raw
In reply to Dylan Yudaken
Quoted 9 lines · Dylan Yudaken

This series adds a patch for a panic in 5.19-rc7 simplified from the syzkaller reproducer
It also causes the poll-mshot-overflow test to be skipped in versions < 5.20

Patch
1: is the panic regression test
2-4: skips the poll-mshot-overflow test on old kernels

[...]

Applied, thanks!

[1/4] add a test for bad buf_ring register

      commit: ded2677991f3af247206f67f466111b3060006b7
[2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h
      commit: 205f2e87471ef543b867fdea2140309507a2e1f7
[3/4] test: poll-mshot-overflow use proper return codes
      commit: 7591d1af4b5a16f4371c0bd907ef71575a837315
[4/4] skip poll-mshot-overflow on old kernels
      commit: 4538e990a8c909bd0e7d3e5ecc0016a4e5f26b0c

Best regards,

Signature · 1 line
Jens Axboe