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]
Date:	Tue, 12 May 2009 17:32:20 -0500
From:	Jason Wessel <jason.wessel@...driver.com>
To:	greg@...ah.com
Cc:	linux-usb@...r.kernel.org, oliver@...kum.org,
	stern@...land.harvard.edu, linux-kernel@...r.kernel.org,
	Jason Wessel <jason.wessel@...driver.com>
Subject: [PATCH 2/2] usb_serial: Run the sysrq handler in a tasklet

If a sysrq is processed on the while holding the usb hcd lock, it is
impossible to drain the queue of urbs via the polling interface and
all the printk output is lost.

Using a tasklet to schedule the sysrq allows the hcd device lock to
free up.

Signed-off-by: Jason Wessel <jason.wessel@...driver.com>
---
 drivers/usb/serial/generic.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index df56ed3..7554d71 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -527,11 +527,42 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
 	}
 }
 
+#ifdef CONFIG_MAGIC_SYSRQ
+/* The sysrq tasklet is used to make the sysrq request not occur with
+ * the hcd device lock held.
+ */
+static struct usb_sysrq_data {
+	struct tty_struct *tty;
+	unsigned int ch;
+	int pending;
+} priv_usb_sysrq;
+
+static void usb_sysrq_task(unsigned long args)
+{
+	handle_sysrq(priv_usb_sysrq.ch, priv_usb_sysrq.tty);
+	priv_usb_sysrq.pending = 0;
+}
+static DECLARE_TASKLET(usb_sysrq_tasklet, usb_sysrq_task, 0);
+
+void usb_serial_generic_sysrq_invoke(struct usb_serial_port *port,
+				     unsigned int ch)
+{
+	if (priv_usb_sysrq.pending)
+		return;
+	priv_usb_sysrq.pending = 1;
+	priv_usb_sysrq.ch = ch;
+	priv_usb_sysrq.tty = tty_port_tty_get(&port->port);
+	tasklet_schedule(&usb_sysrq_tasklet);
+}
+#else
+static void usb_serial_generic_sysrq_invoke() {}
+#endif /* CONFIG_SYSRQ */
+
 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 {
 	if (port->sysrq) {
 		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch, tty_port_tty_get(&port->port));
+			usb_serial_generic_sysrq_invoke(port, ch);
 			port->sysrq = 0;
 			return 1;
 		}
-- 
1.6.3.9.g6345d

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