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]
Message-Id: <1294837325-26187-7-git-send-email-max@vozeler.com>
Date:	Wed, 12 Jan 2011 15:02:04 +0200
From:	Max Vozeler <max@...eler.com>
To:	gregkh@...e.de
Cc:	hirofuchi@...rs.sourceforge.net, rpjday@...shcourse.ca,
	bgmerrell@...ell.com, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org, mwehby@...otticaRetail.com,
	marco@...ikam.com, Max Vozeler <max@...eler.com>
Subject: [PATCH 6/7] staging: usbip: vhci: handle EAGAIN from SO_RCVTIMEO

If there is a receive timeout without any active
requests, we can tell the connection was idle and
ignore the timeout.

If there are active requests for which we expect
to receive a reply we close the connection.

This makes it possible to set an upper bound on
the time a usbip device may be unresponsive.

This is a workaround for the lack of heart-beat
messages in the USBIP protocol.

Extending the protocol would break compatibility
with all previous stub versions, so this seems like
the lesser evil.

Signed-off-by: Max Vozeler <max@...eler.com>
Tested-by: Mark Wehby <MWehby@...otticaRetail.com>
---
 drivers/staging/usbip/vhci_rx.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index ac15cea..bf69914 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -193,6 +193,19 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
 	return;
 }
 
+static int vhci_priv_tx_empty(struct vhci_device *vdev)
+{
+	int empty = 0;
+
+	spin_lock(&vdev->priv_lock);
+
+	empty = list_empty(&vdev->priv_rx);
+
+	spin_unlock(&vdev->priv_lock);
+
+	return empty;
+}
+
 /* recv a pdu */
 static void vhci_rx_pdu(struct usbip_device *ud)
 {
@@ -210,8 +223,14 @@ static void vhci_rx_pdu(struct usbip_device *ud)
 	if (ret < 0) {
 		if (ret == -ECONNRESET)
 			usbip_uinfo("connection reset by peer\n");
-		else if (ret != -ERESTARTSYS)
+		else if (ret == -EAGAIN) {
+			/* ignore if connection was idle */
+			if (vhci_priv_tx_empty(vdev))
+				return;
+			usbip_uinfo("connection timed out with pending urbs\n");
+		} else if (ret != -ERESTARTSYS)
 			usbip_uinfo("xmit failed %d\n", ret);
+
 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
 		return;
 	}
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ