All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing 0/4] tests updates
@ 2022-07-21 14:42 Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 1/4] add a test for bad buf_ring register Dylan Yudaken
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Dylan Yudaken @ 2022-07-21 14:42 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, Kernel-team, 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

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
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH liburing 1/4] add a test for bad buf_ring register
  2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
@ 2022-07-21 14:42 ` Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h Dylan Yudaken
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Dylan Yudaken @ 2022-07-21 14:42 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken

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

Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 test/buf-ring.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/test/buf-ring.c b/test/buf-ring.c
index 5e032663d93b..b17030cbe952 100644
--- a/test/buf-ring.c
+++ b/test/buf-ring.c
@@ -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");
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h
  2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 1/4] add a test for bad buf_ring register Dylan Yudaken
@ 2022-07-21 14:42 ` Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 3/4] test: poll-mshot-overflow use proper return codes Dylan Yudaken
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Dylan Yudaken @ 2022-07-21 14:42 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken

Copy from the 5.20 tree IORING_SETUP_SINGLE_ISSUER which is queued up.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 src/include/liburing/io_uring.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 51126c4f6fd5..99e6963f3ff9 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 3/4] test: poll-mshot-overflow use proper return codes
  2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 1/4] add a test for bad buf_ring register Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h Dylan Yudaken
@ 2022-07-21 14:42 ` Dylan Yudaken
  2022-07-21 14:42 ` [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels Dylan Yudaken
  2022-07-21 15:26 ` [PATCH liburing 0/4] tests updates Jens Axboe
  4 siblings, 0 replies; 7+ messages in thread
From: Dylan Yudaken @ 2022-07-21 14:42 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken

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

Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 test/poll-mshot-overflow.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/test/poll-mshot-overflow.c b/test/poll-mshot-overflow.c
index 078df04294fc..17039f585a77 100644
--- a/test/poll-mshot-overflow.c
+++ b/test/poll-mshot-overflow.c
@@ -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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels
  2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
                   ` (2 preceding siblings ...)
  2022-07-21 14:42 ` [PATCH liburing 3/4] test: poll-mshot-overflow use proper return codes Dylan Yudaken
@ 2022-07-21 14:42 ` Dylan Yudaken
  2022-07-21 14:57   ` Ammar Faizi
  2022-07-21 15:26 ` [PATCH liburing 0/4] tests updates Jens Axboe
  4 siblings, 1 reply; 7+ messages in thread
From: Dylan Yudaken @ 2022-07-21 14:42 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken, Ammar Faizi

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

Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 test/poll-mshot-overflow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/poll-mshot-overflow.c b/test/poll-mshot-overflow.c
index 17039f585a77..360df65d2b15 100644
--- a/test/poll-mshot-overflow.c
+++ b/test/poll-mshot-overflow.c
@@ -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) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels
  2022-07-21 14:42 ` [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels Dylan Yudaken
@ 2022-07-21 14:57   ` Ammar Faizi
  0 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-07-21 14:57 UTC (permalink / raw)
  To: Dylan Yudaken, Jens Axboe, Pavel Begunkov
  Cc: Facebook Kernel Team, io-uring Mailing List

On 7/21/22 9:42 PM, Dylan Yudaken wrote:
> Older kernels have slightly different behaviour, so rather skip the test
> on them.
> 
> Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> Signed-off-by: Dylan Yudaken <dylany@fb.com>

Tested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Thanks!

-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 0/4] tests updates
  2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
                   ` (3 preceding siblings ...)
  2022-07-21 14:42 ` [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels Dylan Yudaken
@ 2022-07-21 15:26 ` Jens Axboe
  4 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2022-07-21 15:26 UTC (permalink / raw)
  To: dylany, asml.silence; +Cc: Kernel-team, io-uring

On Thu, 21 Jul 2022 07:42:25 -0700, Dylan Yudaken wrote:
> 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,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-21 15:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 14:42 [PATCH liburing 0/4] tests updates Dylan Yudaken
2022-07-21 14:42 ` [PATCH liburing 1/4] add a test for bad buf_ring register Dylan Yudaken
2022-07-21 14:42 ` [PATCH liburing 2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h Dylan Yudaken
2022-07-21 14:42 ` [PATCH liburing 3/4] test: poll-mshot-overflow use proper return codes Dylan Yudaken
2022-07-21 14:42 ` [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels Dylan Yudaken
2022-07-21 14:57   ` Ammar Faizi
2022-07-21 15:26 ` [PATCH liburing 0/4] tests updates Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.