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)
* 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set
* Unicodes explicitly.
*/
int con_set_trans_old(unsigned char * arg)
int con_set_trans_old(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;
......@@ -276,12 +276,12 @@ int con_set_trans_old(unsigned char * arg)
return 0;
}
int con_get_trans_old(unsigned char * arg)
int con_get_trans_old(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;
......@@ -293,13 +293,12 @@ int con_get_trans_old(unsigned char * arg)
return 0;
}
int con_set_trans_new(ushort * arg)
int con_set_trans_new(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;
......@@ -313,13 +312,12 @@ int con_set_trans_new(ushort * arg)
return 0;
}
int con_get_trans_new(ushort * arg)
int con_get_trans_new(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;
......@@ -470,7 +468,7 @@ int con_clear_unimap(int con, struct unimapinit *ui)
}
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;
struct uni_pagedir *p, *q;
......@@ -598,7 +596,7 @@ con_copy_unimap(int dstcon, int srccon)
}
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;
u16 **p1, *p2;
......
......@@ -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.
*/
......@@ -95,9 +95,9 @@ static inline int inword(const unsigned char c) {
}
/* 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? */
......@@ -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. */
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;
char *bp, *obp;
......@@ -124,7 +124,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int
{ unsigned short xs, ys, xe, ye;
if (user) {
if (verify_area(VERIFY_READ, sel, sizeof(*sel)))
return -EFAULT;
__get_user(xs, &sel->xs);
......@@ -132,13 +131,6 @@ int set_selection(const struct tiocl_selection *sel, struct tty_struct *tty, int
__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;
}
xs--; ys--; xe--; ye--;
xs = limit(xs, video_num_columns - 1);
ys = limit(ys, video_num_lines - 1);
......
......@@ -152,7 +152,7 @@ static void gotoxy(int currcons, int new_x, int new_y);
static void save_cur(int currcons);
static void reset_terminal(int currcons, int do_clear);
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 hide_cursor(int currcons);
static void console_callback(void *ignored);
......@@ -2274,6 +2274,7 @@ struct console vt_console_driver = {
int tioclinux(struct tty_struct *tty, unsigned long arg)
{
char type, data;
char __user *p = (char __user *)arg;
int lines;
int ret;
......@@ -2281,14 +2282,14 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
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:
......@@ -2298,7 +2299,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
unblank_screen();
break;
case TIOCL_SELLOADLUT:
ret = sel_loadlut(arg);
ret = sel_loadlut(p);
break;
case TIOCL_GETSHIFTSTATE:
......@@ -2309,20 +2310,20 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
* 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();
ret = __put_user(data, (char *) arg);
ret = __put_user(data, p);
break;
case TIOCL_SETVESABLANK:
set_vesa_blanking(arg);
set_vesa_blanking(p);
break;
case TIOCL_SETKMSGREDIRECT:
if (!capable(CAP_SYS_ADMIN)) {
ret = -EPERM;
} else {
if (get_user(data, (char *)arg+1))
if (get_user(data, p+1))
ret = -EFAULT;
else
kmsg_redirect = data;
......@@ -2332,7 +2333,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
ret = fg_console;
break;
case TIOCL_SCROLLCONSOLE:
if (get_user(lines, (s32 *)((char *)arg+4))) {
if (get_user(lines, (s32 __user *)(p+4))) {
ret = -EFAULT;
} else {
scrollfront(lines);
......@@ -2757,11 +2758,10 @@ void give_up_console(const struct consw *csw)
* 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;
get_user(mode, argp);
get_user(mode, p + 1);
vesa_blank_mode = (mode < 4) ? mode : 0;
}
......@@ -2937,7 +2937,7 @@ void set_palette(int currcons)
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;
......@@ -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.
*/
int con_set_cmap(unsigned char *arg)
int con_set_cmap(unsigned char __user *arg)
{
int rc;
......@@ -2983,7 +2983,7 @@ int con_set_cmap(unsigned char *arg)
return rc;
}
int con_get_cmap(unsigned char *arg)
int con_get_cmap(unsigned char __user *arg)
{
int rc;
......@@ -3037,7 +3037,8 @@ int con_font_op(int currcons, struct console_font_op *op)
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,
so that we can get rid of this soon */
......
......@@ -75,7 +75,7 @@ unsigned char keyboard_type = KB_101;
#define s (tmp.kb_table)
#define v (tmp.kb_value)
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;
ushort *key_map, val, ov;
......@@ -160,7 +160,7 @@ do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kb
#undef v
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;
int kc = 0;
......@@ -183,11 +183,12 @@ do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm)
}
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;
char *p;
u_char *q;
u_char __user *up;
int sz;
int delta;
char *first_free, *fj, *fnw;
......@@ -212,15 +213,15 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
case KDGKBSENT:
sz = sizeof(kbs->kb_string) - 1; /* sz should have been
a struct member */
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;
}
......@@ -292,7 +293,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
}
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;
int i;
......@@ -332,7 +333,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm, struct conso
}
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;
int i = 0;
......@@ -370,6 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
struct kbd_struct * kbd;
unsigned int console;
unsigned char ucval;
void __user *up = (void __user *)arg;
int i, perm;
console = vt->vc_num;
......@@ -453,14 +455,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
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(&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;
}
......@@ -565,25 +565,25 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDGKBMETA:
ucval = (vc_kbd_mode(kbd, 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(cmd, (struct kbkeycode *)arg, perm);
return do_kbkeycode_ioctl(cmd, up, perm);
case KDGKBENT:
case KDSKBENT:
return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd);
return do_kdsk_ioctl(cmd, up, perm, kbd);
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 __user *a = up;
if (put_user(accent_table_size, &a->kb_cnt))
return -EFAULT;
......@@ -594,7 +594,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDSKBDIACR:
{
struct kbdiacrs *a = (struct kbdiacrs *)arg;
struct kbdiacrs __user *a = up;
unsigned int ct;
if (!perm)
......@@ -630,7 +630,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KDGETLED:
ucval = getledstate();
setchar:
return put_user(ucval, (char*)arg);
return put_user(ucval, (char __user *)arg);
case KDSETLED:
if (!perm)
......@@ -663,7 +663,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
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;
......@@ -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));
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;
}
......@@ -698,7 +698,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
*/
case VT_GETSTATE:
{
struct vt_stat *vtstat = (struct vt_stat *)arg;
struct vt_stat __user *vtstat = up;
unsigned short state, mask;
if (put_user(fg_console + 1, &vtstat->v_active))
......@@ -844,7 +844,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case VT_RESIZE:
{
struct vt_sizes *vtsizes = (struct vt_sizes *) arg;
struct vt_sizes __user *vtsizes = up;
ushort ll,cc;
if (!perm)
return -EPERM;
......@@ -861,11 +861,11 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case VT_RESIZEX:
{
struct vt_consize *vtconsize = (struct vt_consize *) arg;
struct vt_consize __user *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);
......@@ -932,14 +932,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_CMAP:
if (!perm)
return -EPERM;
return con_set_cmap((char *)arg);
return con_set_cmap(up);
case GIO_CMAP:
return con_get_cmap((char *)arg);
return con_get_cmap(up);
case PIO_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:
{
......@@ -963,13 +963,13 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
}
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(console, &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;
}
......@@ -977,24 +977,24 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_SCRNMAP:
if (!perm)
return -EPERM;
return con_set_trans_old((unsigned char *)arg);
return con_set_trans_old(up);
case GIO_SCRNMAP:
return con_get_trans_old((unsigned char *)arg);
return con_get_trans_old(up);
case PIO_UNISCRNMAP:
if (!perm)
return -EPERM;
return con_set_trans_new((unsigned short *)arg);
return con_set_trans_new(up);
case GIO_UNISCRNMAP:
return con_get_trans_new((unsigned short *)arg);
return con_get_trans_new(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(console, &ui);
return 0;
......@@ -1002,7 +1002,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case PIO_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:
if (!capable(CAP_SYS_TTY_CONFIG))
......
#ifndef _LINUX_KD_H
#define _LINUX_KD_H
#include <linux/types.h>
#include <linux/compiler.h>
/* 0x4B is 'K', to avoid collision with termios and vt */
......@@ -12,7 +13,7 @@
struct consolefontdesc {
unsigned short charcount; /* characters in font (256 or 512) */
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 */
......@@ -63,7 +64,7 @@ struct unipair {
};
struct unimapdesc {
unsigned short entry_ct;
struct unipair *entries;
struct unipair __user *entries;
};
#define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */
#define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */
......
......@@ -13,9 +13,9 @@
extern int sel_cons;
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 sel_loadlut(const unsigned long arg);
extern int sel_loadlut(char __user *p);
extern int mouse_reporting(void);
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);
void unblank_screen(void);
void poke_blanked_console(void);
int con_font_op(int currcons, struct console_font_op *op);
int con_set_cmap(unsigned char *cmap);
int con_get_cmap(unsigned char *cmap);
int con_set_cmap(unsigned char __user *cmap);
int con_get_cmap(unsigned char __user *cmap);
void scrollback(int);
void scrollfront(int);
void update_region(int currcons, unsigned long start, int count);
......@@ -66,13 +66,13 @@ int tioclinux(struct tty_struct *tty, unsigned long arg);
struct unimapinit;
struct unipair;
int con_set_trans_old(unsigned char * table);
int con_get_trans_old(unsigned char * table);
int con_set_trans_new(unsigned short * table);
int con_get_trans_new(unsigned short * table);
int con_set_trans_old(unsigned char __user * table);
int con_get_trans_old(unsigned char __user * table);
int con_set_trans_new(unsigned short __user * table);
int con_get_trans_new(unsigned short __user * table);
int con_clear_unimap(int currcons, struct unimapinit *ui);
int con_set_unimap(int currcons, ushort ct, struct unipair *list);
int con_get_unimap(int currcons, ushort ct, ushort *uct, struct unipair *list);
int con_set_unimap(int currcons, ushort ct, struct unipair __user *list);
int con_get_unimap(int currcons, ushort ct, ushort __user *uct, struct unipair __user *list);
int con_set_default_unimap(int currcons);
void con_free_unimap(int currcons);
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