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: <1227911282-8857-1-git-send-email-keithp@keithp.com>
Date:	Fri, 28 Nov 2008 14:28:02 -0800
From:	Keith Packard <keithp@...thp.com>
To:	linux-kernel@...r.kernel.org
Cc:	Greg Kroah-Hartman <gregkh@...e.de>,
	Keith Packard <keithp@...thp.com>
Subject: [PATCH] usb/serial: Add compat_ioctl pass-through

USB serial devices with extended IOCTLs cannot be used in a 64-bit kernel
from 32-bit user space as the compat_ioctl path is missing. This adds a
pass-through so that drivers may offer this functionality. This requires
that all drivers actually implement a compat_ioctl function if they want to
support this operation.

Signed-off-by: Keith Packard <keithp@...thp.com>
---
 drivers/usb/serial/usb-serial.c |   20 ++++++++++++++++++++
 include/linux/usb/serial.h      |    4 ++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 794b5ff..c83a9f0 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -381,6 +381,25 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
 	return retval;
 }
 
+static int serial_compat_ioctl(struct tty_struct *tty, struct file *file,
+			       unsigned int cmd, unsigned long arg)
+{
+	struct usb_serial_port *port = tty->driver_data;
+	int retval = -ENODEV;
+
+	dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
+
+	WARN_ON(!port->port.count);
+
+	/* pass on to the driver specific version of this function
+	   if it is available */
+	if (port->serial->type->compat_ioctl) {
+		retval = port->serial->type->compat_ioctl(tty, file, cmd, arg);
+	} else
+		retval = -ENOIOCTLCMD;
+	return retval;
+}
+
 static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
 	struct usb_serial_port *port = tty->driver_data;
@@ -1095,6 +1114,7 @@ static const struct tty_operations serial_ops = {
 	.write =		serial_write,
 	.write_room =		serial_write_room,
 	.ioctl =		serial_ioctl,
+	.compat_ioctl =		serial_compat_ioctl,
 	.set_termios =		serial_set_termios,
 	.throttle =		serial_throttle,
 	.unthrottle =		serial_unthrottle,
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 0b8617a..02c4080 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -226,8 +226,12 @@ struct usb_serial_driver {
 			const unsigned char *buf, int count);
 	/* Called only by the tty layer */
 	int  (*write_room)(struct tty_struct *tty);
+	/* Called with bkl held */
 	int  (*ioctl)(struct tty_struct *tty, struct file *file,
 		      unsigned int cmd, unsigned long arg);
+	/* Called without bkl held */
+	int  (*compat_ioctl)(struct tty_struct *tty, struct file *file,
+			     unsigned int cmd, unsigned long arg);
 	void (*set_termios)(struct tty_struct *tty,
 			struct usb_serial_port *port, struct ktermios *old);
 	void (*break_ctl)(struct tty_struct *tty, int break_state);
-- 
1.5.6.5

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