public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support compat_ioctl get/set termios_locked
@ 2011-04-30 14:18 Thomas Meyer
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Meyer @ 2011-04-30 14:18 UTC (permalink / raw)
  To: linux-kernel

plymouth complains about those two missing ioctls.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 drivers/tty/n_tty.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 428f4fe..8d1073f 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -40,6 +40,7 @@
 #include <linux/tty.h>
 #include <linux/timer.h>
 #include <linux/ctype.h>
+#include <linux/compat.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/slab.h>
@@ -2088,6 +2089,20 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
 	}
 }
 
+#ifdef CONFIG_COMPAT
+static long n_tty_compat_ioctl(struct tty_struct *tty, struct file *file,
+		              unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case TIOCGLCKTRMIOS:
+	case TIOCSLCKTRMIOS:
+		return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+#endif
+
 struct tty_ldisc_ops tty_ldisc_N_TTY = {
 	.magic           = TTY_LDISC_MAGIC,
 	.name            = "n_tty",
@@ -2098,6 +2113,9 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
 	.read            = n_tty_read,
 	.write           = n_tty_write,
 	.ioctl           = n_tty_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl    = n_tty_compat_ioctl,
+#endif
 	.set_termios     = n_tty_set_termios,
 	.poll            = n_tty_poll,
 	.receive_buf     = n_tty_receive_buf,
-- 
1.7.4.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Support compat_ioctl get/set termios_locked
@ 2011-09-24  8:51 Thomas Meyer
  2011-09-25 11:11 ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Meyer @ 2011-09-24  8:51 UTC (permalink / raw)
  To: gregkh; +Cc: Linux Kernel Mailing List

When running a Fedora 15 (x86) on an x86_64 kernel, in the boot process
plymouthd complains about those two missing ioctls:
[    2.581783] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005457){t:'T';sz:0} arg(ffb6a5d0) on /dev/tty1
[    2.581803] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005456){t:'T';sz:0} arg(ffb6a680) on /dev/tty1

both ioctl functions work on the 'struct termios', which has the same
size (36 bytes) on x86 and x86_64, so it's just a matter of converting the
pointer from userland.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 drivers/tty/n_tty.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 39d6ab6..24843da 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -40,6 +40,7 @@
 #include <linux/tty.h>
 #include <linux/timer.h>
 #include <linux/ctype.h>
+#include <linux/compat.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/slab.h>
@@ -2095,6 +2096,20 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
 	}
 }
 
+#ifdef CONFIG_COMPAT
+static long n_tty_compat_ioctl(struct tty_struct *tty, struct file *file,
+		              unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case TIOCGLCKTRMIOS:
+	case TIOCSLCKTRMIOS:
+		return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+#endif
+
 struct tty_ldisc_ops tty_ldisc_N_TTY = {
 	.magic           = TTY_LDISC_MAGIC,
 	.name            = "n_tty",
@@ -2105,6 +2120,9 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
 	.read            = n_tty_read,
 	.write           = n_tty_write,
 	.ioctl           = n_tty_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl    = n_tty_compat_ioctl,
+#endif
 	.set_termios     = n_tty_set_termios,
 	.poll            = n_tty_poll,
 	.receive_buf     = n_tty_receive_buf,
-- 
1.7.6.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Support compat_ioctl get/set termios_locked
  2011-09-24  8:51 [PATCH] Support compat_ioctl get/set termios_locked Thomas Meyer
@ 2011-09-25 11:11 ` Arnd Bergmann
  2011-09-28 17:37   ` Thomas Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2011-09-25 11:11 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: gregkh, Linux Kernel Mailing List

On Saturday 24 September 2011 10:51:24 Thomas Meyer wrote:
> When running a Fedora 15 (x86) on an x86_64 kernel, in the boot process
> plymouthd complains about those two missing ioctls:
> [    2.581783] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005457){t:'T';sz:0} arg(ffb6a5d0) on /dev/tty1
> [    2.581803] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005456){t:'T';sz:0} arg(ffb6a680) on /dev/tty1
> 
> both ioctl functions work on the 'struct termios', which has the same
> size (36 bytes) on x86 and x86_64, so it's just a matter of converting the
> pointer from userland.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Hi Thomas,

This looks ok for n_tty, but the same commands are supported for some
(all?) other tty line disciplines as well, and they remain broken
after your patch.

I think it would be better to handle this in the common tty_compat_ioctl()
function before calling into the line discipline's compat_ioctl function.

It would also be nice to move similar commands from fs/compat_ioctl.c into
the same place. The easiest solution would be to add the two missing command
in fs/compat_ioctl.c, but I would prefer getting stuff out of there instead.

	Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Support compat_ioctl get/set termios_locked
  2011-09-25 11:11 ` Arnd Bergmann
@ 2011-09-28 17:37   ` Thomas Meyer
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Meyer @ 2011-09-28 17:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: gregkh, Linux Kernel Mailing List

Am Sonntag, den 25.09.2011, 13:11 +0200 schrieb Arnd Bergmann:
> Hi Thomas,
> 
> This looks ok for n_tty, but the same commands are supported for some
> (all?) other tty line disciplines as well, and they remain broken
> after your patch.
> 
> I think it would be better to handle this in the common tty_compat_ioctl()
> function before calling into the line discipline's compat_ioctl function.
> 

>From a91ed2e890a61a1fa382b6434a3c95774bd1d3da Mon Sep 17 00:00:00 2001
From: Thomas Meyer <thomas@m3y3r.de>
Date: Sat, 24 Sep 2011 10:36:39 +0200
Subject: [PATCH] Support compat_ioctl get/set termios_locked

When running a Fedora 15 (x86) on an x86_64 kernel, in the boot process
plymouthd complains about those two missing ioctls:
[    2.581783] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005457){t:'T';sz:0} arg(ffb6a5d0) on /dev/tty1
[    2.581803] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005456){t:'T';sz:0} arg(ffb6a680) on /dev/tty1

both ioctl functions work on the 'struct termios' resp. 'struct termios2',
which has the same size (36 bytes resp. 44 bytes) on x86 and x86_64,
so it's just a matter of converting the pointer from userland.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 drivers/tty/tty_io.c    |    3 +++
 drivers/tty/tty_ioctl.c |   17 +++++++++++++++++
 include/linux/tty.h     |    2 ++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 4f1fc81..983f29a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2716,6 +2716,9 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
 	ld = tty_ldisc_ref_wait(tty);
 	if (ld->ops->compat_ioctl)
 		retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
+	else
+		n_tty_compat_ioctl_helper(tty, file, cmd, arg);
+
 	tty_ldisc_deref(ld);
 
 	return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 53f2442..9314d93 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/mutex.h>
+#include <linux/compat.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -1179,3 +1180,19 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 	}
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
+
+#ifdef CONFIG_COMPAT
+long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
+					unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case TIOCGLCKTRMIOS:
+	case TIOCSLCKTRMIOS:
+		return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
+#endif
+
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 5f2ede8..ddac668 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -581,6 +581,8 @@ extern int __init tty_init(void);
 /* tty_ioctl.c */
 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 		       unsigned int cmd, unsigned long arg);
+extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
+		       unsigned int cmd, unsigned long arg);
 
 /* serial.c */
 
-- 
1.7.6.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Support compat_ioctl get/set termios_locked
@ 2011-10-05 21:13 Thomas Meyer
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Meyer @ 2011-10-05 21:13 UTC (permalink / raw)
  To: gregkh, Linux Kernel Mailing List

>From 3a8e16c473be2e44b063a7a9072b16ce6fa13353 Mon Sep 17 00:00:00 2001
From: Thomas Meyer <thomas@m3y3r.de>
Date: Sat, 24 Sep 2011 10:36:39 +0200
Subject: [PATCH] Support compat_ioctl get/set termios_locked

When running a Fedora 15 (x86) on an x86_64 kernel, in the boot process
plymouthd complains about those two missing ioctls:
[    2.581783] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005457){t:'T';sz:0} arg(ffb6a5d0) on /dev/tty1
[    2.581803] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005456){t:'T';sz:0} arg(ffb6a680) on /dev/tty1

both ioctl functions work on the 'struct termios' resp. 'struct termios2',
which has the same size (36 bytes resp. 44 bytes) on x86 and x86_64,
so it's just a matter of converting the pointer from userland.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
Sorry, I did forget to set the retval from n_tty_compat_ioctl_helper().

 drivers/tty/tty_io.c    |    2 ++
 drivers/tty/tty_ioctl.c |   17 +++++++++++++++++
 include/linux/tty.h     |    2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 4f1fc81..e68c6303 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2716,6 +2716,8 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
 	ld = tty_ldisc_ref_wait(tty);
 	if (ld->ops->compat_ioctl)
 		retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
+	else
+		retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg);
 	tty_ldisc_deref(ld);
 
 	return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 53f2442..9314d93 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/mutex.h>
+#include <linux/compat.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -1179,3 +1180,19 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 	}
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
+
+#ifdef CONFIG_COMPAT
+long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
+					unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case TIOCGLCKTRMIOS:
+	case TIOCSLCKTRMIOS:
+		return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
+#endif
+
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 5f2ede8..ddac668 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -581,6 +581,8 @@ extern int __init tty_init(void);
 /* tty_ioctl.c */
 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 		       unsigned int cmd, unsigned long arg);
+extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
+		       unsigned int cmd, unsigned long arg);
 
 /* serial.c */
 
-- 
1.7.6.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-05 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-24  8:51 [PATCH] Support compat_ioctl get/set termios_locked Thomas Meyer
2011-09-25 11:11 ` Arnd Bergmann
2011-09-28 17:37   ` Thomas Meyer
  -- strict thread matches above, loose matches on Subject: below --
2011-10-05 21:13 Thomas Meyer
2011-04-30 14:18 Thomas Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox