patch-2.4.9 linux/drivers/char/vt.c
Next file: linux/drivers/char/w83877f_wdt.c
Previous file: linux/drivers/char/tty_ioctl.c
Back to the patch index
Back to the overall index
- Lines: 145
- Date:
Sun Aug 12 17:37:53 2001
- Orig file:
v2.4.8/linux/drivers/char/vt.c
- Orig date:
Fri Feb 9 11:30:22 2001
diff -u --recursive --new-file v2.4.8/linux/drivers/char/vt.c linux/drivers/char/vt.c
@@ -7,6 +7,7 @@
* Dynamic keymap and string allocation - aeb@cwi.nl - May 1994
* Restrict VT switching via ioctl() - grif@cs.ucr.edu - Dec 1995
* Some code moved for less code duplication - Andi Kleen - Mar 1997
+ * Check put/get_user, cleanups - acme@conectiva.com.br - Jun 2001
*/
#include <linux/config.h>
@@ -23,13 +24,11 @@
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/console.h>
+#include <linux/irq.h>
#include <asm/io.h>
#include <asm/uaccess.h>
-
-#if defined(__mc68000__) || defined(CONFIG_APUS)
-#include <asm/machdep.h>
-#endif
+#include <asm/keyboard.h>
#include <linux/kbd_kern.h>
#include <linux/vt_kern.h>
@@ -289,8 +288,10 @@
p = func_table[i];
if(p)
for ( ; *p && sz; p++, sz--)
- put_user(*p, q++);
- put_user('\0', q);
+ if (put_user(*p, q++))
+ return -EFAULT;
+ if (put_user('\0', q))
+ return -EFAULT;
return ((p && *p) ? -EOVERFLOW : 0);
case KDSKBSENT:
if (!perm)
@@ -497,26 +498,26 @@
(cmd == KDENABIO)) ? -ENXIO : 0;
#endif
-#if defined(__mc68000__) || defined(CONFIG_APUS)
- /* Linux/m68k interface for setting the keyboard delay/repeat rate */
+ /* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */
case KDKBDREP:
{
struct kbd_repeat kbrep;
- if (!mach_kbdrate) return( -EINVAL );
- if (!suser()) return( -EPERM );
+ if (!kbd_rate) return( -EINVAL );
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
if (copy_from_user(&kbrep, (void *)arg,
sizeof(struct kbd_repeat)))
return -EFAULT;
- if ((i = mach_kbdrate( &kbrep ))) return( i );
+ if ((i = kbd_rate( &kbrep )))
+ return i;
if (copy_to_user((void *)arg, &kbrep,
sizeof(struct kbd_repeat)))
return -EFAULT;
return 0;
}
-#endif
case KDSETMODE:
/*
@@ -741,10 +742,8 @@
struct vt_stat *vtstat = (struct vt_stat *)arg;
unsigned short state, mask;
- i = verify_area(VERIFY_WRITE,(void *)vtstat, sizeof(struct vt_stat));
- if (i)
- return i;
- put_user(fg_console + 1, &vtstat->v_active);
+ if (put_user(fg_console + 1, &vtstat->v_active))
+ return -EFAULT;
state = 1; /* /dev/tty0 is always open */
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask; ++i, mask <<= 1)
if (VT_IS_IN_USE(i))
@@ -880,11 +879,9 @@
ushort ll,cc;
if (!perm)
return -EPERM;
- i = verify_area(VERIFY_READ, (void *)vtsizes, sizeof(struct vt_sizes));
- if (i)
- return i;
- get_user(ll, &vtsizes->v_rows);
- get_user(cc, &vtsizes->v_cols);
+ if (get_user(ll, &vtsizes->v_rows) ||
+ get_user(cc, &vtsizes->v_cols))
+ return -EFAULT;
return vc_resize_all(ll, cc);
}
@@ -894,15 +891,15 @@
ushort ll,cc,vlin,clin,vcol,ccol;
if (!perm)
return -EPERM;
- i = verify_area(VERIFY_READ, (void *)vtconsize, sizeof(struct vt_consize));
- if (i)
- return i;
- get_user(ll, &vtconsize->v_rows);
- get_user(cc, &vtconsize->v_cols);
- get_user(vlin, &vtconsize->v_vlin);
- get_user(clin, &vtconsize->v_clin);
- get_user(vcol, &vtconsize->v_vcol);
- get_user(ccol, &vtconsize->v_ccol);
+ if (verify_area(VERIFY_READ, (void *)vtconsize,
+ sizeof(struct vt_consize)))
+ return -EFAULT;
+ __get_user(ll, &vtconsize->v_rows);
+ __get_user(cc, &vtconsize->v_cols);
+ __get_user(vlin, &vtconsize->v_vlin);
+ __get_user(clin, &vtconsize->v_clin);
+ __get_user(vcol, &vtconsize->v_vcol);
+ __get_user(ccol, &vtconsize->v_ccol);
vlin = vlin ? vlin : video_scan_lines;
if ( clin )
{
@@ -1069,10 +1066,6 @@
if (!perm)
return -EPERM;
- i = verify_area(VERIFY_READ, (void *) arg,
- sizeof(struct vc_mode));
- if (i)
- return i;
if (copy_from_user(&mode, (void *) arg, sizeof(mode)))
return -EFAULT;
return console_setmode(&mode, cmd == VC_SETMODE);
@@ -1090,10 +1083,6 @@
was changed from 0x766a to 0x766c */
return console_powermode((int) arg);
}
- i = verify_area(VERIFY_READ, (void *) arg,
- sizeof(int));
- if (i)
- return i;
if (get_user(cmap_size, (int *) arg))
return -EFAULT;
if (cmap_size % 3)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)