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:   Thu,  1 Aug 2019 17:25:40 +0200
From:   Stefano Garzarella <sgarzare@...hat.com>
To:     netdev@...r.kernel.org
Cc:     kvm@...r.kernel.org, Stefan Hajnoczi <stefanha@...hat.com>,
        Dexuan Cui <decui@...rosoft.com>,
        virtualization@...ts.linux-foundation.org,
        "David S. Miller" <davem@...emloft.net>,
        Jorgen Hansen <jhansen@...are.com>,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2 10/11] vsock_test: skip read() in test_stream*close tests on a VMCI host

When VMCI transport is used, if the guest closes a connection,
all data is gone and EOF is returned, so we should skip the read
of data written by the peer before closing the connection.

Reported-by: Jorgen Hansen <jhansen@...are.com>
Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>
---
 tools/testing/vsock/vsock_test.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index cb606091489f..64adf45501ca 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -71,6 +71,7 @@ static void test_stream_client_close_client(const struct test_opts *opts)
 
 static void test_stream_client_close_server(const struct test_opts *opts)
 {
+	unsigned int local_cid;
 	int fd;
 
 	fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
@@ -79,16 +80,27 @@ static void test_stream_client_close_server(const struct test_opts *opts)
 		exit(EXIT_FAILURE);
 	}
 
+	local_cid = vsock_get_local_cid(fd);
+
 	control_expectln("CLOSED");
 
 	send_byte(fd, -EPIPE);
-	recv_byte(fd, 1);
+
+	/* Skip the read of data wrote by the peer if we are on VMCI and
+	 * we are on the host side, because when the guest closes a
+	 * connection, all data is gone and EOF is returned.
+	 */
+	if (!(opts->transport == TEST_TRANSPORT_VMCI &&
+	    local_cid == VMADDR_CID_HOST))
+		recv_byte(fd, 1);
+
 	recv_byte(fd, 0);
 	close(fd);
 }
 
 static void test_stream_server_close_client(const struct test_opts *opts)
 {
+	unsigned int local_cid;
 	int fd;
 
 	fd = vsock_stream_connect(opts->peer_cid, 1234);
@@ -97,10 +109,20 @@ static void test_stream_server_close_client(const struct test_opts *opts)
 		exit(EXIT_FAILURE);
 	}
 
+	local_cid = vsock_get_local_cid(fd);
+
 	control_expectln("CLOSED");
 
 	send_byte(fd, -EPIPE);
-	recv_byte(fd, 1);
+
+	/* Skip the read of data wrote by the peer if we are on VMCI and
+	 * we are on the host side, because when the guest closes a
+	 * connection, all data is gone and EOF is returned.
+	 */
+	if (!(opts->transport == TEST_TRANSPORT_VMCI &&
+	    local_cid == VMADDR_CID_HOST))
+		recv_byte(fd, 1);
+
 	recv_byte(fd, 0);
 	close(fd);
 }
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ