Update of /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30292/ruby-2.6/drivers/char Modified Files: Kconfig Makefile consolemap.c selection.c sysrq.c tty_io.c vc_screen.c vt.c vt_ioctl.c vt_proc.c Log Message: sync to 2.6.7 Index: Kconfig =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/Kconfig,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Kconfig 25 May 2004 05:26:48 -0000 1.8 +++ Kconfig 17 Jun 2004 10:44:52 -0000 1.9 @@ -119,15 +119,13 @@ tristate "Cyclades async mux support" depends on SERIAL_NONSTANDARD ---help--- - This is a driver for a card that gives you many serial ports. You - would need something like this to connect more than two modems to + This driver supports Cyclades Z and Y multiserial boards. + You would need something like this to connect more than two modems to your Linux box, for instance in order to become a dial-in server. + For information about the Cyclades-Z card, read <file:drivers/char/README.cycladesZ>. - As of 1.3.9x kernels, this driver's minor numbers start at 0 instead - of 32. - To compile this driver as a module, choose M here: the module will be called cyclades. Index: Makefile =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile 23 Apr 2004 07:36:55 -0000 1.9 +++ Makefile 17 Jun 2004 10:44:52 -0000 1.10 @@ -39,7 +39,6 @@ obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o obj-$(CONFIG_SX) += sx.o generic_serial.o obj-$(CONFIG_RIO) += rio/ generic_serial.o -obj-$(CONFIG_SH_SCI) += sh-sci.o generic_serial.o obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o obj-$(CONFIG_RAW_DRIVER) += raw.o obj-$(CONFIG_SGI_L1_SERIAL) += sn_serial.o @@ -70,7 +69,6 @@ obj-$(CONFIG_FTAPE) += ftape/ obj-$(CONFIG_H8) += h8.o obj-$(CONFIG_PPDEV) += ppdev.o -obj-$(CONFIG_DZ) += dz.o obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWFLASH) += nwflash.o obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o Index: consolemap.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/consolemap.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- consolemap.c 23 Dec 2003 07:44:02 -0000 1.4 +++ consolemap.c 17 Jun 2004 10:44:52 -0000 1.5 @@ -255,12 +255,12 @@ * 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set * Unicodes explicitly. */ -int con_set_trans_old(struct vc_data *vc, unsigned char * arg) +int con_set_trans_old(struct vc_data *vc, unsigned char __user * arg) { int i; unsigned short *p = translations[USER_MAP]; - i = verify_area(VERIFY_READ, (void *)arg, E_TABSZ); + i = verify_area(VERIFY_READ, arg, E_TABSZ); if (i) return i; @@ -274,12 +274,12 @@ return 0; } -int con_get_trans_old(struct vc_data *vc, unsigned char * arg) +int con_get_trans_old(struct vc_data *vc, unsigned char __user * arg) { int i, ch; unsigned short *p = translations[USER_MAP]; - i = verify_area(VERIFY_WRITE, (void *)arg, E_TABSZ); + i = verify_area(VERIFY_WRITE, arg, E_TABSZ); if (i) return i; @@ -291,13 +291,12 @@ return 0; } -int con_set_trans_new(struct vc_data *vc, ushort * arg) +int con_set_trans_new(struct vc_data *vc, ushort __user * arg) { int i; unsigned short *p = translations[USER_MAP]; - i = verify_area(VERIFY_READ, (void *)arg, - E_TABSZ*sizeof(unsigned short)); + i = verify_area(VERIFY_READ, arg, E_TABSZ*sizeof(unsigned short)); if (i) return i; @@ -311,13 +310,12 @@ return 0; } -int con_get_trans_new(struct vc_data *vc, ushort * arg) +int con_get_trans_new(struct vc_data *vc, ushort __user * arg) { int i; unsigned short *p = translations[USER_MAP]; - i = verify_area(VERIFY_WRITE, (void *)arg, - E_TABSZ*sizeof(unsigned short)); + i = verify_area(VERIFY_WRITE, arg, E_TABSZ*sizeof(unsigned short)); if (i) return i; @@ -468,7 +466,7 @@ } int -con_set_unimap(struct vc_data *vc, ushort ct, struct unipair *list) +con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) { struct uni_pagedir *p, *q; int err = 0, err1, i; @@ -571,6 +569,7 @@ dflt = p; return err; } +EXPORT_SYMBOL(con_set_default_unimap); int con_copy_unimap(struct vc_data *dst, struct vc_data *src) @@ -589,7 +588,7 @@ } int -con_get_unimap(struct vc_data *vc, ushort ct, ushort *uct, struct unipair *list) +con_get_unimap(struct vc_data *vc, ushort ct, ushort *uct, struct unipair __user *list) { int i, j, k, ect; u16 **p1, *p2; Index: selection.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/selection.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- selection.c 25 May 2004 05:26:48 -0000 1.4 +++ selection.c 17 Jun 2004 10:44:52 -0000 1.5 @@ -3,10 +3,10 @@ * * This module exports the functions: * - * 'int set_selection(const unsigned long arg)' + * 'int set_selection(struct tiocl_selection __user *, struct tty_struct *)' * 'void clear_selection(void)' - * 'int paste_selection(struct tty_struct *tty)' - * 'int sel_loadlut(const unsigned long arg)' + * 'int paste_selection(struct tty_struct *)' + * 'int sel_loadlut(char __user *)' * * Now that /dev/vcs exists, most of this can disappear again. */ @@ -105,9 +105,9 @@ } /* set inwordLut contents. Invoked by ioctl(). */ -int sel_loadlut(const unsigned long arg) +int sel_loadlut(char __user *p) { - return copy_from_user(inwordLut, (u32 *)(arg+4), 32) ? -EFAULT : 0; + return copy_from_user(inwordLut, (u32 __user *)(p+4), 32) ? -EFAULT : 0; } /* does screen address p correspond to character at LH/RH edge of screen? */ @@ -123,7 +123,7 @@ } /* set the current selection. Invoked by ioctl() or by kernel code. */ -int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int user) +int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty) { struct vc_data *vc = (struct vc_data *) tty->driver_data; int sel_mode, new_sel_start, new_sel_end, spc; @@ -134,21 +134,13 @@ { unsigned short xs, ys, xe, ye; - if (user) { - if (verify_area(VERIFY_READ, sel, sizeof(*sel))) - return -EFAULT; - __get_user(xs, &sel->xs); - __get_user(ys, &sel->ys); - __get_user(xe, &sel->xe); - __get_user(ye, &sel->ye); - __get_user(sel_mode, &sel->sel_mode); - } else { - xs = sel->xs; /* set selection from kernel */ - ys = sel->ys; - xe = sel->xe; - ye = sel->ye; - sel_mode = sel->sel_mode; - } + if (verify_area(VERIFY_READ, sel, sizeof(*sel))) + return -EFAULT; + __get_user(xs, &sel->xs); + __get_user(ys, &sel->ys); + __get_user(xe, &sel->xe); + __get_user(ye, &sel->ye); + __get_user(sel_mode, &sel->sel_mode); xs--; ys--; xe--; ye--; xs = limit(xs, vc->vc_cols - 1); ys = limit(ys, vc->vc_rows - 1); Index: sysrq.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/sysrq.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- sysrq.c 9 Feb 2004 07:31:07 -0000 1.4 +++ sysrq.c 17 Jun 2004 10:44:52 -0000 1.5 @@ -313,36 +313,18 @@ } /* - * This function is called by the keyboard handler when SysRq is pressed - * and any other keycode arrives. - */ - -void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) -{ - if (!sysrq_enabled) - return; - - __sysrq_lock_table(); - __handle_sysrq_nolock(key, pt_regs, tty); - __sysrq_unlock_table(); -} - -/* * This is the non-locking version of handle_sysrq * It must/can only be called by sysrq key handlers, * as they are inside of the lock */ -void __handle_sysrq_nolock(int key, struct pt_regs *pt_regs, - struct tty_struct *tty) +void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) { struct sysrq_key_op *op_p; int orig_log_level; int i, j; - - if (!sysrq_enabled) - return; + __sysrq_lock_table(); orig_log_level = console_loglevel; console_loglevel = 7; printk(KERN_INFO "SysRq : "); @@ -364,10 +346,22 @@ printk ("\n"); console_loglevel = orig_log_level; } + __sysrq_unlock_table(); +} + +/* + * This function is called by the keyboard handler when SysRq is pressed + * and any other keycode arrives. + */ + +void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) +{ + if (!sysrq_enabled) + return; + __handle_sysrq(key, pt_regs, tty); } EXPORT_SYMBOL(handle_sysrq); -EXPORT_SYMBOL(__handle_sysrq_nolock); EXPORT_SYMBOL(__sysrq_lock_table); EXPORT_SYMBOL(__sysrq_unlock_table); EXPORT_SYMBOL(__sysrq_get_key_op); Index: tty_io.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/tty_io.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- tty_io.c 25 May 2004 05:26:48 -0000 1.10 +++ tty_io.c 17 Jun 2004 10:44:52 -0000 1.11 @@ -134,9 +134,9 @@ static void initialize_tty_struct(struct tty_struct *tty); -static ssize_t tty_read(struct file *, char *, size_t, loff_t *); -static ssize_t tty_write(struct file *, const char *, size_t, loff_t *); -ssize_t redirected_tty_write(struct file *, const char *, size_t, loff_t *); +static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); +static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); +ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *); static unsigned int tty_poll(struct file *, poll_table *); static int tty_open(struct inode *, struct file *); static int tty_release(struct inode *, struct file *); @@ -339,7 +339,7 @@ EXPORT_SYMBOL(tty_check_change); -static ssize_t hung_up_tty_read(struct file * file, char * buf, +static ssize_t hung_up_tty_read(struct file * file, char __user * buf, size_t count, loff_t *ppos) { /* Can't seek (pread) on ttys. */ @@ -348,7 +348,7 @@ return 0; } -static ssize_t hung_up_tty_write(struct file * file, const char * buf, +static ssize_t hung_up_tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) { /* Can't seek (pwrite) on ttys. */ @@ -638,7 +638,7 @@ EXPORT_SYMBOL(start_tty); -static ssize_t tty_read(struct file * file, char * buf, size_t count, +static ssize_t tty_read(struct file * file, char __user * buf, size_t count, loff_t *ppos) { int i; @@ -672,10 +672,10 @@ * denial-of-service type attacks */ static inline ssize_t do_tty_write( - ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t), + ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char __user *, size_t), struct tty_struct *tty, struct file *file, - const unsigned char *buf, + const unsigned char __user *buf, size_t count) { ssize_t ret = 0, written = 0; @@ -717,7 +717,7 @@ } -static ssize_t tty_write(struct file * file, const char * buf, size_t count, +static ssize_t tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) { struct tty_struct * tty; @@ -735,10 +735,10 @@ if (!tty->ldisc.write) return -EIO; return do_tty_write(tty->ldisc.write, tty, file, - (const unsigned char *)buf, count); + (const unsigned char __user *)buf, count); } -ssize_t redirected_tty_write(struct file * file, const char * buf, size_t count, +ssize_t redirected_tty_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) { struct file *p = NULL; @@ -1267,6 +1267,18 @@ #endif /* + * Prevent flush_to_ldisc() from rescheduling the work for later. Then + * kill any delayed work. + */ + clear_bit(TTY_DONT_FLIP, &tty->flags); + cancel_delayed_work(&tty->flip.work); + + /* + * Wait for ->hangup_work and ->flip.work handlers to terminate + */ + flush_scheduled_work(); + + /* * Shutdown the current line discipline, and reset it to N_TTY. * N.B. why reset ldisc when we're releasing the memory?? */ @@ -1282,18 +1294,6 @@ module_put(o_tty->ldisc.owner); o_tty->ldisc = ldiscs[N_TTY]; } - - /* - * Prevent flush_to_ldisc() from rescheduling the work for later. Then - * kill any delayed work. - */ - clear_bit(TTY_DONT_FLIP, &tty->flags); - cancel_delayed_work(&tty->flip.work); - - /* - * Wait for ->hangup_work and ->flip.work handlers to terminate - */ - flush_scheduled_work(); /* * The release_mem function takes care of the details of clearing @@ -1499,19 +1499,19 @@ return 0; } -static int tiocsti(struct tty_struct *tty, char * arg) +static int tiocsti(struct tty_struct *tty, char __user *p) { char ch, mbz = 0; if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) return -EPERM; - if (get_user(ch, arg)) + if (get_user(ch, p)) return -EFAULT; tty->ldisc.receive_buf(tty, &ch, &mbz, 1); return 0; } -static int tiocgwinsz(struct tty_struct *tty, struct winsize * arg) +static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) { if (copy_to_user(arg, &tty->winsize, sizeof(*arg))) return -EFAULT; @@ -1519,7 +1519,7 @@ } static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, - struct winsize * arg) + struct winsize __user * arg) { struct winsize tmp_ws; @@ -1576,11 +1576,11 @@ } -static int fionbio(struct file *file, int *arg) +static int fionbio(struct file *file, int __user *p) { int nonblock; - if (get_user(nonblock, arg)) + if (get_user(nonblock, p)) return -EFAULT; if (nonblock) @@ -1631,7 +1631,7 @@ return 0; } -static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t *arg) +static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) { /* * (tty == real_tty) is a cheap way of @@ -1639,10 +1639,10 @@ */ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY; - return put_user(real_tty->pgrp, arg); + return put_user(real_tty->pgrp, p); } -static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t *arg) +static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) { pid_t pgrp; int retval = tty_check_change(real_tty); @@ -1655,7 +1655,7 @@ (current->signal->tty != real_tty) || (real_tty->session != current->signal->session)) return -ENOTTY; - if (get_user(pgrp, (pid_t *) arg)) + if (get_user(pgrp, p)) return -EFAULT; if (pgrp < 0) return -EINVAL; @@ -1665,7 +1665,7 @@ return 0; } -static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t *arg) +static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) { /* * (tty == real_tty) is a cheap way of @@ -1675,14 +1675,14 @@ return -ENOTTY; if (real_tty->session <= 0) return -ENOTTY; - return put_user(real_tty->session, arg); + return put_user(real_tty->session, p); } -static int tiocsetd(struct tty_struct *tty, int *arg) +static int tiocsetd(struct tty_struct *tty, int __user *p) { int ldisc; - if (get_user(ldisc, arg)) + if (get_user(ldisc, p)) return -EFAULT; return tty_set_ldisc(tty, ldisc); } @@ -1701,7 +1701,7 @@ } static int -tty_tiocmget(struct tty_struct *tty, struct file *file, unsigned long arg) +tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p) { int retval = -EINVAL; @@ -1709,21 +1709,21 @@ retval = tty->driver->tiocmget(tty, file); if (retval >= 0) - retval = put_user(retval, (int *)arg); + retval = put_user(retval, p); } return retval; } static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd, - unsigned long arg) + unsigned __user *p) { int retval = -EINVAL; if (tty->driver->tiocmset) { unsigned int set, clear, val; - retval = get_user(val, (unsigned int *)arg); + retval = get_user(val, p); if (retval) return retval; @@ -1756,6 +1756,7 @@ unsigned int cmd, unsigned long arg) { struct tty_struct *tty, *real_tty; + void __user *p = (void __user *)arg; int retval; tty = (struct tty_struct *)file->private_data; @@ -1813,15 +1814,15 @@ switch (cmd) { case TIOCSTI: - return tiocsti(tty, (char *)arg); + return tiocsti(tty, p); case TIOCGWINSZ: - return tiocgwinsz(tty, (struct winsize *) arg); + return tiocgwinsz(tty, p); case TIOCSWINSZ: - return tiocswinsz(tty, real_tty, (struct winsize *) arg); + return tiocswinsz(tty, real_tty, p); case TIOCCONS: return real_tty!=tty ? -EINVAL : tioccons(file); case FIONBIO: - return fionbio(file, (int *) arg); + return fionbio(file, p); case TIOCEXCL: set_bit(TTY_EXCLUSIVE, &tty->flags); return 0; @@ -1840,15 +1841,15 @@ case TIOCSCTTY: return tiocsctty(tty, arg); case TIOCGPGRP: - return tiocgpgrp(tty, real_tty, (pid_t *) arg); + return tiocgpgrp(tty, real_tty, p); case TIOCSPGRP: - return tiocspgrp(tty, real_tty, (pid_t *) arg); + return tiocspgrp(tty, real_tty, p); case TIOCGSID: - return tiocgsid(tty, real_tty, (pid_t *) arg); + return tiocgsid(tty, real_tty, p); case TIOCGETD: - return put_user(tty->ldisc.num, (int *) arg); + return put_user(tty->ldisc.num, (int __user *)p); case TIOCSETD: - return tiocsetd(tty, (int *) arg); + return tiocsetd(tty, p); #ifdef CONFIG_VT case TIOCLINUX: return tioclinux(tty, arg); @@ -1876,12 +1877,12 @@ return send_break(tty, arg ? arg*(HZ/10) : HZ/4); case TIOCMGET: - return tty_tiocmget(tty, file, arg); + return tty_tiocmget(tty, file, p); case TIOCMSET: case TIOCMBIC: case TIOCMBIS: - return tty_tiocmset(tty, file, cmd, arg); + return tty_tiocmset(tty, file, cmd, p); } if (tty->driver->ioctl) { int retval = (tty->driver->ioctl)(tty, file, cmd, arg); Index: vc_screen.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/vc_screen.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- vc_screen.c 25 May 2004 05:26:48 -0000 1.5 +++ vc_screen.c 17 Jun 2004 10:44:52 -0000 1.6 @@ -135,7 +135,7 @@ extern struct semaphore con_buf_sem; static ssize_t -vcs_read(struct file *file, char *buf, size_t count, loff_t *ppos) +vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct inode *inode = file->f_dentry->d_inode; unsigned int currcons = iminor(inode); @@ -306,7 +306,7 @@ } static ssize_t -vcs_write(struct file *file, const char *buf, size_t count, loff_t *ppos) +vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct inode *inode = file->f_dentry->d_inode; unsigned int currcons = iminor(inode); Index: vt.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/vt.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- vt.c 25 May 2004 05:26:48 -0000 1.19 +++ vt.c 17 Jun 2004 10:44:52 -0000 1.20 @@ -1114,11 +1114,6 @@ old_row_size = video_size_row; old_screenbuf_size = screenbuf_size; - video_num_lines = new_rows; - video_num_columns = new_cols; - video_size_row = new_row_size; - screenbuf_size = ss; - err = resize_screen(vc, new_cols, new_rows); if (err) { resize_screen(vc, old_cols, old_rows); @@ -1126,6 +1121,11 @@ return err; } + video_num_lines = new_rows; + video_num_columns = new_cols; + video_size_row = new_row_size; + screenbuf_size = ss; + rlth = min(old_row_size, new_row_size); rrem = new_row_size - rlth; ol = origin; @@ -1684,20 +1684,21 @@ { struct vc_data *vc = tty->driver_data; char type, data; + char __user *p = (char __user *)arg; int lines, ret; if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE) return -EINVAL; if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) return -EPERM; - if (get_user(type, (char *)arg)) + if (get_user(type, p)) return -EFAULT; ret = 0; switch (type) { case TIOCL_SETSEL: acquire_console_sem(); - ret = set_selection((struct tiocl_selection *)((char *)arg+1), tty, 1); + ret = set_selection((struct tiocl_selection __user *)(p+1), tty); release_console_sem(); break; case TIOCL_PASTESEL: @@ -1707,7 +1708,7 @@ unblank_screen(); break; case TIOCL_SELLOADLUT: - ret = sel_loadlut(arg); + ret = sel_loadlut(p); break; case TIOCL_GETSHIFTSTATE: @@ -1718,14 +1719,14 @@ * related to the kernel should not use this. */ data = shift_state; - ret = __put_user(data, (char *) arg); + ret = __put_user(data, p); break; case TIOCL_GETMOUSEREPORTING: data = mouse_reporting(vc); - ret = __put_user(data, (char *) arg); + ret = __put_user(data, p); break; case TIOCL_SETVESABLANK: - if (get_user(data, (char *) arg + 1)) + if (get_user(data, p + 1)) return -EFAULT; vc->display_fg->blank_mode = (data < 4) ? data : 0; break; @@ -1733,7 +1734,7 @@ if (!capable(CAP_SYS_ADMIN)) { ret = -EPERM; } else { - if (get_user(data, (char *)arg)) + if (get_user(data, p+1)) ret = -EFAULT; else kmsg_redirect = data; @@ -1743,7 +1744,7 @@ ret = vc->display_fg->fg_console->vc_num; break; case TIOCL_SCROLLCONSOLE: - if (get_user(lines, (s32 *)((char *)arg+4))) { + if (get_user(lines, (s32 __user *)(p+4))) { ret = -EFAULT; } else { scroll_down(vc, lines); @@ -1911,11 +1912,16 @@ * and become default driver for newly opened ones. */ -void take_over_console(struct vt_struct *vt, const struct consw *csw) +int take_over_console(struct vt_struct *vt, const struct consw *csw) { struct vc_data *vc = vt->fg_console; const char *desc; int i; + struct module *owner; + + owner = csw->owner; + if (!try_module_get(owner)) + return -ENODEV; acquire_console_sem(); @@ -1928,13 +1934,18 @@ sw->con_deinit(vc); } + /* under Linux-ruby one reference per console driver */ + module_put(vt->vt_sw->owner); + __module_get(owner); + /* Test new hardware state */ desc = csw->con_startup(vt, 0); if (!desc) { /* Make sure the original driver state is restored to normal */ vt->vt_sw->con_startup(vt, 1); release_console_sem(); - return; + module_put(owner); + return -ENODEV; } vt->vt_sw = csw; vt->display_desc = (char *)desc; @@ -1967,6 +1978,9 @@ vt->first_vc + 1, vt->first_vc + vt->vc_count); release_console_sem(); + + module_put(owner); + return 0; } /* Index: vt_ioctl.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/vt_ioctl.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- vt_ioctl.c 25 May 2004 05:26:48 -0000 1.7 +++ vt_ioctl.c 17 Jun 2004 10:44:52 -0000 1.8 @@ -53,7 +53,7 @@ unsigned char keyboard_type = KB_101; #ifdef CONFIG_X86 -asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on); +#include <linux/syscalls.h> #endif /* @@ -102,7 +102,7 @@ #define s (tmp.kb_table) #define v (tmp.kb_value) static inline int -do_kdsk_ioctl(struct vc_data *vc, int cmd, struct kbentry *user_kbe, int perm) +do_kdsk_ioctl(struct vc_data *vc, int cmd, struct kbentry __user *user_kbe, int perm) { struct kbd_struct *kbd = &vc->kbd_table; ushort *key_map, val, ov; @@ -186,7 +186,7 @@ #undef v static inline int -do_kbkeycode_ioctl(struct vc_data *vc, int cmd, struct kbkeycode *user_kbkc, int perm) +do_kbkeycode_ioctl(struct vc_data *vc, int cmd, struct kbkeycode __user *user_kbkc, int perm) { struct kbkeycode tmp; int kc = 0; @@ -209,12 +209,13 @@ } static inline int -do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm) +do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) { char *first_free, *fj, *fnw, *p; int i, j, k, delta, sz, ret; struct kbsentry *kbs; u_char *q; + u_char __user *up; kbs = kmalloc(sizeof(*kbs), GFP_KERNEL); if (!kbs) { @@ -234,15 +235,15 @@ case KDGKBSENT: /* sz should have been a struct memeber */ sz = sizeof(kbs->kb_string) - 1; - q = user_kdgkb->kb_string; + up = user_kdgkb->kb_string; p = func_table[i]; if (p) for ( ; *p && sz; p++, sz--) - if (put_user(*p, q++)) { + if (put_user(*p, up++)) { ret = -EFAULT; goto reterr; } - if (put_user('\0', q)) { + if (put_user('\0', up)) { ret = -EFAULT; goto reterr; } @@ -344,7 +345,8 @@ goto quit; if (!op->height) {/* Need to guess font height [compat] */ int h, i; - u8 *charmap = op->data, tmp; + u8 __user *charmap = op->data; + u8 tmp; /* If from KDFONTOP ioctl, don't allow things which can be done in userland, @@ -415,7 +417,7 @@ } static inline int -do_fontx_ioctl(struct vc_data *vc, struct console_font_op *op, struct consolefontdesc *user_cfd, int cmd, int perm) +do_fontx_ioctl(struct vc_data *vc, struct console_font_op *op, struct consolefontdesc __user *user_cfd, int cmd, int perm) { struct consolefontdesc cfdarg; int i; @@ -454,7 +456,7 @@ } static inline int -do_unimap_ioctl(struct vc_data *vc, int cmd, struct unimapdesc *user_ud, int perm) +do_unimap_ioctl(struct vc_data *vc, int cmd, struct unimapdesc __user *user_ud, int perm) { struct unimapdesc tmp; int i = 0; @@ -481,7 +483,7 @@ * Load palette into the DAC registers. arg points to a colour * map, 3 bytes per colour, 16 colours, range from 0 to 255. */ -int con_set_cmap(struct vc_data *vc, unsigned char *arg) +int con_set_cmap(struct vc_data *vc, unsigned char __user *arg) { int red[16], green[16], blue[16]; int i, j, k; @@ -506,7 +508,7 @@ return 0; } -int con_get_cmap(struct vc_data *vc, unsigned char *arg) +int con_get_cmap(struct vc_data *vc, unsigned char __user *arg) { int i; @@ -691,6 +693,7 @@ struct vc_data *vc = (struct vc_data *)tty->driver_data; struct console_font_op op; /* used in multiple places */ unsigned char ucval; + void __user *up = (void __user *)arg; int i, perm; if (!vc) /* impossible? */ @@ -771,12 +774,12 @@ if (!capable(CAP_SYS_TTY_CONFIG)) return -EPERM; - if (copy_from_user(&kbrep, (void *)arg, sizeof(struct kbd_repeat))) + if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat))) return -EFAULT; err = kbd_rate(vc->display_fg->keyboard, &kbrep); if (err) return err; - if (copy_to_user((void *)arg,&kbrep, sizeof(struct kbd_repeat))) + if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat))) return -EFAULT; return 0; } @@ -881,25 +884,25 @@ case KDGKBMETA: ucval = (get_kbd_mode(&vc->kbd_table, VC_META) ? K_ESCPREFIX : K_METABIT); setint: - return put_user(ucval, (int *)arg); + return put_user(ucval, (int __user *)arg); case KDGETKEYCODE: case KDSETKEYCODE: if(!capable(CAP_SYS_TTY_CONFIG)) perm=0; - return do_kbkeycode_ioctl(vc, cmd, (struct kbkeycode *)arg, perm); + return do_kbkeycode_ioctl(vc, cmd, up, perm); case KDGKBENT: case KDSKBENT: - return do_kdsk_ioctl(vc, cmd, (struct kbentry *)arg, perm); + return do_kdsk_ioctl(vc, cmd, up, perm); case KDGKBSENT: case KDSKBSENT: - return do_kdgkb_ioctl(cmd, (struct kbsentry *)arg, perm); + return do_kdgkb_ioctl(cmd, up, perm); case KDGKBDIACR: { - struct kbdiacrs *a = (struct kbdiacrs *)arg; + struct kbdiacrs *a = up; if (put_user(accent_table_size, &a->kb_cnt)) return -EFAULT; @@ -910,7 +913,7 @@ case KDSKBDIACR: { - struct kbdiacrs *a = (struct kbdiacrs *)arg; + struct kbdiacrs __user *a = up; unsigned int ct; if (!perm) @@ -946,7 +949,7 @@ case KDGETLED: ucval = getledstate(vc); setchar: - return put_user(ucval, (char*)arg); + return put_user(ucval, (char __user *)arg); case KDSETLED: if (!perm) @@ -959,10 +962,7 @@ * generated by pressing an appropriate key combination. * Thus, one can have a daemon that e.g. spawns a new console * upon a keypress and then changes to it. - * Probably init should be changed to do this (and have a - * field ks (`keyboard signal') in inittab describing the - * desired action), so that the number of background daemons - * does not increase. + * See also the kbrequest field of inittab(5). */ case KDSIGACCEPT: { @@ -982,7 +982,7 @@ if (!perm) return -EPERM; - if (copy_from_user(&tmp, (void*)arg, sizeof(struct vt_mode))) + if (copy_from_user(&tmp, up, sizeof(struct vt_mode))) return -EFAULT; if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) return -EINVAL; @@ -1006,7 +1006,7 @@ memcpy(&tmp, &(vc->vt_mode), sizeof(struct vt_mode)); release_console_sem(); - rc = copy_to_user((void*)arg, &tmp, sizeof(struct vt_mode)); + rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); return rc ? -EFAULT : 0; } @@ -1017,7 +1017,7 @@ */ case VT_GETSTATE: { - struct vt_stat *vtstat = (struct vt_stat *)arg; + struct vt_stat *vtstat = up; unsigned short mask, state = 0; struct vc_data *tmp; @@ -1185,7 +1185,7 @@ } case VT_RESIZE: { - struct vt_sizes *vtsizes = (struct vt_sizes *) arg; + struct vt_sizes __user *vtsizes = up; ushort ll,cc; if (!perm) return -EPERM; @@ -1204,12 +1204,12 @@ case VT_RESIZEX: { - struct vt_consize *vtconsize = (struct vt_consize *) arg; + struct vt_consize *vtconsize = up; ushort ll,cc,vlin,clin,vcol,ccol; if (!perm) return -EPERM; - if (verify_area(VERIFY_READ, (void *)vtconsize, + if (verify_area(VERIFY_READ, vtconsize, sizeof(struct vt_consize))) return -EFAULT; __get_user(ll, &vtconsize->v_rows); @@ -1274,14 +1274,14 @@ case PIO_CMAP: if (!perm) return -EPERM; - return con_set_cmap(vc, (char *)arg); + return con_set_cmap(vc, up); case GIO_CMAP: - return con_get_cmap(vc, (char *)arg); + return con_get_cmap(vc, up); case PIO_FONTX: case GIO_FONTX: - return do_fontx_ioctl(vc, &op, (struct consolefontdesc *)arg, cmd, perm); + return do_fontx_ioctl(vc, &op, up, cmd, perm); case PIO_FONTRESET: { @@ -1305,13 +1305,13 @@ } case KDFONTOP: { - if (copy_from_user(&op, (void *) arg, sizeof(op))) + if (copy_from_user(&op, up, sizeof(op))) return -EFAULT; if (!perm && op.op != KD_FONT_OP_GET) return -EPERM; i = con_font_op(vc, &op); if (i) return i; - if (copy_to_user((void *) arg, &op, sizeof(op))) + if (copy_to_user(up, &op, sizeof(op))) return -EFAULT; return 0; } @@ -1319,24 +1319,24 @@ case PIO_SCRNMAP: if (!perm) return -EPERM; - return con_set_trans_old(vc, (unsigned char *)arg); + return con_set_trans_old(vc, up); case GIO_SCRNMAP: - return con_get_trans_old(vc, (unsigned char *)arg); + return con_get_trans_old(vc, up); case PIO_UNISCRNMAP: if (!perm) return -EPERM; - return con_set_trans_new(vc, (unsigned short *)arg); + return con_set_trans_new(vc, up); case GIO_UNISCRNMAP: - return con_get_trans_new(vc, (unsigned short *)arg); + return con_get_trans_new(vc, up); case PIO_UNIMAPCLR: { struct unimapinit ui; if (!perm) return -EPERM; - i = copy_from_user(&ui, (void *)arg, sizeof(struct unimapinit)); + i = copy_from_user(&ui, up, sizeof(struct unimapinit)); if (i) return -EFAULT; con_clear_unimap(vc, &ui); return 0; @@ -1344,7 +1344,7 @@ case PIO_UNIMAP: case GIO_UNIMAP: - return do_unimap_ioctl(vc, cmd, (struct unimapdesc *)arg, perm); + return do_unimap_ioctl(vc, cmd, up, perm); case VT_LOCKSWITCH: if (!capable(CAP_SYS_TTY_CONFIG)) |