Commit 79c58bde authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: vt and friends

vt, vt_ioctl, consolemap and selection annotated, struct unimapdesc
and struct consolefontdesc got __user on their pointer members.
parent f8ee27f6
...@@ -257,12 +257,12 @@ static void update_user_maps(void) ...@@ -257,12 +257,12 @@ static void update_user_maps(void)
* 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set * 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set
* Unicodes explicitly. * Unicodes explicitly.
*/ */
int con_set_trans_old(unsigned char * arg) int con_set_trans_old(unsigned char __user * arg)
{ {
int i; int i;
unsigned short *p = translations[USER_MAP]; 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) if (i)
return i; return i;
...@@ -276,12 +276,12 @@ int con_set_trans_old(unsigned char * arg) ...@@ -276,12 +276,12 @@ int con_set_trans_old(unsigned char * arg)
return 0; return 0;
} }
int con_get_trans_old(unsigned char * arg) int con_get_trans_old(unsigned char __user * arg)
{ {
int i, ch; int i, ch;
unsigned short *p = translations[USER_MAP]; 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) if (i)
return i; return i;
...@@ -293,13 +293,12 @@ int con_get_trans_old(unsigned char * arg) ...@@ -293,13 +293,12 @@ int con_get_trans_old(unsigned char * arg)
return 0; return 0;
} }
int con_set_trans_new(ushort * arg) int con_set_trans_new(ushort __user * arg)
{ {
int i; int i;
unsigned short *p = translations[USER_MAP]; unsigned short *p = translations[USER_MAP];
i = verify_area(VERIFY_READ, (void *)arg, i = verify_area(VERIFY_READ, arg, E_TABSZ*sizeof(unsigned short));
E_TABSZ*sizeof(unsigned short));
if (i) if (i)
return i; return i;
...@@ -313,13 +312,12 @@ int con_set_trans_new(ushort * arg) ...@@ -313,13 +312,12 @@ int con_set_trans_new(ushort * arg)
return 0; return 0;
} }
int con_get_trans_new(ushort * arg) int con_get_trans_new(ushort __user * arg)
{ {
int i; int i;
unsigned short *p = translations[USER_MAP]; unsigned short *p = translations[USER_MAP];
i = verify_area(VERIFY_WRITE, (void *)arg, i = verify_area(VERIFY_WRITE, arg, E_TABSZ*sizeof(unsigned short));
E_TABSZ*sizeof(unsigned short));
if (i) if (i)
return i; return i;
...@@ -470,7 +468,7 @@ int con_clear_unimap(int con, struct unimapinit *ui) ...@@ -470,7 +468,7 @@ int con_clear_unimap(int con, struct unimapinit *ui)
} }
int int
con_set_unimap(int con, ushort ct, struct unipair *list) con_set_unimap(int con, ushort ct, struct unipair __user *list)
{ {
int err = 0, err1, i; int err = 0, err1, i;
struct uni_pagedir *p, *q; struct uni_pagedir *p, *q;
...@@ -598,7 +596,7 @@ con_copy_unimap(int dstcon, int srccon) ...@@ -598,7 +596,7 @@ con_copy_unimap(int dstcon, int srccon)
} }
int int
con_get_unimap(int con, ushort ct, ushort *uct, struct unipair *list) con_get_unimap(int con, ushort ct, ushort __user *uct, struct unipair __user *list)
{ {
int i, j, k, ect; int i, j, k, ect;
u16 **p1, *p2; u16 **p1, *p2;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
* *
* This module exports the functions: * 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)' * 'void clear_selection(void)'
* 'int paste_selection(struct tty_struct *tty)' * 'int paste_selection(struct tty_struct *)'
* 'int sel_loadlut(const unsigned long arg)' * 'int sel_loadlut(char __user *)'
* *
* Now that /dev/vcs exists, most of this can disappear again. * Now that /dev/vcs exists, most of this can disappear again.
*/ */
...@@ -95,9 +95,9 @@ static inline int inword(const unsigned char c) { ...@@ -95,9 +95,9 @@ static inline int inword(const unsigned char c) {
} }
/* set inwordLut contents. Invoked by ioctl(). */ /* 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? */ /* does screen address p correspond to character at LH/RH edge of screen? */
...@@ -113,7 +113,7 @@ static inline unsigned short limit(const unsigned short v, const unsigned short ...@@ -113,7 +113,7 @@ static inline unsigned short limit(const unsigned short v, const unsigned short
} }
/* set the current selection. Invoked by ioctl() or by kernel code. */ /* 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)
{ {
int sel_mode, new_sel_start, new_sel_end, spc; int sel_mode, new_sel_start, new_sel_end, spc;
char *bp, *obp; char *bp, *obp;
...@@ -124,7 +124,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int ...@@ -124,7 +124,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int
{ unsigned short xs, ys, xe, ye; { unsigned short xs, ys, xe, ye;
if (user) {
if (verify_area(VERIFY_READ, sel, sizeof(*sel))) if (verify_area(VERIFY_READ, sel, sizeof(*sel)))
return -EFAULT; return -EFAULT;
__get_user(xs, &sel->xs); __get_user(xs, &sel->xs);
...@@ -132,13 +131,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int ...@@ -132,13 +131,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int
__get_user(xe, &sel->xe); __get_user(xe, &sel->xe);
__get_user(ye, &sel->ye); __get_user(ye, &sel->ye);
__get_user(sel_mode, &sel->sel_mode); __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;
}
xs--; ys--; xe--; ye--; xs--; ys--; xe--; ye--;
xs = limit(xs, video_num_columns - 1); xs = limit(xs, video_num_columns - 1);
ys = limit(ys, video_num_lines - 1); ys = limit(ys, video_num_lines - 1);
......
...@@ -152,7 +152,7 @@ static void gotoxy(int currcons, int new_x, int new_y); ...@@ -152,7 +152,7 @@ static void gotoxy(int currcons, int new_x, int new_y);
static void save_cur(int currcons); static void save_cur(int currcons);
static void reset_terminal(int currcons, int do_clear); static void reset_terminal(int currcons, int do_clear);
static void con_flush_chars(struct tty_struct *tty); static void con_flush_chars(struct tty_struct *tty);
static void set_vesa_blanking(unsigned long arg); static void set_vesa_blanking(char __user *p);
static void set_cursor(int currcons); static void set_cursor(int currcons);
static void hide_cursor(int currcons); static void hide_cursor(int currcons);
static void console_callback(void *ignored); static void console_callback(void *ignored);
...@@ -2274,6 +2274,7 @@ struct console vt_console_driver = { ...@@ -2274,6 +2274,7 @@ struct console vt_console_driver = {
int tioclinux(struct tty_struct *tty, unsigned long arg) int tioclinux(struct tty_struct *tty, unsigned long arg)
{ {
char type, data; char type, data;
char __user *p = (char __user *)arg;
int lines; int lines;
int ret; int ret;
...@@ -2281,14 +2282,14 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2281,14 +2282,14 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
return -EINVAL; return -EINVAL;
if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
if (get_user(type, (char *)arg)) if (get_user(type, p))
return -EFAULT; return -EFAULT;
ret = 0; ret = 0;
switch (type) switch (type)
{ {
case TIOCL_SETSEL: case TIOCL_SETSEL:
acquire_console_sem(); 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(); release_console_sem();
break; break;
case TIOCL_PASTESEL: case TIOCL_PASTESEL:
...@@ -2298,7 +2299,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2298,7 +2299,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
unblank_screen(); unblank_screen();
break; break;
case TIOCL_SELLOADLUT: case TIOCL_SELLOADLUT:
ret = sel_loadlut(arg); ret = sel_loadlut(p);
break; break;
case TIOCL_GETSHIFTSTATE: case TIOCL_GETSHIFTSTATE:
...@@ -2309,20 +2310,20 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2309,20 +2310,20 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
* related to the kernel should not use this. * related to the kernel should not use this.
*/ */
data = shift_state; data = shift_state;
ret = __put_user(data, (char *) arg); ret = __put_user(data, p);
break; break;
case TIOCL_GETMOUSEREPORTING: case TIOCL_GETMOUSEREPORTING:
data = mouse_reporting(); data = mouse_reporting();
ret = __put_user(data, (char *) arg); ret = __put_user(data, p);
break; break;
case TIOCL_SETVESABLANK: case TIOCL_SETVESABLANK:
set_vesa_blanking(arg); set_vesa_blanking(p);
break; break;
case TIOCL_SETKMSGREDIRECT: case TIOCL_SETKMSGREDIRECT:
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
ret = -EPERM; ret = -EPERM;
} else { } else {
if (get_user(data, (char *)arg+1)) if (get_user(data, p+1))
ret = -EFAULT; ret = -EFAULT;
else else
kmsg_redirect = data; kmsg_redirect = data;
...@@ -2332,7 +2333,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) ...@@ -2332,7 +2333,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
ret = fg_console; ret = fg_console;
break; break;
case TIOCL_SCROLLCONSOLE: case TIOCL_SCROLLCONSOLE:
if (get_user(lines, (s32 *)((char *)arg+4))) { if (get_user(lines, (s32 __user *)(p+4))) {
ret = -EFAULT; ret = -EFAULT;
} else { } else {
scrollfront(lines); scrollfront(lines);
...@@ -2757,11 +2758,10 @@ void give_up_console(const struct consw *csw) ...@@ -2757,11 +2758,10 @@ void give_up_console(const struct consw *csw)
* Screen blanking * Screen blanking
*/ */
static void set_vesa_blanking(unsigned long arg) static void set_vesa_blanking(char __user *p)
{ {
char *argp = (char *)arg + 1;
unsigned int mode; unsigned int mode;
get_user(mode, argp); get_user(mode, p + 1);
vesa_blank_mode = (mode < 4) ? mode : 0; vesa_blank_mode = (mode < 4) ? mode : 0;
} }
...@@ -2937,7 +2937,7 @@ void set_palette(int currcons) ...@@ -2937,7 +2937,7 @@ void set_palette(int currcons)
sw->con_set_palette(vc_cons[currcons].d, color_table); sw->con_set_palette(vc_cons[currcons].d, color_table);
} }
static int set_get_cmap(unsigned char *arg, int set) static int set_get_cmap(unsigned char __user *arg, int set)
{ {
int i, j, k; int i, j, k;
...@@ -2972,7 +2972,7 @@ static int set_get_cmap(unsigned char *arg, int set) ...@@ -2972,7 +2972,7 @@ static int set_get_cmap(unsigned char *arg, int set)
* map, 3 bytes per colour, 16 colours, range from 0 to 255. * map, 3 bytes per colour, 16 colours, range from 0 to 255.
*/ */
int con_set_cmap(unsigned char *arg) int con_set_cmap(unsigned char __user *arg)
{ {
int rc; int rc;
...@@ -2983,7 +2983,7 @@ int con_set_cmap(unsigned char *arg) ...@@ -2983,7 +2983,7 @@ int con_set_cmap(unsigned char *arg)
return rc; return rc;
} }
int con_get_cmap(unsigned char *arg) int con_get_cmap(unsigned char __user *arg)
{ {
int rc; int rc;
...@@ -3037,7 +3037,8 @@ int con_font_op(int currcons, struct console_font_op *op) ...@@ -3037,7 +3037,8 @@ int con_font_op(int currcons, struct console_font_op *op)
goto quit; goto quit;
if (!op->height) { /* Need to guess font height [compat] */ if (!op->height) { /* Need to guess font height [compat] */
int h, i; 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, /* If from KDFONTOP ioctl, don't allow things which can be done in userland,
so that we can get rid of this soon */ so that we can get rid of this soon */
......
...@@ -75,7 +75,7 @@ unsigned char keyboard_type = KB_101; ...@@ -75,7 +75,7 @@ unsigned char keyboard_type = KB_101;
#define s (tmp.kb_table) #define s (tmp.kb_table)
#define v (tmp.kb_value) #define v (tmp.kb_value)
static inline int static inline int
do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kbd) do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_struct *kbd)
{ {
struct kbentry tmp; struct kbentry tmp;
ushort *key_map, val, ov; ushort *key_map, val, ov;
...@@ -160,7 +160,7 @@ do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kb ...@@ -160,7 +160,7 @@ do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kb
#undef v #undef v
static inline int static inline int
do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm) do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, int perm)
{ {
struct kbkeycode tmp; struct kbkeycode tmp;
int kc = 0; int kc = 0;
...@@ -183,11 +183,12 @@ do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm) ...@@ -183,11 +183,12 @@ do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm)
} }
static inline int 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)
{ {
struct kbsentry *kbs; struct kbsentry *kbs;
char *p; char *p;
u_char *q; u_char *q;
u_char __user *up;
int sz; int sz;
int delta; int delta;
char *first_free, *fj, *fnw; char *first_free, *fj, *fnw;
...@@ -212,15 +213,15 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm) ...@@ -212,15 +213,15 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
case KDGKBSENT: case KDGKBSENT:
sz = sizeof(kbs->kb_string) - 1; /* sz should have been sz = sizeof(kbs->kb_string) - 1; /* sz should have been
a struct member */ a struct member */
q = user_kdgkb->kb_string; up = user_kdgkb->kb_string;
p = func_table[i]; p = func_table[i];
if(p) if(p)
for ( ; *p && sz; p++, sz--) for ( ; *p && sz; p++, sz--)
if (put_user(*p, q++)) { if (put_user(*p, up++)) {
ret = -EFAULT; ret = -EFAULT;
goto reterr; goto reterr;
} }
if (put_user('\0', q)) { if (put_user('\0', up)) {
ret = -EFAULT; ret = -EFAULT;
goto reterr; goto reterr;
} }
...@@ -292,7 +293,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm) ...@@ -292,7 +293,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
} }
static inline int static inline int
do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm, struct console_font_op *op) do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struct console_font_op *op)
{ {
struct consolefontdesc cfdarg; struct consolefontdesc cfdarg;
int i; int i;
...@@ -332,7 +333,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm, struct conso ...@@ -332,7 +333,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm, struct conso
} }
static inline int static inline int
do_unimap_ioctl(int cmd, struct unimapdesc *user_ud, int perm, unsigned int console) do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, unsigned int console)
{ {
struct unimapdesc tmp; struct unimapdesc tmp;
int i = 0; int i = 0;
...@@ -370,6 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -370,6 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
struct kbd_struct * kbd; struct kbd_struct * kbd;
unsigned int console; unsigned int console;
unsigned char ucval; unsigned char ucval;
void __user *up = (void __user *)arg;
int i, perm; int i, perm;
console = vt->vc_num; console = vt->vc_num;
...@@ -453,14 +455,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -453,14 +455,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
if (!capable(CAP_SYS_TTY_CONFIG)) if (!capable(CAP_SYS_TTY_CONFIG))
return -EPERM; return -EPERM;
if (copy_from_user(&kbrep, (void *)arg, if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat)))
sizeof(struct kbd_repeat)))
return -EFAULT; return -EFAULT;
err = kbd_rate(&kbrep); err = kbd_rate(&kbrep);
if (err) if (err)
return err; return err;
if (copy_to_user((void *)arg, &kbrep, if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))
sizeof(struct kbd_repeat)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -565,25 +565,25 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -565,25 +565,25 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDGKBMETA: case KDGKBMETA:
ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT); ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
setint: setint:
return put_user(ucval, (int *)arg); return put_user(ucval, (int __user *)arg);
case KDGETKEYCODE: case KDGETKEYCODE:
case KDSETKEYCODE: case KDSETKEYCODE:
if(!capable(CAP_SYS_TTY_CONFIG)) if(!capable(CAP_SYS_TTY_CONFIG))
perm=0; perm=0;
return do_kbkeycode_ioctl(cmd, (struct kbkeycode *)arg, perm); return do_kbkeycode_ioctl(cmd, up, perm);
case KDGKBENT: case KDGKBENT:
case KDSKBENT: case KDSKBENT:
return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd); return do_kdsk_ioctl(cmd, up, perm, kbd);
case KDGKBSENT: case KDGKBSENT:
case KDSKBSENT: case KDSKBSENT:
return do_kdgkb_ioctl(cmd, (struct kbsentry *)arg, perm); return do_kdgkb_ioctl(cmd, up, perm);
case KDGKBDIACR: case KDGKBDIACR:
{ {
struct kbdiacrs *a = (struct kbdiacrs *)arg; struct kbdiacrs __user *a = up;
if (put_user(accent_table_size, &a->kb_cnt)) if (put_user(accent_table_size, &a->kb_cnt))
return -EFAULT; return -EFAULT;
...@@ -594,7 +594,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -594,7 +594,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDSKBDIACR: case KDSKBDIACR:
{ {
struct kbdiacrs *a = (struct kbdiacrs *)arg; struct kbdiacrs __user *a = up;
unsigned int ct; unsigned int ct;
if (!perm) if (!perm)
...@@ -630,7 +630,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -630,7 +630,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDGETLED: case KDGETLED:
ucval = getledstate(); ucval = getledstate();
setchar: setchar:
return put_user(ucval, (char*)arg); return put_user(ucval, (char __user *)arg);
case KDSETLED: case KDSETLED:
if (!perm) if (!perm)
...@@ -663,7 +663,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -663,7 +663,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
if (!perm) if (!perm)
return -EPERM; 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; return -EFAULT;
if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS)
return -EINVAL; return -EINVAL;
...@@ -687,7 +687,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -687,7 +687,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
memcpy(&tmp, &vt_cons[console]->vt_mode, sizeof(struct vt_mode)); memcpy(&tmp, &vt_cons[console]->vt_mode, sizeof(struct vt_mode));
release_console_sem(); 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; return rc ? -EFAULT : 0;
} }
...@@ -698,7 +698,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -698,7 +698,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
*/ */
case VT_GETSTATE: case VT_GETSTATE:
{ {
struct vt_stat *vtstat = (struct vt_stat *)arg; struct vt_stat __user *vtstat = up;
unsigned short state, mask; unsigned short state, mask;
if (put_user(fg_console + 1, &vtstat->v_active)) if (put_user(fg_console + 1, &vtstat->v_active))
...@@ -844,7 +844,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -844,7 +844,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case VT_RESIZE: case VT_RESIZE:
{ {
struct vt_sizes *vtsizes = (struct vt_sizes *) arg; struct vt_sizes __user *vtsizes = up;
ushort ll,cc; ushort ll,cc;
if (!perm) if (!perm)
return -EPERM; return -EPERM;
...@@ -861,11 +861,11 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -861,11 +861,11 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case VT_RESIZEX: case VT_RESIZEX:
{ {
struct vt_consize *vtconsize = (struct vt_consize *) arg; struct vt_consize __user *vtconsize = up;
ushort ll,cc,vlin,clin,vcol,ccol; ushort ll,cc,vlin,clin,vcol,ccol;
if (!perm) if (!perm)
return -EPERM; return -EPERM;
if (verify_area(VERIFY_READ, (void *)vtconsize, if (verify_area(VERIFY_READ, vtconsize,
sizeof(struct vt_consize))) sizeof(struct vt_consize)))
return -EFAULT; return -EFAULT;
__get_user(ll, &vtconsize->v_rows); __get_user(ll, &vtconsize->v_rows);
...@@ -932,14 +932,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -932,14 +932,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_CMAP: case PIO_CMAP:
if (!perm) if (!perm)
return -EPERM; return -EPERM;
return con_set_cmap((char *)arg); return con_set_cmap(up);
case GIO_CMAP: case GIO_CMAP:
return con_get_cmap((char *)arg); return con_get_cmap(up);
case PIO_FONTX: case PIO_FONTX:
case GIO_FONTX: case GIO_FONTX:
return do_fontx_ioctl(cmd, (struct consolefontdesc *)arg, perm, &op); return do_fontx_ioctl(cmd, up, perm, &op);
case PIO_FONTRESET: case PIO_FONTRESET:
{ {
...@@ -963,13 +963,13 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -963,13 +963,13 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
} }
case KDFONTOP: { case KDFONTOP: {
if (copy_from_user(&op, (void *) arg, sizeof(op))) if (copy_from_user(&op, up, sizeof(op)))
return -EFAULT; return -EFAULT;
if (!perm && op.op != KD_FONT_OP_GET) if (!perm && op.op != KD_FONT_OP_GET)
return -EPERM; return -EPERM;
i = con_font_op(console, &op); i = con_font_op(console, &op);
if (i) return i; if (i) return i;
if (copy_to_user((void *) arg, &op, sizeof(op))) if (copy_to_user(up, &op, sizeof(op)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -977,24 +977,24 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -977,24 +977,24 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_SCRNMAP: case PIO_SCRNMAP:
if (!perm) if (!perm)
return -EPERM; return -EPERM;
return con_set_trans_old((unsigned char *)arg); return con_set_trans_old(up);
case GIO_SCRNMAP: case GIO_SCRNMAP:
return con_get_trans_old((unsigned char *)arg); return con_get_trans_old(up);
case PIO_UNISCRNMAP: case PIO_UNISCRNMAP:
if (!perm) if (!perm)
return -EPERM; return -EPERM;
return con_set_trans_new((unsigned short *)arg); return con_set_trans_new(up);
case GIO_UNISCRNMAP: case GIO_UNISCRNMAP:
return con_get_trans_new((unsigned short *)arg); return con_get_trans_new(up);
case PIO_UNIMAPCLR: case PIO_UNIMAPCLR:
{ struct unimapinit ui; { struct unimapinit ui;
if (!perm) if (!perm)
return -EPERM; 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; if (i) return -EFAULT;
con_clear_unimap(console, &ui); con_clear_unimap(console, &ui);
return 0; return 0;
...@@ -1002,7 +1002,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -1002,7 +1002,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_UNIMAP: case PIO_UNIMAP:
case GIO_UNIMAP: case GIO_UNIMAP:
return do_unimap_ioctl(cmd, (struct unimapdesc *)arg, perm, console); return do_unimap_ioctl(cmd, up, perm, console);
case VT_LOCKSWITCH: case VT_LOCKSWITCH:
if (!capable(CAP_SYS_TTY_CONFIG)) if (!capable(CAP_SYS_TTY_CONFIG))
......
#ifndef _LINUX_KD_H #ifndef _LINUX_KD_H
#define _LINUX_KD_H #define _LINUX_KD_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/compiler.h>
/* 0x4B is 'K', to avoid collision with termios and vt */ /* 0x4B is 'K', to avoid collision with termios and vt */
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
struct consolefontdesc { struct consolefontdesc {
unsigned short charcount; /* characters in font (256 or 512) */ unsigned short charcount; /* characters in font (256 or 512) */
unsigned short charheight; /* scan lines per character (1-32) */ unsigned short charheight; /* scan lines per character (1-32) */
char *chardata; /* font data in expanded form */ char __user *chardata; /* font data in expanded form */
}; };
#define PIO_FONTRESET 0x4B6D /* reset to default font */ #define PIO_FONTRESET 0x4B6D /* reset to default font */
...@@ -63,7 +64,7 @@ struct unipair { ...@@ -63,7 +64,7 @@ struct unipair {
}; };
struct unimapdesc { struct unimapdesc {
unsigned short entry_ct; unsigned short entry_ct;
struct unipair *entries; struct unipair __user *entries;
}; };
#define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */ #define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */
#define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */ #define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
extern int sel_cons; extern int sel_cons;
extern void clear_selection(void); extern void clear_selection(void);
extern int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int user); extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
extern int paste_selection(struct tty_struct *tty); extern int paste_selection(struct tty_struct *tty);
extern int sel_loadlut(const unsigned long arg); extern int sel_loadlut(char __user *p);
extern int mouse_reporting(void); extern int mouse_reporting(void);
extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
......
...@@ -49,8 +49,8 @@ void do_unblank_screen(int leaving_gfx); ...@@ -49,8 +49,8 @@ void do_unblank_screen(int leaving_gfx);
void unblank_screen(void); void unblank_screen(void);
void poke_blanked_console(void); void poke_blanked_console(void);
int con_font_op(int currcons, struct console_font_op *op); int con_font_op(int currcons, struct console_font_op *op);
int con_set_cmap(unsigned char *cmap); int con_set_cmap(unsigned char __user *cmap);
int con_get_cmap(unsigned char *cmap); int con_get_cmap(unsigned char __user *cmap);
void scrollback(int); void scrollback(int);
void scrollfront(int); void scrollfront(int);
void update_region(int currcons, unsigned long start, int count); void update_region(int currcons, unsigned long start, int count);
...@@ -66,13 +66,13 @@ int tioclinux(struct tty_struct *tty, unsigned long arg); ...@@ -66,13 +66,13 @@ int tioclinux(struct tty_struct *tty, unsigned long arg);
struct unimapinit; struct unimapinit;
struct unipair; struct unipair;
int con_set_trans_old(unsigned char * table); int con_set_trans_old(unsigned char __user * table);
int con_get_trans_old(unsigned char * table); int con_get_trans_old(unsigned char __user * table);
int con_set_trans_new(unsigned short * table); int con_set_trans_new(unsigned short __user * table);
int con_get_trans_new(unsigned short * table); int con_get_trans_new(unsigned short __user * table);
int con_clear_unimap(int currcons, struct unimapinit *ui); int con_clear_unimap(int currcons, struct unimapinit *ui);
int con_set_unimap(int currcons, ushort ct, struct unipair *list); int con_set_unimap(int currcons, ushort ct, struct unipair __user *list);
int con_get_unimap(int currcons, ushort ct, ushort *uct, struct unipair *list); int con_get_unimap(int currcons, ushort ct, ushort __user *uct, struct unipair __user *list);
int con_set_default_unimap(int currcons); int con_set_default_unimap(int currcons);
void con_free_unimap(int currcons); void con_free_unimap(int currcons);
void con_protect_unimap(int currcons, int rdonly); void con_protect_unimap(int currcons, int rdonly);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment