Re: tty_[un]register_devfs putting 3K structures on the stack

From: Jeff Dike (jdike@karaya.com)
Date: Tue Oct 17 2000 - 00:08:08 EST


tytso@mit.edu said:
> If the problem only impacts User-mode Linux, it's hard for me to justify
> hanging the "critical" label on it. However I'm willing to look at the
> patch, bless it, and send it on to Linus

Below is the patch to rid tty_register_devfs and tty_unregister_devfs of the
tty_struct local.

I still think that treating it as critical deserves consideration because it's
a potentially nasty problem, and one that could be tough to debug. As Alan
pointed out, it's easier to fix the bug than it is to prove that it can't
happen on any of the other arches.

                                Jeff

diff -u drivers/char/tty_io.c.orig drivers/char/tty_io.c
--- drivers/char/tty_io.c.orig Tue Oct 17 00:06:04 2000
+++ drivers/char/tty_io.c Tue Oct 17 00:05:37 2000
@@ -1994,12 +1994,11 @@
 {
 #ifdef CONFIG_DEVFS_FS
        umode_t mode = S_IFCHR | S_IRUSR | S_IWUSR;
- struct tty_struct tty;
+ kdev_t device = MKDEV (driver->major, minor);
+ int idx = minor - driver->minor_start;
        char buf[32];
 
- tty.driver = *driver;
- tty.device = MKDEV (driver->major, minor);
- switch (tty.device) {
+ switch (device) {
                case TTY_DEV:
                case PTMX_DEV:
                        mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
@@ -2020,23 +2019,21 @@
             (driver->major < UNIX98_PTY_SLAVE_MAJOR + UNIX98_NR_MAJORS) )
                flags |= DEVFS_FL_CURRENT_OWNER;
 # endif
- devfs_register (NULL, tty_name (&tty, buf), flags | DEVFS_FL_DEFAULT,
+ sprintf(buf, driver->name, idx + driver->name_base);
+ devfs_register (NULL, buf, flags | DEVFS_FL_DEFAULT,
                        driver->major, minor, mode, &tty_fops, NULL);
 #endif /* CONFIG_DEVFS_FS */
 }
 
-void tty_unregister_devfs (struct tty_driver *driver, unsigned minor)
+void tty_unregister_devfs (struct tty_driver *driver, unsigned int minor)
 {
 #ifdef CONFIG_DEVFS_FS
        void * handle;
- struct tty_struct tty;
+ int idx = minor - driver->minor_start;
        char buf[32];
 
- tty.driver = *driver;
- tty.device = MKDEV(driver->major, minor);
-
- handle = devfs_find_handle (NULL, tty_name (&tty, buf),
- driver->major, minor,
+ sprintf(buf, driver->name, idx + driver->name_base);
+ handle = devfs_find_handle (NULL, buf, driver->major, minor,
                                    DEVFS_SPECIAL_CHR, 0);
        devfs_unregister (handle);
 #endif /* CONFIG_DEVFS_FS */

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



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:10 EST