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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1c3b277135e8f98dacc2a6ce582a48ae4d64780f.1589714504.git.asml.silence@gmail.com>
Date:   Sun, 17 May 2020 14:23:47 +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 liburing 4/4] splice/tee/tests: test len=0 splice/tee

Check zero-length splice() and tee().

Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---
 test/splice.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/test/splice.c b/test/splice.c
index 119c493..b81aa4b 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -144,7 +144,7 @@ static int do_splice_op(struct io_uring *ring,
 	struct io_uring_sqe *sqe;
 	int ret = -1;
 
-	while (len) {
+	do {
 		sqe = io_uring_get_sqe(ring);
 		if (!sqe) {
 			fprintf(stderr, "get sqe failed\n");
@@ -179,7 +179,7 @@ static int do_splice_op(struct io_uring *ring,
 		if (off_out != -1)
 			off_out += cqe->res;
 		io_uring_cqe_seen(ring, cqe);
-	}
+	} while (len);
 
 	return 0;
 }
@@ -215,6 +215,21 @@ static void check_tee_support(struct io_uring *ring, struct test_ctx *ctx)
 	has_tee = (ret == -EBADF);
 }
 
+static int check_zero_splice(struct io_uring *ring, struct test_ctx *ctx)
+{
+	int ret;
+
+	ret = do_splice(ring, ctx->fd_in, -1, ctx->pipe1[1], -1, 0);
+	if (ret)
+		return ret;
+
+	ret = do_splice(ring, ctx->pipe2[0], -1, ctx->pipe1[1], -1, 0);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int splice_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
 {
 	int ret;
@@ -349,11 +364,23 @@ static int check_tee(struct io_uring *ring, struct test_ctx *ctx)
 	return 0;
 }
 
+static int check_zero_tee(struct io_uring *ring, struct test_ctx *ctx)
+{
+	return do_tee(ring, ctx->pipe2[0], ctx->pipe1[1], 0);
+}
+
 static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
 {
 	int ret;
 
 	if (has_splice) {
+		ret = check_zero_splice(ring, ctx);
+		if (ret) {
+			fprintf(stderr, "check_zero_splice failed %i %i\n",
+				ret, errno);
+			return ret;
+		}
+
 		ret = splice_to_pipe(ring, ctx);
 		if (ret) {
 			fprintf(stderr, "splice_to_pipe failed %i %i\n",
@@ -384,6 +411,13 @@ static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
 	}
 
 	if (has_tee) {
+		ret = check_zero_tee(ring, ctx);
+		if (ret) {
+			fprintf(stderr, "check_zero_tee() failed %i %i\n",
+				ret, errno);
+			return ret;
+		}
+
 		ret = fail_tee_nonpipe(ring, ctx);
 		if (ret) {
 			fprintf(stderr, "fail_tee_nonpipe() failed %i %i\n",
-- 
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ